LdapTools\Object\LdapObjectCreator::create PHP Метод

create() публичный Метод

Specify the object type to create. Either by its string name type from the schema of the LdapObjectSchema.
public create ( string | LdapObjectSchema $type )
$type string | LdapTools\Schema\LdapObjectSchema
    public function create($type)
    {
        if (!is_string($type) && !$type instanceof LdapObjectSchema) {
            throw new InvalidArgumentException('You must either pass the schema object type as a string to this method, or pass the schema types ' . 'LdapObjectSchema to this method.');
        }
        if (!$type instanceof LdapObjectSchema) {
            $type = $this->schemaFactory->get($this->connection->getConfig()->getSchemaName(), $type);
        }
        $this->schema = $type;
        $this->container = $type->getDefaultContainer();
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * Get a LdapObjectCreator object.
  *
  * @param string|null $type
  * @return LdapObjectCreator
  */
 public function createLdapObject($type = null)
 {
     $creator = new LdapObjectCreator($this->getConnection(), $this->getSchemaFactory(), $this->config->getEventDispatcher());
     if ($type) {
         $creator->create($type);
     }
     return $creator;
 }