Creates a new default content to be pushed in layout columns.

@param  string               $classname
@param  boolean              $mainzone

@return AbstractClassContent
519212
private function createNewDefaultContent($classname, $mainzone = false)
    {
        $content = new $classname();
        if (null !== $content->getProperty('labelized-by')) {
            try {
                $label = $content;
                foreach (explode('->', (string) $label->getProperty('labelized-by')) as $property) {
                    if (is_object($label->$property)) {
                        $label = $label->$property;
                    } else {
                        break;
                    }
                }

                $label->$property = $this->getTitle();
            } catch (\Exception $e) {
            }
        }

        if (true === $mainzone) {
            $content->setMainNode($this);
        }

        return $content;
    }
625726
public static function create( $className = null )
    {
        if ( is_null( $className ) )
        {
            $ini = eZINI::instance( 'ezcomments.ini' );
            $className = $ini->variable( 'NotificationSettings', 'NotificationManagerClass' );
        }
        return  new $className();
    }
246958
public function create($className)
    {
        $builder = new Builder($className, $this);
        $this->getGuesser()->fill($builder);
        return $builder;
    }
292262
public function replaceOptContentTable(AbstractClassContent $content)
    {
        if (null === $content->getMainNode()) {
            return $this;
        }

        $command = 'REPLACE';
        if (!$this->replaceSupported) {
            // REPLACE command not supported, remove first then insert
            $this->removeOptContentTable($content);
            $command = 'INSERT';
        }

        $meta = $this->_em->getClassMetadata('BackBee\ClassContent\Indexes\OptContentByModified');
        $query = $command.' INTO '.$meta->getTableName().
                ' ('.$meta->getColumnName('_uid').', '.
                $meta->getColumnName('_label').', '.
                $meta->getColumnName('_classname').', '.
                $meta->getColumnName('_node_uid').', '.
                $meta->getColumnName('_modified').', '.
                $meta->getColumnName('_created').')'.
                ' VALUES (:uid, :label, :classname, :node_uid, :modified, :created)';

        $params = array(
            'uid' => $content->getUid(),
            'label' => $content->getLabel(),
            'classname' => AbstractClassContent::getShortClassname($content),
            'node_uid' => $content->getMainNode()->getUid(),
            'modified' => date('Y-m-d H:i:s', $content->getModified()->getTimestamp()),
            'created' => date('Y-m-d H:i:s', $content->getCreated()->getTimestamp()),
        );

        $types = array(
            \Doctrine\DBAL\Connection::PARAM_STR_ARRAY,
            \Doctrine\DBAL\Connection::PARAM_STR_ARRAY,
            \Doctrine\DBAL\Connection::PARAM_STR_ARRAY,
            \Doctrine\DBAL\Connection::PARAM_STR_ARRAY,
            \Doctrine\DBAL\Connection::PARAM_STR_ARRAY,
            \Doctrine\DBAL\Connection::PARAM_STR_ARRAY,
        );

        return $this->executeUpdate($query, $params, $types);
    }
401922
public static function prepareDefault($name)
    {
        $default = static::defaultContent($name);
        if (empty($default)) {
            return false;
        }

        $content = new static;
        $content->topic = $default['topic'];
        $content->content = $default['content'];
        return $content;
    }
883464
public function setLayout(Layout $layout, AbstractClassContent $toPushInMainZone = null)
    {
        $this->_layout = $layout;

        $count = count((array) $layout->getZones());
        // Add as much ContentSet to the page main ContentSet than defined zones in layout
        for ($i = $this->getContentSet()->count(); $i < $count; $i++) {
            // Do this case really exists ?
            if (null === $zone = $layout->getZone($i)) {
                $this->getContentSet()->push(new ContentSet());
                continue;
            }

            // Create a new column
            $contentset = new ContentSet(null, $zone->options);

            if (null !== $toPushInMainZone && true === $zone->mainZone) {
                // Existing content push in the main zone
                $contentset->push($toPushInMainZone->setMainNode($this));
            } elseif ('inherited' === $zone->defaultClassContent) {
                // Inherited zone => same ContentSet than parent if exist
                $contentset = $this->getInheritedContent($i, $contentset);
            } elseif ($zone->defaultClassContent) {
                // New default content push
                $contentset->push($this->createNewDefaultContent(
                    'BackBee\ClassContent\\'.$zone->defaultClassContent,
                    $zone->mainZone
                ));
            }

            $this->getContentSet()->push($contentset);
        }

        return $this;
    }
799937
public function toggleClass($classname)
    {
        $classes = explode(' ', $classname);
        foreach ($this as $i => $node) {
            $c = self::create($node);
            /** @var \DOMNode $node */
            foreach ($classes as $class) {
                if ($c->hasClass($class)) {
                    $c->removeClass($class);
                } else {
                    $c->addClass($class);
                }
            }
        }
        return $this;
    }
987091
public function setDefaultRepositoryClassName($className)
    {
        $reflectionClass = new \ReflectionClass($className);

        if (!$reflectionClass->implementsInterface(ObjectRepository::class)) {
            throw PHPCRException::invalidDocumentRepository($className);
        }

        $this->attributes['defaultRepositoryClassName'] = $className;
    }
851992
private function commitPostProcess(AbstractClassContent $content, Revision $draft)
    {
        $data = $draft->jsonSerialize();
        if (0 !== count($data['parameters']) && 0 !== count($data['elements'])) {
            $draft->setRevision($content->getRevision());
            $draft->setState(Revision::STATE_MODIFIED);
            $this->entityManager->persist($draft);
        }

        return $this;
    }
133426
public function insertContentObject(CreateStruct $struct, $currentVersionNo = 1)
    {
        $initialLanguageId = !empty($struct->mainLanguageId) ? $struct->mainLanguageId : $struct->initialLanguageId;
        $initialLanguageCode = $this->languageHandler->load($initialLanguageId)->languageCode;

        if (isset($struct->name[$initialLanguageCode])) {
            $name = $struct->name[$initialLanguageCode];
        } else {
            $name = '';
        }

        $q = $this->dbHandler->createInsertQuery();
        $q->insertInto(
            $this->dbHandler->quoteTable('ezcontentobject')
        )->set(
            $this->dbHandler->quoteColumn('id'),
            $this->dbHandler->getAutoIncrementValue('ezcontentobject', 'id')
        )->set(
            $this->dbHandler->quoteColumn('current_version'),
            $q->bindValue($currentVersionNo, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('name'),
            $q->bindValue($name, null, \PDO::PARAM_STR)
        )->set(
            $this->dbHandler->quoteColumn('contentclass_id'),
            $q->bindValue($struct->typeId, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('section_id'),
            $q->bindValue($struct->sectionId, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('owner_id'),
            $q->bindValue($struct->ownerId, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('initial_language_id'),
            $q->bindValue($initialLanguageId, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('remote_id'),
            $q->bindValue($struct->remoteId, null, \PDO::PARAM_STR)
        )->set(
            $this->dbHandler->quoteColumn('modified'),
            $q->bindValue(0, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('published'),
            $q->bindValue(0, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('status'),
            $q->bindValue(ContentInfo::STATUS_DRAFT, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('language_mask'),
            $q->bindValue(
                $this->generateLanguageMask(
                    $struct->fields,
                    $initialLanguageCode,
                    $struct->alwaysAvailable
                ),
                null,
                \PDO::PARAM_INT
            )
        );

        $q->prepare()->execute();

        return $this->dbHandler->lastInsertId(
            $this->dbHandler->getSequenceName('ezcontentobject', 'id')
        );
    }
1119212
public function setDefaultRepositoryClassName($className): void
    {
        $reflectionClass = new \ReflectionClass($className);

        if (! $reflectionClass->implementsInterface(DocumentRepositoryInterface::class)) {
            throw new InvalidDocumentRepositoryException($className);
        }

        $this->defaultRepositoryClassName = $className;
    }
115346
public static function create($classname, $args = null, $filter = null, $override = null) {
		//obtain provider list for this class
		$profile = Profiler::getClassProfile($classname);
		$providers = $profile->providers;
		
		if (empty($providers)) {
			throw new \RuntimeException("Class $classname does not have any provider associated with it");
		}

		//create new container and register all providers
		$container = new Container();
		
		foreach ($providers as $provider) {
			$providerInstance = self::getProvider($provider);
			$providerInstance->register($container);
		}

		return self::createWith($classname, $container, $args, $filter, $override);
	}
508724
public final function addClass(
        string $className,
        string $classPath): LoaderInterface
    {
        $this->classMap->addClass($className, $classPath);
        return $this;
    }
423580
public static function createPluginObject($className, $name, $alias, $i18n, $args = [])
    {
        return Yii::createObject(array_merge([
            'class' => $className,
            'name' => $name,
            'alias' => $alias,
            'i18n' => $i18n,
        ], $args));
    }
1212273
public static SourceLineAnnotation createUnknown(@DottedClassName String className) {
        return createUnknown(className, AnalysisContext.currentAnalysisContext().lookupSourceFile(className), -1, -1);
    }
307777
public function createByClassName(string $nameOrFullClassName): MetaEntityInterface
    {
        /** @var MetaEntityInterface $metaEntity */
        $metaEntity = new $this->metaEntityClass($nameOrFullClassName);
        $metaEntity->setUseCustomRepository($this->useCustomRepository);
        $ormTableAnnotation = $this->metaAnnotationFactory->createMetaAnnotation(
            $metaEntity,
            ['Doctrine\ORM\Mapping' => 'ORM'],
            'ORM\Table',
            ['name' => $metaEntity->getTableName()]
        ) ;
        $ormEntityAnnotation = $this->metaAnnotationFactory->createMetaAnnotation(
            $metaEntity,
            ['Doctrine\ORM\Mapping' => 'ORM'],
            'ORM\Entity'
        ) ;
        if ($metaEntity->hasCustomRepository()) {
            $ormEntityAnnotation->addAnnotationAttribute('repositoryClass', $metaEntity->getRepositoryFullClassName());
        }
        return $metaEntity
            ->addEntityAnnotation($ormTableAnnotation)
            ->addEntityAnnotation($ormEntityAnnotation)
        ;
    }
453604
public function generate(Page $page, AbstractClassContent $content = null, $force = false, $exceptionOnMissingScheme = true)
    {
        if (!is_bool($force)) {
            throw new \InvalidArgumentException(sprintf(
                '%s method expect `force parameter` to be type of boolean, %s given',
                __METHOD__,
                gettype($force)
            ));
        }

        if (
            null !== $page->getUrl(false)
            && $page->getState() & Page::STATE_ONLINE
            && (!$force && $this->preserveOnline)
        ) {
            return $page->getUrl(false);
        }

        if ($page->isRoot() && array_key_exists('_root_', $this->schemes)) {
            return $this->doGenerate($this->schemes['_root_'], $page, $content);
        }

        if (isset($this->schemes['_layout_']) && is_array($this->schemes['_layout_'])) {
            if (array_key_exists($page->getLayout()->getUid(), $this->schemes['_layout_'])) {
                return $this->doGenerate($this->schemes['_layout_'][$page->getLayout()->getUid()], $page);
            }
        }

        if (null !== $content && array_key_exists('_content_', $this->schemes)) {
            $shortClassname = str_replace(AbstractContent::CLASSCONTENT_BASE_NAMESPACE, '', get_class($content));
            if (array_key_exists($shortClassname, $this->schemes['_content_'])) {
                return $this->doGenerate($this->schemes['_content_'][$shortClassname], $page, $content);
            }
        }

        if (array_key_exists('_default_', $this->schemes)) {
            return $this->doGenerate($this->schemes['_default_'], $page, $content);
        }

        $url = $page->getUrl(false);
        if (!empty($url)) {
            return $url;
        }

        if (true === $exceptionOnMissingScheme) {
            throw new RewritingException(
                sprintf('No rewriting scheme found for Page (#%s)', $page->getUid()),
                RewritingException::MISSING_SCHEME
            );
        }

        return '/'.$page->getUid();
    }