PHP Class LdapTools\Ldif\LdifParser

Author: Chad Sikorra ([email protected])
Afficher le fichier Open project: ldaptools/ldaptools

Protected Properties

Свойство Type Description
$changeTypeMap A simple changetype to full class name mapping.
$commentQueue Any comments pending for the next entry in the LDIF.
$line The current line number we are on during parsing.
$lines string[]
$urlLoaders LdapTools\Ldif\UrlLoader\UrlLoaderInterface[] An array of UrlLoaders with the key set to the type of URL they handle.

Méthodes publiques

Méthode Description
__construct ( )
hasUrlLoader ( string $type ) : boolean Check if a URL loader for a specific URL type exists.
parse ( string $ldif ) : Ldif Parses a string containing LDIF data and returns an object with the entries it contains.
removeUrlLoader ( string $type ) Remove a URL loader by its string type.
setUrlLoader ( string $type, LdapTools\Ldif\UrlLoader\UrlLoaderInterface $loader ) Set a URL loader to be used by the parser.

Méthodes protégées

Méthode Description
addCommentToQueueOrLdif ( Ldif $ldif ) Determine whether the comment should be added to the LDIF itself, or if it's a comment for an entry within the LDIF. If it's for an entry in the LDIF, then we make the assumption that we an empty line separates comments between the LDIF comments overall and the start of a comment for an entry. This seems like the most reasonable way to do it, though it still may not be perfect.
addDirectiveToEntry ( string $key, string $value, LdapTools\Ldif\Entry\LdifEntryInterface $entry ) Figures out what to add to the LDIF entry for a specific key/value directive given.
addModDnDirective ( LdifEntryModDn $entry, string $key, string $value )
addModifyDirective ( LdifEntryModify $entry, string $key, string $value )
cleanup ( ) Do a bit of cleanup post parsing.
currentLine ( ) : boolean | string
getBoolFromStringBool ( string $value ) : boolean Convert an expected string "true" or "false" to bool.
getBoolFromStringInt ( string $value ) : boolean Convert an expected string "0" or "1" to bool.
getContinuedValues ( $value ) : string Check for any continued values and concatenate them into one.
getKeyAndValue ( string $line ) : array
getLdapControl ( string $value ) : LdapControl Validate a control directive and get the value for the control and the criticality.
getLdifEntryObject ( string $dn, string $changeType ) : LdapTools\Ldif\Entry\LdifEntryInterface Get the LdifEntry for the changetype.
getValueFromUrl ( string $url ) : string Get the value of the URL data via a UrlLoader.
getValuesForModifyAction ( string $attribute, string $action ) : array
isComment ( ) : boolean Check if the current line is a comment.
isCommonDirective ( ) : boolean Check if the line is a directive common to any change type (ie. changetype or control).
isContinuedValue ( string $line ) : boolean Check if a line is a continuation of a previous value.
isEndOfEntry ( ) : boolean Check if we are at the end of a LDIF entry.
isEndOfLdif ( ) : boolean Check if we are at the end of the LDIF string.
isStartOfEntry ( ) : boolean Checks for the start of a LDIF entry on the current line.
nextLine ( boolean $advance = true ) : string | false
parseCommonDirectives ( $dn ) : LdapTools\Ldif\Entry\LdifEntryInterface Parses directives that are potentially common to all entries and returns the LdifEntry object. Common directives include: changetype, control
parseEntry ( ) : LdapTools\Ldif\Entry\LdifEntryInterface Parse an entry from the DN position until we reach the start of the next entry. Return the entry that was parsed.
setLdifVersion ( Ldif $ldif, integer $version )
setup ( string $ldif )
startsWith ( string $value, null | string $line = null ) : boolean Check if the current line starts with a specific value.
throwException ( string $message ) A simple helper to add additional information to the exception.
validateDirectiveInChange ( string $type, string $directive )

Method Details

__construct() public méthode

public __construct ( )

addCommentToQueueOrLdif() protected méthode

Determine whether the comment should be added to the LDIF itself, or if it's a comment for an entry within the LDIF. If it's for an entry in the LDIF, then we make the assumption that we an empty line separates comments between the LDIF comments overall and the start of a comment for an entry. This seems like the most reasonable way to do it, though it still may not be perfect.
protected addCommentToQueueOrLdif ( Ldif $ldif )
$ldif Ldif

addDirectiveToEntry() protected méthode

Figures out what to add to the LDIF entry for a specific key/value directive given.
protected addDirectiveToEntry ( string $key, string $value, LdapTools\Ldif\Entry\LdifEntryInterface $entry )
$key string
$value string
$entry LdapTools\Ldif\Entry\LdifEntryInterface

addModDnDirective() protected méthode

protected addModDnDirective ( LdifEntryModDn $entry, string $key, string $value )
$entry LdapTools\Ldif\Entry\LdifEntryModDn
$key string
$value string

addModifyDirective() protected méthode

protected addModifyDirective ( LdifEntryModify $entry, string $key, string $value )
$entry LdapTools\Ldif\Entry\LdifEntryModify
$key string
$value string

cleanup() protected méthode

Do a bit of cleanup post parsing.
protected cleanup ( )

currentLine() protected méthode

protected currentLine ( ) : boolean | string
Résultat boolean | string

getBoolFromStringBool() protected méthode

Convert an expected string "true" or "false" to bool.
protected getBoolFromStringBool ( string $value ) : boolean
$value string
Résultat boolean

getBoolFromStringInt() protected méthode

Convert an expected string "0" or "1" to bool.
protected getBoolFromStringInt ( string $value ) : boolean
$value string
Résultat boolean

getContinuedValues() protected méthode

Check for any continued values and concatenate them into one.
protected getContinuedValues ( $value ) : string
$value
Résultat string

getKeyAndValue() protected méthode

protected getKeyAndValue ( string $line ) : array
$line string
Résultat array

getLdapControl() protected méthode

Validate a control directive and get the value for the control and the criticality.
protected getLdapControl ( string $value ) : LdapControl
$value string
Résultat LdapTools\Connection\LdapControl

getLdifEntryObject() protected méthode

Get the LdifEntry for the changetype.
protected getLdifEntryObject ( string $dn, string $changeType ) : LdapTools\Ldif\Entry\LdifEntryInterface
$dn string
$changeType string
Résultat LdapTools\Ldif\Entry\LdifEntryInterface

getValueFromUrl() protected méthode

Get the value of the URL data via a UrlLoader.
protected getValueFromUrl ( string $url ) : string
$url string
Résultat string

getValuesForModifyAction() protected méthode

protected getValuesForModifyAction ( string $attribute, string $action ) : array
$attribute string
$action string
Résultat array

hasUrlLoader() public méthode

Check if a URL loader for a specific URL type exists.
public hasUrlLoader ( string $type ) : boolean
$type string
Résultat boolean

isComment() protected méthode

Check if the current line is a comment.
protected isComment ( ) : boolean
Résultat boolean

isCommonDirective() protected méthode

Check if the line is a directive common to any change type (ie. changetype or control).
protected isCommonDirective ( ) : boolean
Résultat boolean

isContinuedValue() protected méthode

Check if a line is a continuation of a previous value.
protected isContinuedValue ( string $line ) : boolean
$line string
Résultat boolean

isEndOfEntry() protected méthode

Check if we are at the end of a LDIF entry.
protected isEndOfEntry ( ) : boolean
Résultat boolean

isEndOfLdif() protected méthode

Check if we are at the end of the LDIF string.
protected isEndOfLdif ( ) : boolean
Résultat boolean

isStartOfEntry() protected méthode

Checks for the start of a LDIF entry on the current line.
protected isStartOfEntry ( ) : boolean
Résultat boolean

nextLine() protected méthode

protected nextLine ( boolean $advance = true ) : string | false
$advance boolean Whether to advance the currently active line ahead or not.
Résultat string | false

parse() public méthode

Parses a string containing LDIF data and returns an object with the entries it contains.
public parse ( string $ldif ) : Ldif
$ldif string
Résultat Ldif

parseCommonDirectives() protected méthode

Parses directives that are potentially common to all entries and returns the LdifEntry object. Common directives include: changetype, control
protected parseCommonDirectives ( $dn ) : LdapTools\Ldif\Entry\LdifEntryInterface
$dn
Résultat LdapTools\Ldif\Entry\LdifEntryInterface

parseEntry() protected méthode

Parse an entry from the DN position until we reach the start of the next entry. Return the entry that was parsed.
protected parseEntry ( ) : LdapTools\Ldif\Entry\LdifEntryInterface
Résultat LdapTools\Ldif\Entry\LdifEntryInterface

removeUrlLoader() public méthode

Remove a URL loader by its string type.
public removeUrlLoader ( string $type )
$type string

setLdifVersion() protected méthode

protected setLdifVersion ( Ldif $ldif, integer $version )
$ldif Ldif
$version integer

setUrlLoader() public méthode

Set a URL loader to be used by the parser.
public setUrlLoader ( string $type, LdapTools\Ldif\UrlLoader\UrlLoaderInterface $loader )
$type string The URL type (ie. file, http, etc)
$loader LdapTools\Ldif\UrlLoader\UrlLoaderInterface

setup() protected méthode

protected setup ( string $ldif )
$ldif string

startsWith() protected méthode

Check if the current line starts with a specific value.
protected startsWith ( string $value, null | string $line = null ) : boolean
$value string
$line null | string
Résultat boolean

throwException() protected méthode

A simple helper to add additional information to the exception.
protected throwException ( string $message )
$message string

validateDirectiveInChange() protected méthode

protected validateDirectiveInChange ( string $type, string $directive )
$type string The changetype.
$directive string The directive used.

Property Details

$changeTypeMap protected_oe property

A simple changetype to full class name mapping.
protected $changeTypeMap

$commentQueue protected_oe property

Any comments pending for the next entry in the LDIF.
protected $commentQueue

$line protected_oe property

The current line number we are on during parsing.
protected $line

$lines protected_oe property

protected string[] $lines
Résultat string[]

$urlLoaders protected_oe property

An array of UrlLoaders with the key set to the type of URL they handle.
protected UrlLoaderInterface[],LdapTools\Ldif\UrlLoader $urlLoaders
Résultat LdapTools\Ldif\UrlLoader\UrlLoaderInterface[]