make

@param array                     $database
@param PropertyContainerContract $propertyContainer

@return static
@throws SchemaException
427708
public static function make(
        $database,
        $propertyContainer
    ) {
        $instance = new self();
        $instance->setDatabase(
            Database::make(
                $database,
                $propertyContainer
            )
        );

        return $instance;
    }
1245944
public function buildBundleSchemaWithProperties(
        BundleSchemaInterface $sourceBundleSchema,
        array $propertyCollection
    ): BundleSchemaInterface {
        $schemaData = [];
        foreach ($propertyCollection as $property) {
            $schemaData[] = $property->toArray();
        }

        $schema = $this->readerFactory->createSchema()
            ->setName($sourceBundleSchema->getSchema()->getName())
            ->setSchema($schemaData);

        $bundleSchema = $this->bundleSchemaFactory->createBundleSchema(
            $schema,
            $sourceBundleSchema->getSchemaFilename()
        );

        return $bundleSchema;
    }
130259
static public function makeObjectsArray( $array , $with_contentobject = true, array $propertiesOverride = null, $lang = null )
    {
        $retNodes = array();
        if ( !is_array( $array ) )
            return $retNodes;

        foreach ( $array as $node )
        {
            if ( $propertiesOverride !== null )
            {
                $node = $propertiesOverride + $node;
            }

            if ( $node['node_id'] == 1 && (!array_key_exists( 'name', $node ) || !$node['name'] ) )
            {
                $node['name'] = ezpI18n::tr( 'kernel/content', 'Top Level Nodes' );
            }

            $object = new eZContentObjectTreeNode(
                array(
                    "node_id" => $node["node_id"],
                    "parent_node_id" => $node["parent_node_id"],
                    "main_node_id" => $node["main_node_id"],
                    "contentobject_id" => isset( $node["id"] ) ? $node["id"] : $node["contentobject_id"],
                    "contentobject_version" => $node["contentobject_version"],
                    "contentobject_is_published" => $node["contentobject_is_published"],
                    "depth" => $node["depth"],
                    "sort_field" => $node["sort_field"],
                    "sort_order" => $node["sort_order"],
                    "priority" => $node["priority"],
                    "modified_subnode" => $node["modified_subnode"],
                    "path_string" => $node["path_string"],
                    "path_identification_string" => $node["path_identification_string"],
                    "remote_id" => $node["remote_id"],
                    "is_hidden" => $node["is_hidden"],
                    "is_invisible" => $node["is_invisible"],
                )
            );
            // If the name is not set it will be fetched later on when
            // getName()/attribute( 'name' ) is accessed.
            if ( isset( $node['name'] ) )
            {
                $object->setName( $node['name'] );
            }

            if ( isset( $node['class_serialized_name_list'] ) )
            {
                $node['class_name'] = eZContentClass::nameFromSerializedString( $node['class_serialized_name_list'] );
                $object->ClassName = $node['class_name'];
            }
            if ( isset( $node['class_identifier'] ) )
                $object->ClassIdentifier = $node['class_identifier'];

            if ( isset( $node['is_container'] ) )
                $object->ClassIsContainer = $node['is_container'];

            if ( $with_contentobject )
            {
                if ( isset( $node['class_name'] ) )
                {
                    $row = array(
                        "id" => $node["id"],
                        "section_id" => $node["section_id"],
                        "owner_id" => $node["owner_id"],
                        "contentclass_id" => $node["contentclass_id"],
                        "name" => $node["name"],
                        "published" => $node["published"],
                        "modified" => $node["modified"],
                        "current_version" => $node["current_version"],
                        "status" => $node["status"],
                        "remote_id" => $node["object_remote_id"],
                        "language_mask" => $node["language_mask"],
                        "initial_language_id" => $node["initial_language_id"],
                        "class_name" => $node["class_name"],
                    );

                    if ( isset( $node['class_identifier'] ) )
                        $row['class_identifier'] = $node['class_identifier'];

                    $contentObject = new eZContentObject( $row );
                }
                else
                {
                    $contentObject = new eZContentObject( array() );
                    if ( isset( $node['name'] ) )
                         $contentObject->setCachedName( $node['name'] );
                }
                if ( isset( $node['real_translation'] ) && $node['real_translation'] != '' )
                {
                    if ( $node['real_translation'] == $lang )
                    {
                        $object->CurrentLanguage = $node['real_translation'];
                    }

                    $contentObject->CurrentLanguage = $node['real_translation'];
                }
                if ( $node['node_id'] == 1 )
                {
                    $contentObject->ClassName = 'Folder';
                    $contentObject->ClassIdentifier = 'folder';
                    $contentObject->ClassID = 1;
                    $contentObject->SectionID = 1;
                }

                $object->setContentObject( $contentObject );
            }
            $retNodes[] = $object;
        }
        return $retNodes;
    }
152489
protected function map(
        $propertyName,
        $columnName = null,
        \Closure $fromArrayCallback = null,
        \Closure $toArrayCallback = null
    ) {
        if (!$columnName) {
            $columnName = $propertyName;
        }

        if ($columnName instanceof \Closure) {
            $fromArrayCallback = $columnName;
            $columnName        = null;
        }

        if ($columnName) {
            $this->columnsToProperties[$columnName] = $propertyName;
            $this->columns[]                        = $columnName;
        }
        $this->properties[] = $propertyName;

        if ($fromArrayCallback) {
            $this->propertiesFromArrayCallbacks[$propertyName] = $fromArrayCallback;
        }

        if ($toArrayCallback) {
            $this->propertiesToArrayCallbacks[$propertyName] = $toArrayCallback;
        }

        return $this;
    }
1289645
public static function buildContainer(array $definitions)
    {
        /** @var ContainerBuilder $builder */
        $builder = new static();
        $container = Container::getContainer();
        $manager = $builder->_createManager($definitions);
        if (!$container) {
            $container = new Container($manager);
        } else {
            $builder->_merge($container->getDefinitionManager(), $manager);
        }
        return $container;
    }
150601
public function setProperties(array $properties)
    {
        foreach ($properties as $property => $value) {
            $method = sprintf('set%s', str_replace('_', '', $property));

            if (!method_exists($this, $method)) {
                 throw SchemaException::invalidColumnProperty($this->getName(), $property);
            }

            $this->$method($value);
        }
    }
1126979
protected function buildCollectionPluginCollection(
        PluginContainerInterface $pluginContainer,
        PropertyExplorerInterface $propertyExplorer
    ): array {
        $propertyPlugins = $this
            ->createCollectionFactoryPlugin($propertyExplorer)
            ->createPluginCollection();

        return \array_merge($propertyPlugins, $pluginContainer->getCollectionPlugins());
    }
409160
public function setRestrictions($dataContainerName = null, $propertyName = null)
    {
        parent::setRestrictions($dataContainerName);
        $this->propertyName = $propertyName;
    }
325766
public function make($object)
    {
        $manager = Manager::getInstance();

        // Instantiate hydrator
        // TODO: We'll need to optimize this and allow pre-generation
        //       of these hydrators, and get it, ideally, from the entityMap or
        //       the Mapper class, so it's only instantiated once
        $config = new Configuration(get_class($object));

        $hydratorClass = $config->createFactory()->getHydratorClass();
        $hydrator = new $hydratorClass();

        if ($manager->isValueObject($object)) {
            $entityMap = $manager->getValueMap($object);
        } else {
            $entityMap = $manager->mapper($object)->getEntityMap();
        }

        // Build Wrapper
        return new ObjectWrapper($object, $entityMap, $hydrator);
    }
1216330
public function create($contentOrName, $type = null, array $data = [])
    {
        // Check if container or name is defined
        if (!(
            $contentOrName instanceof Model\ContentInterface ||
            (is_string($contentOrName) && 0 < strlen($contentOrName))
        )
        ) {
            throw new InvalidOperationException("Excepted instance of ContentInterface or string.");
        }

        // Default type if null
        if (null === $type) {
            $type = $this->defaultType;
        }

        // New instance
        $container = $this->editor->getRepository()->createContainer();
        $container->setType($type);

        // Plugin creation
        $plugin = $this->editor->getContainerPlugin($type);
        $plugin->create($container, $data);

        // Create default row
        if (!$plugin instanceof CopyPlugin) {
            $this->editor->getRowManager()->create($container);
        }

        // Add to container if available
        if ($contentOrName instanceof Model\ContentInterface) {
            $count = $contentOrName->getContainers()->count();
            $container->setPosition($count);
            $contentOrName->addContainer($container);
        } else {
            $container->setName($contentOrName);
        }

        return $container;
    }
662596
protected function createScopesTable(Connection $connection, DatabaseSchemaInterface $schema): void
    {
        $manager = $connection->getSchemaManager();

        $table = new Table($schema->getScopesTable());
        $table->addColumn($schema->getScopesIdentityColumn(), Type::STRING)->setNotnull(true);
        $table->addColumn($schema->getScopesDescriptionColumn(), Type::STRING)->setNotnull(false);
        $table->addColumn($schema->getScopesCreatedAtColumn(), Type::DATETIME)->setNotnull(true);
        $table->addColumn($schema->getScopesUpdatedAtColumn(), Type::DATETIME)->setNotnull(false);
        $table->setPrimaryKey([$schema->getScopesIdentityColumn()]);

        $manager->dropAndCreateTable($table);
    }
470202
public static function create($type = null, array $config = []) {

	    if(!$type) {

	        if(!isset($config['dsn'])) {
	            throw new \Exception('No database type defined.');
            }

            if(preg_match('/^([a-z0-9]+):/i', trim($config['dsn']), $matches)) {
                $type = $matches[1];
            }
            else {
                throw new \Exception('No driver found in DSN.');
            }

        }

		$type = strtolower($type);

		if($type === 'propel') {

			// check whether Propel is available (assume Propel2)

            if(!class_exists('\\Propel\\Runtime\\Propel')) {
                throw new \Exception('Propel is configured as driver for vxPDO but not available in this application.');
            }

            $serviceContainer = \Propel\Runtime\Propel::getServiceContainer();

            // retrieve adapter information

            $adapterName = $serviceContainer->getAdapterClass();
            $dsnName = $serviceContainer->getDefaultDatasource();

            /* @var $connection \Propel\Runtime\Connection\ConnectionInterface */

            $connection = \Propel\Runtime\Propel::getConnection();

            if(!in_array($adapterName, ['mysql', 'pgsql'])) {

                throw new \Exception(sprintf("vxPDO accepts only mysql and pgsql as established connection drivers. The configured Propel connection '%s' uses '%s'.", $dsnName, $adapterName));

			}

			// @todo fugly like hell - perhaps some more concise solution exists

            preg_match('/dbname=([^;]+)/i', \Propel\Runtime\Propel::getConnectionManager($dsnName)->getConfiguration()['dsn'], $matches);
            $dbName = $matches[1] ?? '';

            $pdoConnection = new Propel2ConnectionWrapper($connection);
            $pdoConnection->setName($dsnName);
            $pdoConnection->setDbName($dbName);

            $className =
                __NAMESPACE__ .
                '\\Adapter\\' .
                ucfirst($adapterName);

            /* @var $vxPDO DatabaseInterface */

            $vxPDO = new $className();
            $vxPDO->setConnection($pdoConnection);

            return $vxPDO;

		}

		else {

			$className =
				__NAMESPACE__ .
				'\\Adapter\\' .
				ucfirst($type);
	
			// check whether driver is available
				
			if(!class_exists($className)) {
	
				throw new ConfigException(sprintf("No class for driver '%s' supported.", $type));
	
			}
				
			return new $className($config);

		}

	}
1222923
public static function create(array $properties): SkeletonEmbeddableInterface
    {
        if (array_key_exists(SkeletonEmbeddableInterface::EMBEDDED_PROP_PROPERTY_ONE, $properties)) {
            return new self(
                $properties[SkeletonEmbeddableInterface::EMBEDDED_PROP_PROPERTY_ONE],
                $properties[SkeletonEmbeddableInterface::EMBEDDED_PROP_PROPERTY_TWO]
            );
        }

        return new self(...array_values($properties));
    }
11661
private function make(string $class)
    {
        if (! array_key_exists($class, $this->instances)) {

            try {

                return $this->instances[$class] = ($this->factory)($class)->value($this);

            }

            catch (ResolvingExceptionInterface $e) {

                throw new ReflectionContainerException($class, $e);

            }

        }

        return $this->instances[$class];
    }
985055
public function newFromBuilder($attributes = [], $connection = null)
    {
        $attributes = (array) $attributes;

        if (! empty($attributes['type'])
            && isset(static::$models[$attributes['type']])
            && class_exists($class = static::$models[$attributes['type']])
        ) {
            /** @var Post $instance */
            $instance = new $class;
            $instance->exists = true;
            $instance->setRawAttributes($attributes, true);
            $instance->setConnection($connection ?: $this->connection);

            return $instance;
        }

        return parent::newFromBuilder($attributes, $connection);
    }
866701
public static function create(base $db = null)
    {
        if ($db === null) {
            $db = GnfConnectionProvider::getConnection(PlatformConnectionGroup::PLATFORM_WRITE);
        }

        return new static($db);
    }
1042582
public function compile(CompilationContext $compilationContext)
    {
        $statement = $this->statement;

        $codePrinter = $compilationContext->codePrinter;

        if (isset($statement['expr'])) {
            $currentMethod = $compilationContext->currentMethod;

            if ($currentMethod->isConstructor()) {
                throw new CompilerException('Constructors cannot return values', $statement['expr']);
            }

            if ($currentMethod->isVoid()) {
                throw new CompilerException(
                    "Method is marked as 'void' and it must not return any value",
                    $statement['expr']
                );
            }

            /*
             * Use return member for properties on this
             */
            if ('property-access' == $statement['expr']['type']) {
                if ('variable' == $statement['expr']['left']['type']) {
                    if ('this' == $statement['expr']['left']['value']) {
                        if ('variable' == $statement['expr']['right']['type']) {
                            /*
                             * If the property is accessed on 'this', we check if the property does exist.
                             */
                            $property = $statement['expr']['right']['value'];
                            $classDefinition = $compilationContext->classDefinition;
                            if (!$classDefinition->hasProperty($property)) {
                                throw new CompilerException(
                                    sprintf(
                                        "Class '%s' does not have a property called: '%s'",
                                        $classDefinition->getCompleteName(),
                                        $property
                                    ),
                                    $statement['expr']['right']
                                );
                            }

                            $compilationContext->headersManager->add('kernel/object');
                            $codePrinter->output('RETURN_MM_MEMBER(getThis(), "'.$property.'");');

                            return;
                        }
                    }
                }
            }

            /*
             * Fetches return_value and tries to return the value directly there.
             */
            $variable = $compilationContext->symbolTable->getVariable('return_value');

            $expr = new Expression($statement['expr']);
            $expr->setExpectReturn(true, $variable);
            $expr->setReadOnly(true);
            $resolvedExpr = $expr->compile($compilationContext);

            /*
             * Here we check if the variable returns a compatible type according to its type hints
             */
            if ($currentMethod->hasReturnTypes()) {
                switch ($resolvedExpr->getType()) {
                    case Types::T_NULL:
                        if (false == $currentMethod->areReturnTypesNullCompatible()) {
                            throw new InvalidTypeException($resolvedExpr->getType(), $statement['expr']);
                        }
                        break;

                    case Types::T_INT:
                    case Types::T_UINT:
                    case Types::T_LONG:
                    case Types::T_ULONG:
                    case Types::T_CHAR:
                    case Types::T_UCHAR:
                        if (false == $currentMethod->areReturnTypesIntCompatible()) {
                            throw new InvalidTypeException($resolvedExpr->getType(), $statement['expr']);
                        }
                        break;

                    case Types::T_BOOL:
                        if (false == $currentMethod->areReturnTypesBoolCompatible()) {
                            throw new InvalidTypeException($resolvedExpr->getType(), $statement['expr']);
                        }
                        break;

                    case Types::T_DOUBLE:
                        if (false == $currentMethod->areReturnTypesDoubleCompatible()) {
                            throw new InvalidTypeException($resolvedExpr->getType(), $statement['expr']);
                        }
                        break;

                    case Types::T_STRING:
                    case Types::T_ISTRING:
                        if (false == $currentMethod->areReturnTypesStringCompatible()) {
                            throw new InvalidTypeException($resolvedExpr->getType(), $statement['expr']);
                        }
                        break;

                    case Types::T_VARIABLE:
                        $symbolVariable = $compilationContext->symbolTable->getVariableForRead(
                            $resolvedExpr->getCode(),
                            $compilationContext,
                            $statement['expr']
                        );

                        switch ($symbolVariable->getType()) {
                            case Types::T_INT:
                            case Types::T_UINT:
                            case Types::T_LONG:
                            case Types::T_ULONG:
                            case Types::T_CHAR:
                            case Types::T_UCHAR:
                                if (false == $currentMethod->areReturnTypesIntCompatible()) {
                                    throw new InvalidTypeException($resolvedExpr->getType(), $statement['expr']);
                                }
                                break;

                            case Types::T_DOUBLE:
                                if (false == $currentMethod->areReturnTypesDoubleCompatible()) {
                                    throw new InvalidTypeException($resolvedExpr->getType(), $statement['expr']);
                                }
                                break;

                            case Types::T_STRING:
                            case Types::T_ISTRING:
                                if (false == $currentMethod->areReturnTypesStringCompatible()) {
                                    throw new InvalidTypeException($resolvedExpr->getType(), $statement['expr']);
                                }
                                break;

                            case Types::T_BOOL:
                                if (false == $currentMethod->areReturnTypesBoolCompatible()) {
                                    throw new InvalidTypeException($resolvedExpr->getType(), $statement['expr']);
                                }
                                break;

                            case Types::T_VARIABLE:
                                break;
                        }
                        break;
                }
            }

            switch ($resolvedExpr->getType()) {
                case Types::T_NULL:
                    $codePrinter->output('RETURN_MM_NULL();');
                    break;

                case Types::T_INT:
                case Types::T_UINT:
                case Types::T_LONG:
                case Types::T_ULONG:
                case Types::T_CHAR:
                case Types::T_UCHAR:
                    $codePrinter->output('RETURN_MM_LONG('.$resolvedExpr->getCode().');');
                    break;

                case Types::T_BOOL:
                    $codePrinter->output('RETURN_MM_BOOL('.$resolvedExpr->getBooleanCode().');');
                    break;

                case Types::T_DOUBLE:
                    $codePrinter->output('RETURN_MM_DOUBLE('.$resolvedExpr->getCode().');');
                    break;

                case Types::T_STRING:
                case Types::T_ISTRING:
                    $compilationContext->backend->returnString(
                        add_slashes($resolvedExpr->getCode()),
                        $compilationContext
                    );
                    break;

                case Types::T_ARRAY:
                    if ('return_value' != $resolvedExpr->getCode()) {
                        $codePrinter->output('RETURN_CTOR('.$resolvedExpr->getCode().');');
                    } else {
                        $codePrinter->output('RETURN_MM();');
                    }
                    break;

                case Types::T_VARIABLE:
                    if (!isset($symbolVariable)) {
                        $symbolVariable = $compilationContext->symbolTable->getVariableForRead(
                            $resolvedExpr->getCode(),
                            $compilationContext,
                            $statement['expr']
                        );
                    }

                    switch ($symbolVariable->getType()) {
                        case Types::T_INT:
                        case Types::T_UINT:
                        case Types::T_LONG:
                        case Types::T_ULONG:
                        case Types::T_CHAR:
                        case Types::T_UCHAR:
                            $codePrinter->output('RETURN_MM_LONG('.$symbolVariable->getName().');');
                            break;

                        case Types::T_DOUBLE:
                            $codePrinter->output('RETURN_MM_DOUBLE('.$symbolVariable->getName().');');
                            break;

                        case Types::T_STRING:
                        case Types::T_ISTRING:
                        case Types::T_ARRAY:
                            $codePrinter->output(
                                'RETURN_CTOR('.$compilationContext->backend->getVariableCode($symbolVariable).');'
                            );
                            break;

                        case Types::T_BOOL:
                            $codePrinter->output('RETURN_MM_BOOL('.$symbolVariable->getName().');');
                            break;

                        case Types::T_VARIABLE:
                            if ('this_ptr' == $symbolVariable->getName()) {
                                $codePrinter->output('RETURN_THIS();');
                            } else {
                                if ('return_value' != $symbolVariable->getName()) {
                                    if (!$symbolVariable->isExternal()) {
                                        if ($symbolVariable->isLocalOnly()) {
                                            $codePrinter->output(
                                                sprintf(
                                                    'RETURN_LCTOR(%s);',
                                                    $compilationContext->backend->getVariableCode($symbolVariable)
                                                )
                                            );
                                        } else {
                                            if (!$symbolVariable->isMemoryTracked()) {
                                                $codePrinter->output(
                                                    sprintf(
                                                        'RETURN_CTOR(%s);',
                                                        $compilationContext->backend->getVariableCode($symbolVariable)
                                                    )
                                                );
                                            } else {
                                                $codePrinter->output(
                                                    sprintf(
                                                        'RETURN_CCTOR(%s);',
                                                        $compilationContext->backend->getVariableCode($symbolVariable)
                                                    )
                                                );
                                            }
                                        }
                                    } else {
                                        $codePrinter->output(
                                            sprintf(
                                                'RETVAL_ZVAL(%s, 1, 0);',
                                                $compilationContext->backend->getVariableCode($symbolVariable)
                                            )
                                        );
                                        $codePrinter->output('RETURN_MM();');
                                    }
                                } else {
                                    $codePrinter->output('RETURN_MM();');
                                }
                            }
                            if ($symbolVariable->isTemporal()) {
                                $symbolVariable->setIdle(true);
                            }
                            break;

                        default:
                            throw new CompilerException(
                                sprintf("Cannot return variable '%s'", $symbolVariable->getType()),
                                $statement['expr']
                            );
                    }
                    break;

                default:
                    throw new CompilerException("Cannot return '".$resolvedExpr->getType()."'", $statement['expr']);
            }

            return;
        }

        /*
         * Return without an expression
         */
        $codePrinter->output('RETURN_MM_NULL();');
    }