Import a Path into the Platform.

@param string $structure
@param array  $data
@param array  $resourcesCreated

@return Path
518672
public function import($structure, array $data, array $resourcesCreated = [])
    {
        // Create a new Path object which will be populated with exported data
        $path = new Path();

        $pathData = $data['data']['path'];

        // Populate Path properties
        $path->setDescription($pathData['description']);
        $path->setOpenSummary($pathData['summaryDisplayed']);
        $path->setManualProgressionAllowed($pathData['manualProgressionAllowed']);

        // Create steps
        $stepData = $data['data']['steps'];
        if (!empty($stepData)) {
            $createdSteps = [];
            foreach ($stepData as $step) {
                $createdSteps = $this->importStep($path, $step, $resourcesCreated, $createdSteps);
            }
        }

        // Inject empty structure into path (will be replaced by a version with updated IDs later in the import process)
        $path->setStructure($structure);

        return $path;
    }
240476
public function populateNodes($structure)
    {
        try {
            $this->output = json_encode($structure);
        } catch (\Exception $e) {
            throw new \Genesis\Exceptions\InvalidArgument('Invalid data/tree');
        }
    }
1041866
protected static function addStructure(array $structure, vfsStreamDirectory $baseDir)
    {
        foreach ($structure as $name => $data) {
            $name = (string) $name;
            if (is_array($data) === true) {
                self::addStructure($data, self::newDirectory($name)->at($baseDir));
            } elseif (is_string($data) === true) {
                self::newFile($name)->withContent($data)->at($baseDir);
            }
        }

        return $baseDir;
    }
1067400
public function createTranslatedProperty($property, $locale, StructureInterface $structure = null)
    {
        if ($property instanceof ItemMetadata) {
            $property = $this->createProperty($property, $structure);
        }
        $property = new TranslatedProperty(
            $property,
            $locale,
            $this->namespaceRegistry->getPrefix('content_localized')
        );

        return $property;
    }
1322492
public function importWebsite(array $data, $rootPath, array $resourcesCreated = [], $test = false)
    {
        $website = new Website($test);
        if (isset($data['data'])) {
            $websiteData = $data['data'];
            $websiteOptions = new WebsiteOptions();
            $websiteOptions->setWebsite($website);
            $website->setOptions($websiteOptions);

            $websitePagesMap = [];
            foreach ($websiteData['pages'] as $websitePage) {
                $entityWebsitePage = new WebsitePage();
                $entityWebsitePage->setWebsite($website);

                //resource link case, need no map manifest IDs to matching resource
                if (WebsitePageTypeEnum::RESOURCE_PAGE === $websitePage['type']) {
                    $resource_node = null;
                    //full workspace import, external resource ID, search matching resource amongst other imported resources
                    if (isset($resourcesCreated) && isset($websitePage['resource_node_id']) && isset($resourcesCreated[$websitePage['resource_node_id']])) {
                        //resource_node_id is the UID of the resource
                        if (isset($resourcesCreated[$websitePage['resource_node_id']])) {
                            $resource_node = $resourcesCreated[$websitePage['resource_node_id']]->getResourceNode();
                        }
                        //standalone website import, ID references existing entity
                    } elseif (isset($websitePage['resource_node_id'])) {
                        $resource_node = $this->om->getRepository('ClarolineCoreBundle:Resource\ResourceNode')
                            ->findOneBy(['id' => $websitePage['resource_node_id']]);
                    }
                    if (null !== $resource_node) {
                        $websitePage['resource_node'] = $resource_node;
                    }
                }

                $entityWebsitePage->importFromArray($websitePage, $rootPath);
                if ($websitePage['is_root']) {
                    $website->setRoot($entityWebsitePage);
                    $this->om->persist($website);
                } else {
                    $entityWebsitePageParent = $websitePagesMap[$websitePage['parent_id']];
                    $entityWebsitePage->setParent($entityWebsitePageParent);
                    $this->websitePageRepository->persistAsLastChildOf($entityWebsitePage, $entityWebsitePageParent);
                }
                if ($websitePage['is_homepage']) {
                    $website->setHomePage($entityWebsitePage);
                }

                $websitePagesMap[$websitePage['id']] = $entityWebsitePage;
            }
            //flush, otherwise we dont have the website ID needed for building uploadPath for banner
            $this->om->forceFlush();

            $website->getOptions()->importFromArray(
                $this->webDir,
                $websiteData['options'],
                $rootPath
            );
        }

        return $website;
    }
258310
private function getProxies($contentData, StructureInterface $structure)
    {
        $contentData = $contentData ?: '{}';
        $data = json_decode($contentData, true);

        $content = $this->contentProxyFactory->createContentProxy($structure, $data);
        $view = $this->contentProxyFactory->createViewProxy($structure, $data);

        return [$content, $view];
    }
631835
protected function createResourcesSection(array $resources = array())
    {
        $builder = new TreeBuilder();
        $node = $builder->root('resources');
        $node->addDefaultsIfNotSet();
        $resourceNodes = $node->children();

        foreach ($resources as $resource => $defaults) {
            $resourceNode = $resourceNodes
                ->arrayNode($resource)
                ->addDefaultsIfNotSet()
            ;

            $this->addClassesSection($resourceNode, $defaults['classes']);

            if (isset($defaults['options'])) {
                $this->createOptionsNode($resourceNode, $defaults['options']);
            }

            if (!isset($defaults['validation_groups'])) {
                $defaults['validation_groups'] = array(
                    'default' => array()
                );
            }

            $this->addValidationGroupsSection($resourceNode, $defaults['validation_groups']);

            if (isset($defaults['translation'])) {
                $this->createTranslationNode($resourceNode, $defaults['translation']);
            }
        }

        return $node;
    }
378309
public function withStructure(ITableStructure $structure) : TableViewsDefiner
    {
        return new TableViewsDefiner($this->name, $this->callback, new ArrayTableDataSource($structure, $this->data));
    }
1206775
private function findStructureByDataId(ElementStructure $structure, $dataId)
    {
        if ($structure->getDataId() === $dataId) {
            return $structure;
        }

        foreach ($structure->getStructures() as $childStructure) {
            $result = $this->findStructureByDataId($childStructure, $dataId);
            if ($result) {
                return $result;
            }
        }

        return null;
    }
233317
public function save( & $structure )
    {
        if ( $structure instanceof Structure )
        {
            $userId     = $structure->userId;
            $section    = $structure->section;
            $settings   = $structure->settings;
        }
        else
        {
            $data = (array) $structure;

            if ( ArrayUtils::isHashTable( $data ) )
            {
                $userId     = $data['userId'];
                $section    = $data['section'];
                $settings   = $data['settings'];
            }
            else
            {
                list( $userId,
                      $section,
                      $settings ) = $data;
            }
        }

        $rows       = 0;
        $savedKeys  = array();
        $sql        = $this->sql();

        foreach ( $settings as $key => $value )
        {
            $update = $sql->update()
                          ->set( array(
                              'value' => $value
                          ) )
                          ->where( array(
                              'userId'  => $userId,
                              'section' => $section,
                              'key'     => $key,
                          ) );

            $affected = $this->sql()
                             ->prepareStatementForSqlObject( $update )
                             ->execute()
                             ->getAffectedRows();

            if ( $affected )
            {
                $rows += $affected;
            }
            else
            {
                $insert = $sql->insert()
                              ->values( array(
                                 'userId'  => $userId,
                                 'section' => $section,
                                 'key'     => $key,
                                 'value'   => $value,
                             ) );

                $rows += $this->sql()
                              ->prepareStatementForSqlObject( $insert )
                              ->execute()
                              ->getAffectedRows();
            }

            $savedKeys[] = $key;
        }

        $deleteWhere = array(
            'userId'    => $userId,
            'section'   => $section,
        );

        if ( ! empty( $savedKeys ) )
        {
            $deleteWhere[] = new NotIn( 'key', $savedKeys );
        }

        $delete = $this->sql()
                       ->delete()
                       ->where( $deleteWhere );

        $rows += $this->sql()
                      ->prepareStatementForSqlObject( $delete )
                      ->execute()
                      ->getAffectedRows();

        return $rows;
    }
133469
public function hydrate( array $data, $structure )
    {
        if ( $structure instanceof Structure\ProxyBase )
        {
            if ( isset( $data['tags'] ) && is_string( $data['tags'] ) )
            {
                $data['tags'] = explode( static::TAG_SEPARATOR, $data['tags'] );
            }

            if ( isset( $data['tagIds'] ) && is_string( $data['tagIds'] ) )
            {
                $data['tagIds'] = explode( static::TAG_SEPARATOR, $data['tagIds'] );
            }

            if ( isset( $data['localeTags'] ) && is_string( $data['localeTags'] ) )
            {
                $data['localeTags'] = explode( static::TAG_SEPARATOR, $data['localeTags'] );
            }

            if ( isset( $data['proxyData'] ) )
            {
                $proxyData = $data['proxyData'] ?: array();
                unset( $data['proxyData'] );

                if ( is_string( $proxyData ) )
                {
                    $proxyData = $this->parseProxyData( $proxyData );
                }

                if ( is_array( $proxyData ) )
                {
                    $proxyData = array_merge( $data, $proxyData );
                }

                foreach ( static::$columns as $column => $type )
                {
                    unset( $proxyData[$column] );
                }
            }
            else
            {
                $proxyData = $data;
            }

            $proxyData['proxyBase'] = parent::hydrate( $data, $structure );
            $proxyData['type']      = $proxyData['proxyBase']->type;

            return $this->structureFactory
                        ->factory( $proxyData );
        }

        return parent::hydrate( $data, $structure );
    }
861697
public function create($name, $structure, $options = '')
	{
        Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated');
		$db = Eresus_DB::getHandler();
		$name = $db->options->tableNamePrefix . $name;
		$query = "CREATE TABLE `$name` ($structure) $options";
		$result = $this->query($query);

		if ($result)
		{
			$db = Eresus_DB::getHandler();
			$this->dbSchema = ezcDbSchema::createFromDb($db);
		}

		return $result;
	}
753305
private function includeAndParseFiles($structure, $rootDir)
    {
        if (\is_array($structure)) {
            $result = [];
            foreach ($structure as $key => $structureElement) {
                $result[$key] = $this->includeAndParseFiles($structureElement, $rootDir);
            }

            return $result;
        }

        if ($structure instanceof TaggedValue && $structure->getTag() === 'include') {
            return $this->loadAndParseFile($structure->getValue(), $rootDir);
        }

        if (\strpos($structure, '!include') === 0) {
            return $this->loadAndParseFile(\str_replace('!include ', '', $structure), $rootDir);
        }

        return $structure;
    }
258170
public function convertStructureToSuccessMessage(MessageStructure $structure, RawMessage $rawMessage)
    {
        $message = new SuccessMessage($structure->getElements()[0]);
        $message->setSerialization($rawMessage->getBytes());

        return $message;
    }
260086
public function create($data)
    {
        $fileDescriptor = new FileDescriptor($data->getHash());
        $fileDescriptor->setPackage(
            $this->extractPackageFromDocBlock($data->getDocBlock()) ?: $this->getBuilder()->getDefaultPackage()
        );

        $fileDescriptor->setName($data->getName());
        $fileDescriptor->setPath($data->getPath());
        if ($this->getBuilder()->getProjectDescriptor()->getSettings()->shouldIncludeSource()) {
            $fileDescriptor->setSource($data->getSource());
        }

        $fileDescriptor->setIncludes(new Collection($data->getIncludes()));
        $fileDescriptor->setNamespaceAliases(new Collection($data->getNamespaces()));

        $this->assembleDocBlock($data->getDocBlock(), $fileDescriptor);
        $this->overridePackageTag($data, $fileDescriptor);

        //$this->addMarkers($data->getMarkers(), $fileDescriptor);
        $this->addConstants($data->getConstants(), $fileDescriptor);
        $this->addFunctions($data->getFunctions(), $fileDescriptor);
        $this->addClasses($data->getClasses(), $fileDescriptor);
        $this->addInterfaces($data->getInterfaces(), $fileDescriptor);
        $this->addTraits($data->getTraits(), $fileDescriptor);

        return $fileDescriptor;
    }
248224
public function createProperty(ItemMetadata $property, StructureInterface $structure = null)
    {
        if ($property instanceof SectionMetadata) {
            return $this->createSectionProperty($property, $structure);
        }

        if ($property instanceof BlockMetadata) {
            return $this->createBlockProperty($property, $structure);
        }

        if (null === $property->getType()) {
            throw new \RuntimeException(sprintf(
                'Property name "%s" has no type.',
                $property->getName()
            ));
        }

        $parameters = $this->convertArrayToParameters($property->getParameters());
        $propertyBridge = new LegacyProperty(
            $property->getName(),
            [
                'title' => $property->getTitles(),
                'info_text' => $property->getDescriptions(),
                'placeholder' => $property->getPlaceholders(),
            ],
            $property->getType(),
            $property->isRequired(),
            $property->isLocalized(),
            $property->getMaxOccurs(),
            $property->getMinOccurs(),
            $parameters,
            [],
            $property->getColSpan()
        );

        foreach ($property->getTags() as $tag) {
            $propertyBridge->addTag(new PropertyTag($tag['name'], $tag['priority'], $tag['attributes']));
        }

        $propertyBridge->setStructure($structure);

        return $propertyBridge;
    }
1273244
public function create($resourceType, $name, $data)
    {
        return $this->client()->put($data, 'custom-fields/{resourceType}/{name}', [
            'resourceType' => $resourceType,
            'name' => $name,
        ]);
    }