repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
netgen-layouts/layouts-core | lib/Core/StructBuilder/LayoutResolverStructBuilder.php | LayoutResolverStructBuilder.newConditionCreateStruct | public function newConditionCreateStruct(string $type): ConditionCreateStruct
{
$struct = new ConditionCreateStruct();
$struct->type = $type;
return $struct;
} | php | public function newConditionCreateStruct(string $type): ConditionCreateStruct
{
$struct = new ConditionCreateStruct();
$struct->type = $type;
return $struct;
} | [
"public",
"function",
"newConditionCreateStruct",
"(",
"string",
"$",
"type",
")",
":",
"ConditionCreateStruct",
"{",
"$",
"struct",
"=",
"new",
"ConditionCreateStruct",
"(",
")",
";",
"$",
"struct",
"->",
"type",
"=",
"$",
"type",
";",
"return",
"$",
"struc... | Creates a new condition create struct from the provided values. | [
"Creates",
"a",
"new",
"condition",
"create",
"struct",
"from",
"the",
"provided",
"values",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/StructBuilder/LayoutResolverStructBuilder.php#L63-L69 | train |
netgen-layouts/layouts-core | lib/Form/TranslatableTypeTrait.php | TranslatableTypeTrait.disableUntranslatableForms | private function disableUntranslatableForms(FormBuilderInterface $builder): void
{
foreach ($builder as $form) {
/** @var \Symfony\Component\Form\FormBuilderInterface $form */
$innerType = $form->getType()->getInnerType();
$disabled = !$innerType instanceof ParametersType;
$parameterDefinition = $form->getOption('ngbm_parameter_definition');
if ($parameterDefinition instanceof ParameterDefinition) {
$disabled = $parameterDefinition->getOption('translatable') !== true;
}
$form->setDisabled($disabled);
if ($parameterDefinition instanceof ParameterDefinition) {
continue;
}
$this->disableUntranslatableForms($form);
}
} | php | private function disableUntranslatableForms(FormBuilderInterface $builder): void
{
foreach ($builder as $form) {
/** @var \Symfony\Component\Form\FormBuilderInterface $form */
$innerType = $form->getType()->getInnerType();
$disabled = !$innerType instanceof ParametersType;
$parameterDefinition = $form->getOption('ngbm_parameter_definition');
if ($parameterDefinition instanceof ParameterDefinition) {
$disabled = $parameterDefinition->getOption('translatable') !== true;
}
$form->setDisabled($disabled);
if ($parameterDefinition instanceof ParameterDefinition) {
continue;
}
$this->disableUntranslatableForms($form);
}
} | [
"private",
"function",
"disableUntranslatableForms",
"(",
"FormBuilderInterface",
"$",
"builder",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"builder",
"as",
"$",
"form",
")",
"{",
"/** @var \\Symfony\\Component\\Form\\FormBuilderInterface $form */",
"$",
"innerType",
... | Disables all inputs for parameters which are not translatable. | [
"Disables",
"all",
"inputs",
"for",
"parameters",
"which",
"are",
"not",
"translatable",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Form/TranslatableTypeTrait.php#L16-L36 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.loadCollectionData | public function loadCollectionData($collectionId, int $status): array
{
$query = $this->getCollectionSelectQuery();
$query->where(
$query->expr()->eq('c.id', ':id')
)
->setParameter('id', $collectionId, Type::INTEGER);
$this->applyStatusCondition($query, $status, 'c.status');
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | php | public function loadCollectionData($collectionId, int $status): array
{
$query = $this->getCollectionSelectQuery();
$query->where(
$query->expr()->eq('c.id', ':id')
)
->setParameter('id', $collectionId, Type::INTEGER);
$this->applyStatusCondition($query, $status, 'c.status');
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | [
"public",
"function",
"loadCollectionData",
"(",
"$",
"collectionId",
",",
"int",
"$",
"status",
")",
":",
"array",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getCollectionSelectQuery",
"(",
")",
";",
"$",
"query",
"->",
"where",
"(",
"$",
"query",
"->"... | Loads all collection data for collection with specified ID.
@param int|string $collectionId
@param int $status
@return array | [
"Loads",
"all",
"collection",
"data",
"for",
"collection",
"with",
"specified",
"ID",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L25-L36 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.loadItemData | public function loadItemData($itemId, int $status): array
{
$query = $this->getItemSelectQuery();
$query->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $itemId, Type::INTEGER);
$this->applyStatusCondition($query, $status);
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | php | public function loadItemData($itemId, int $status): array
{
$query = $this->getItemSelectQuery();
$query->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $itemId, Type::INTEGER);
$this->applyStatusCondition($query, $status);
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | [
"public",
"function",
"loadItemData",
"(",
"$",
"itemId",
",",
"int",
"$",
"status",
")",
":",
"array",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getItemSelectQuery",
"(",
")",
";",
"$",
"query",
"->",
"where",
"(",
"$",
"query",
"->",
"expr",
"(",... | Loads all data for an item.
@param int|string $itemId
@param int $status
@return array | [
"Loads",
"all",
"data",
"for",
"an",
"item",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L46-L57 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.loadItemWithPositionData | public function loadItemWithPositionData(Collection $collection, int $position): array
{
$query = $this->getItemSelectQuery();
$query->where(
$query->expr()->andX(
$query->expr()->eq('collection_id', ':collection_id'),
$query->expr()->eq('position', ':position')
)
)
->setParameter('collection_id', $collection->id, Type::INTEGER)
->setParameter('position', $position, Type::INTEGER);
$this->applyStatusCondition($query, $collection->status);
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | php | public function loadItemWithPositionData(Collection $collection, int $position): array
{
$query = $this->getItemSelectQuery();
$query->where(
$query->expr()->andX(
$query->expr()->eq('collection_id', ':collection_id'),
$query->expr()->eq('position', ':position')
)
)
->setParameter('collection_id', $collection->id, Type::INTEGER)
->setParameter('position', $position, Type::INTEGER);
$this->applyStatusCondition($query, $collection->status);
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | [
"public",
"function",
"loadItemWithPositionData",
"(",
"Collection",
"$",
"collection",
",",
"int",
"$",
"position",
")",
":",
"array",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getItemSelectQuery",
"(",
")",
";",
"$",
"query",
"->",
"where",
"(",
"$",
... | Loads an item with specified position in specified collection. | [
"Loads",
"an",
"item",
"with",
"specified",
"position",
"in",
"specified",
"collection",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L62-L77 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.loadQueryData | public function loadQueryData($queryId, int $status): array
{
$query = $this->getQuerySelectQuery();
$query->where(
$query->expr()->eq('q.id', ':id')
)
->setParameter('id', $queryId, Type::INTEGER);
$this->applyStatusCondition($query, $status, 'q.status');
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | php | public function loadQueryData($queryId, int $status): array
{
$query = $this->getQuerySelectQuery();
$query->where(
$query->expr()->eq('q.id', ':id')
)
->setParameter('id', $queryId, Type::INTEGER);
$this->applyStatusCondition($query, $status, 'q.status');
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | [
"public",
"function",
"loadQueryData",
"(",
"$",
"queryId",
",",
"int",
"$",
"status",
")",
":",
"array",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQuerySelectQuery",
"(",
")",
";",
"$",
"query",
"->",
"where",
"(",
"$",
"query",
"->",
"expr",
"... | Loads all data for a query.
@param int|string $queryId
@param int $status
@return array | [
"Loads",
"all",
"data",
"for",
"a",
"query",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L87-L98 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.loadCollectionItemsData | public function loadCollectionItemsData(Collection $collection): array
{
$query = $this->getItemSelectQuery();
$query->where(
$query->expr()->eq('collection_id', ':collection_id')
)
->setParameter('collection_id', $collection->id, Type::INTEGER);
$this->applyStatusCondition($query, $collection->status);
$query->addOrderBy('position', 'ASC');
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | php | public function loadCollectionItemsData(Collection $collection): array
{
$query = $this->getItemSelectQuery();
$query->where(
$query->expr()->eq('collection_id', ':collection_id')
)
->setParameter('collection_id', $collection->id, Type::INTEGER);
$this->applyStatusCondition($query, $collection->status);
$query->addOrderBy('position', 'ASC');
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | [
"public",
"function",
"loadCollectionItemsData",
"(",
"Collection",
"$",
"collection",
")",
":",
"array",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getItemSelectQuery",
"(",
")",
";",
"$",
"query",
"->",
"where",
"(",
"$",
"query",
"->",
"expr",
"(",
"... | Loads all data for items that belong to collection with specified ID. | [
"Loads",
"all",
"data",
"for",
"items",
"that",
"belong",
"to",
"collection",
"with",
"specified",
"ID",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L103-L116 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.loadCollectionQueryData | public function loadCollectionQueryData(Collection $collection): array
{
$query = $this->getQuerySelectQuery();
$query->where(
$query->expr()->eq('q.collection_id', ':collection_id')
)
->setParameter('collection_id', $collection->id, Type::INTEGER);
$this->applyStatusCondition($query, $collection->status, 'q.status');
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | php | public function loadCollectionQueryData(Collection $collection): array
{
$query = $this->getQuerySelectQuery();
$query->where(
$query->expr()->eq('q.collection_id', ':collection_id')
)
->setParameter('collection_id', $collection->id, Type::INTEGER);
$this->applyStatusCondition($query, $collection->status, 'q.status');
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | [
"public",
"function",
"loadCollectionQueryData",
"(",
"Collection",
"$",
"collection",
")",
":",
"array",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQuerySelectQuery",
"(",
")",
";",
"$",
"query",
"->",
"where",
"(",
"$",
"query",
"->",
"expr",
"(",
... | Loads all data for queries that belong to collection with specified ID. | [
"Loads",
"all",
"data",
"for",
"queries",
"that",
"belong",
"to",
"collection",
"with",
"specified",
"ID",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L148-L159 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.collectionExists | public function collectionExists($collectionId, int $status): bool
{
$query = $this->connection->createQueryBuilder();
$query->select('count(*) AS count')
->from('ngbm_collection')
->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $collectionId, Type::INTEGER);
$this->applyStatusCondition($query, $status);
$data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
return (int) ($data[0]['count'] ?? 0) > 0;
} | php | public function collectionExists($collectionId, int $status): bool
{
$query = $this->connection->createQueryBuilder();
$query->select('count(*) AS count')
->from('ngbm_collection')
->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $collectionId, Type::INTEGER);
$this->applyStatusCondition($query, $status);
$data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
return (int) ($data[0]['count'] ?? 0) > 0;
} | [
"public",
"function",
"collectionExists",
"(",
"$",
"collectionId",
",",
"int",
"$",
"status",
")",
":",
"bool",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"select",
"(",
"'coun... | Returns if the collection exists.
@param int|string $collectionId
@param int $status
@return bool | [
"Returns",
"if",
"the",
"collection",
"exists",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L169-L184 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.createCollectionTranslation | public function createCollectionTranslation(Collection $collection, string $locale): void
{
$query = $this->connection->createQueryBuilder()
->insert('ngbm_collection_translation')
->values(
[
'collection_id' => ':collection_id',
'status' => ':status',
'locale' => ':locale',
]
)
->setParameter('collection_id', $collection->id, Type::INTEGER)
->setParameter('status', $collection->status, Type::INTEGER)
->setParameter('locale', $locale, Type::STRING);
$query->execute();
} | php | public function createCollectionTranslation(Collection $collection, string $locale): void
{
$query = $this->connection->createQueryBuilder()
->insert('ngbm_collection_translation')
->values(
[
'collection_id' => ':collection_id',
'status' => ':status',
'locale' => ':locale',
]
)
->setParameter('collection_id', $collection->id, Type::INTEGER)
->setParameter('status', $collection->status, Type::INTEGER)
->setParameter('locale', $locale, Type::STRING);
$query->execute();
} | [
"public",
"function",
"createCollectionTranslation",
"(",
"Collection",
"$",
"collection",
",",
"string",
"$",
"locale",
")",
":",
"void",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
"->",
"insert",
"(",
"'n... | Creates a collection translation. | [
"Creates",
"a",
"collection",
"translation",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L227-L243 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.updateCollection | public function updateCollection(Collection $collection): void
{
$query = $this->connection->createQueryBuilder();
$query
->update('ngbm_collection')
->set('start', ':start')
->set('length', ':length')
->set('translatable', ':translatable')
->set('main_locale', ':main_locale')
->set('always_available', ':always_available')
->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $collection->id, Type::INTEGER)
->setParameter('start', $collection->offset, Type::INTEGER)
->setParameter('length', $collection->limit, Type::INTEGER)
->setParameter('translatable', $collection->isTranslatable, Type::BOOLEAN)
->setParameter('main_locale', $collection->mainLocale, Type::STRING)
->setParameter('always_available', $collection->alwaysAvailable, Type::BOOLEAN);
$this->applyStatusCondition($query, $collection->status);
$query->execute();
} | php | public function updateCollection(Collection $collection): void
{
$query = $this->connection->createQueryBuilder();
$query
->update('ngbm_collection')
->set('start', ':start')
->set('length', ':length')
->set('translatable', ':translatable')
->set('main_locale', ':main_locale')
->set('always_available', ':always_available')
->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $collection->id, Type::INTEGER)
->setParameter('start', $collection->offset, Type::INTEGER)
->setParameter('length', $collection->limit, Type::INTEGER)
->setParameter('translatable', $collection->isTranslatable, Type::BOOLEAN)
->setParameter('main_locale', $collection->mainLocale, Type::STRING)
->setParameter('always_available', $collection->alwaysAvailable, Type::BOOLEAN);
$this->applyStatusCondition($query, $collection->status);
$query->execute();
} | [
"public",
"function",
"updateCollection",
"(",
"Collection",
"$",
"collection",
")",
":",
"void",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"update",
"(",
"'ngbm_collection'",
")",... | Updates a collection. | [
"Updates",
"a",
"collection",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L248-L271 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.deleteCollectionTranslations | public function deleteCollectionTranslations($collectionId, ?int $status = null, ?string $locale = null): void
{
$query = $this->connection->createQueryBuilder();
$query->delete('ngbm_collection_translation')
->where(
$query->expr()->eq('collection_id', ':collection_id')
)
->setParameter('collection_id', $collectionId, Type::INTEGER);
if ($status !== null) {
$this->applyStatusCondition($query, $status);
}
if ($locale !== null) {
$query
->andWhere($query->expr()->eq('locale', ':locale'))
->setParameter(':locale', $locale, Type::STRING);
}
$query->execute();
} | php | public function deleteCollectionTranslations($collectionId, ?int $status = null, ?string $locale = null): void
{
$query = $this->connection->createQueryBuilder();
$query->delete('ngbm_collection_translation')
->where(
$query->expr()->eq('collection_id', ':collection_id')
)
->setParameter('collection_id', $collectionId, Type::INTEGER);
if ($status !== null) {
$this->applyStatusCondition($query, $status);
}
if ($locale !== null) {
$query
->andWhere($query->expr()->eq('locale', ':locale'))
->setParameter(':locale', $locale, Type::STRING);
}
$query->execute();
} | [
"public",
"function",
"deleteCollectionTranslations",
"(",
"$",
"collectionId",
",",
"?",
"int",
"$",
"status",
"=",
"null",
",",
"?",
"string",
"$",
"locale",
"=",
"null",
")",
":",
"void",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
... | Deletes collection translations.
@param int|string $collectionId
@param int $status
@param string $locale | [
"Deletes",
"collection",
"translations",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L320-L341 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.updateItem | public function updateItem(Item $item): void
{
$query = $this->connection->createQueryBuilder();
$query
->update('ngbm_collection_item')
->set('collection_id', ':collection_id')
->set('position', ':position')
->set('value', ':value')
->set('value_type', ':value_type')
->set('config', ':config')
->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $item->id, Type::INTEGER)
->setParameter('collection_id', $item->collectionId, Type::INTEGER)
->setParameter('position', $item->position, Type::INTEGER)
->setParameter('value', $item->value, Type::STRING)
->setParameter('value_type', $item->valueType, Type::STRING)
->setParameter('config', $item->config, Type::JSON_ARRAY);
$this->applyStatusCondition($query, $item->status);
$query->execute();
} | php | public function updateItem(Item $item): void
{
$query = $this->connection->createQueryBuilder();
$query
->update('ngbm_collection_item')
->set('collection_id', ':collection_id')
->set('position', ':position')
->set('value', ':value')
->set('value_type', ':value_type')
->set('config', ':config')
->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $item->id, Type::INTEGER)
->setParameter('collection_id', $item->collectionId, Type::INTEGER)
->setParameter('position', $item->position, Type::INTEGER)
->setParameter('value', $item->value, Type::STRING)
->setParameter('value_type', $item->valueType, Type::STRING)
->setParameter('config', $item->config, Type::JSON_ARRAY);
$this->applyStatusCondition($query, $item->status);
$query->execute();
} | [
"public",
"function",
"updateItem",
"(",
"Item",
"$",
"item",
")",
":",
"void",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"update",
"(",
"'ngbm_collection_item'",
")",
"->",
"s... | Updates an item. | [
"Updates",
"an",
"item",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L384-L408 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.createQuery | public function createQuery(Query $query): Query
{
$dbQuery = $this->connection->createQueryBuilder()
->insert('ngbm_collection_query')
->values(
[
'id' => ':id',
'status' => ':status',
'collection_id' => ':collection_id',
'type' => ':type',
]
)
->setValue(
'id',
$query->id !== null ?
(int) $query->id :
$this->connectionHelper->getAutoIncrementValue('ngbm_collection_query')
)
->setParameter('status', $query->status, Type::INTEGER)
->setParameter('collection_id', $query->collectionId, Type::INTEGER)
->setParameter('type', $query->type, Type::STRING);
$dbQuery->execute();
$query->id = $query->id ?? (int) $this->connectionHelper->lastInsertId('ngbm_collection_query');
return $query;
} | php | public function createQuery(Query $query): Query
{
$dbQuery = $this->connection->createQueryBuilder()
->insert('ngbm_collection_query')
->values(
[
'id' => ':id',
'status' => ':status',
'collection_id' => ':collection_id',
'type' => ':type',
]
)
->setValue(
'id',
$query->id !== null ?
(int) $query->id :
$this->connectionHelper->getAutoIncrementValue('ngbm_collection_query')
)
->setParameter('status', $query->status, Type::INTEGER)
->setParameter('collection_id', $query->collectionId, Type::INTEGER)
->setParameter('type', $query->type, Type::STRING);
$dbQuery->execute();
$query->id = $query->id ?? (int) $this->connectionHelper->lastInsertId('ngbm_collection_query');
return $query;
} | [
"public",
"function",
"createQuery",
"(",
"Query",
"$",
"query",
")",
":",
"Query",
"{",
"$",
"dbQuery",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
"->",
"insert",
"(",
"'ngbm_collection_query'",
")",
"->",
"values",
"(",
"... | Creates a query. | [
"Creates",
"a",
"query",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L481-L508 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.createQueryTranslation | public function createQueryTranslation(Query $query, string $locale): void
{
$dbQuery = $this->connection->createQueryBuilder()
->insert('ngbm_collection_query_translation')
->values(
[
'query_id' => ':query_id',
'status' => ':status',
'locale' => ':locale',
'parameters' => ':parameters',
]
)
->setParameter('query_id', $query->id, Type::INTEGER)
->setParameter('status', $query->status, Type::INTEGER)
->setParameter('locale', $locale, Type::STRING)
->setParameter('parameters', $query->parameters[$locale], Type::JSON_ARRAY);
$dbQuery->execute();
} | php | public function createQueryTranslation(Query $query, string $locale): void
{
$dbQuery = $this->connection->createQueryBuilder()
->insert('ngbm_collection_query_translation')
->values(
[
'query_id' => ':query_id',
'status' => ':status',
'locale' => ':locale',
'parameters' => ':parameters',
]
)
->setParameter('query_id', $query->id, Type::INTEGER)
->setParameter('status', $query->status, Type::INTEGER)
->setParameter('locale', $locale, Type::STRING)
->setParameter('parameters', $query->parameters[$locale], Type::JSON_ARRAY);
$dbQuery->execute();
} | [
"public",
"function",
"createQueryTranslation",
"(",
"Query",
"$",
"query",
",",
"string",
"$",
"locale",
")",
":",
"void",
"{",
"$",
"dbQuery",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
"->",
"insert",
"(",
"'ngbm_collectio... | Creates a query translation. | [
"Creates",
"a",
"query",
"translation",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L513-L531 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.updateQueryTranslation | public function updateQueryTranslation(Query $query, string $locale): void
{
$dbQuery = $this->connection->createQueryBuilder();
$dbQuery
->update('ngbm_collection_query_translation')
->set('parameters', ':parameters')
->where(
$dbQuery->expr()->andX(
$dbQuery->expr()->eq('query_id', ':query_id'),
$dbQuery->expr()->eq('locale', ':locale')
)
)
->setParameter('query_id', $query->id, Type::INTEGER)
->setParameter('locale', $locale, Type::STRING)
->setParameter('parameters', $query->parameters[$locale], Type::JSON_ARRAY);
$this->applyStatusCondition($dbQuery, $query->status);
$dbQuery->execute();
} | php | public function updateQueryTranslation(Query $query, string $locale): void
{
$dbQuery = $this->connection->createQueryBuilder();
$dbQuery
->update('ngbm_collection_query_translation')
->set('parameters', ':parameters')
->where(
$dbQuery->expr()->andX(
$dbQuery->expr()->eq('query_id', ':query_id'),
$dbQuery->expr()->eq('locale', ':locale')
)
)
->setParameter('query_id', $query->id, Type::INTEGER)
->setParameter('locale', $locale, Type::STRING)
->setParameter('parameters', $query->parameters[$locale], Type::JSON_ARRAY);
$this->applyStatusCondition($dbQuery, $query->status);
$dbQuery->execute();
} | [
"public",
"function",
"updateQueryTranslation",
"(",
"Query",
"$",
"query",
",",
"string",
"$",
"locale",
")",
":",
"void",
"{",
"$",
"dbQuery",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"dbQuery",
"->",
"update"... | Updates a query translation. | [
"Updates",
"a",
"query",
"translation",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L536-L556 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.deleteQueryTranslations | public function deleteQueryTranslations(array $queryIds, ?int $status = null, ?string $locale = null): void
{
$query = $this->connection->createQueryBuilder();
$query->delete('ngbm_collection_query_translation')
->where(
$query->expr()->in('query_id', [':query_id'])
)
->setParameter('query_id', $queryIds, Connection::PARAM_INT_ARRAY);
if ($status !== null) {
$this->applyStatusCondition($query, $status);
}
if ($locale !== null) {
$query
->andWhere($query->expr()->eq('locale', ':locale'))
->setParameter(':locale', $locale, Type::STRING);
}
$query->execute();
} | php | public function deleteQueryTranslations(array $queryIds, ?int $status = null, ?string $locale = null): void
{
$query = $this->connection->createQueryBuilder();
$query->delete('ngbm_collection_query_translation')
->where(
$query->expr()->in('query_id', [':query_id'])
)
->setParameter('query_id', $queryIds, Connection::PARAM_INT_ARRAY);
if ($status !== null) {
$this->applyStatusCondition($query, $status);
}
if ($locale !== null) {
$query
->andWhere($query->expr()->eq('locale', ':locale'))
->setParameter(':locale', $locale, Type::STRING);
}
$query->execute();
} | [
"public",
"function",
"deleteQueryTranslations",
"(",
"array",
"$",
"queryIds",
",",
"?",
"int",
"$",
"status",
"=",
"null",
",",
"?",
"string",
"$",
"locale",
"=",
"null",
")",
":",
"void",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->"... | Deletes the query translations with provided query IDs. | [
"Deletes",
"the",
"query",
"translations",
"with",
"provided",
"query",
"IDs",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L581-L602 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.getItemSelectQuery | private function getItemSelectQuery(): QueryBuilder
{
$query = $this->connection->createQueryBuilder();
$query->select('DISTINCT ngbm_collection_item.*')
->from('ngbm_collection_item');
return $query;
} | php | private function getItemSelectQuery(): QueryBuilder
{
$query = $this->connection->createQueryBuilder();
$query->select('DISTINCT ngbm_collection_item.*')
->from('ngbm_collection_item');
return $query;
} | [
"private",
"function",
"getItemSelectQuery",
"(",
")",
":",
"QueryBuilder",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"select",
"(",
"'DISTINCT ngbm_collection_item.*'",
")",
"->",
"... | Builds and returns an item database SELECT query. | [
"Builds",
"and",
"returns",
"an",
"item",
"database",
"SELECT",
"query",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L628-L635 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php | CollectionQueryHandler.getQuerySelectQuery | private function getQuerySelectQuery(): QueryBuilder
{
$query = $this->connection->createQueryBuilder();
$query->select('DISTINCT q.*, qt.*')
->from('ngbm_collection_query', 'q')
->innerJoin(
'q',
'ngbm_collection_query_translation',
'qt',
$query->expr()->andX(
$query->expr()->eq('qt.query_id', 'q.id'),
$query->expr()->eq('qt.status', 'q.status')
)
);
return $query;
} | php | private function getQuerySelectQuery(): QueryBuilder
{
$query = $this->connection->createQueryBuilder();
$query->select('DISTINCT q.*, qt.*')
->from('ngbm_collection_query', 'q')
->innerJoin(
'q',
'ngbm_collection_query_translation',
'qt',
$query->expr()->andX(
$query->expr()->eq('qt.query_id', 'q.id'),
$query->expr()->eq('qt.status', 'q.status')
)
);
return $query;
} | [
"private",
"function",
"getQuerySelectQuery",
"(",
")",
":",
"QueryBuilder",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"select",
"(",
"'DISTINCT q.*, qt.*'",
")",
"->",
"from",
"("... | Builds and returns a block database SELECT query. | [
"Builds",
"and",
"returns",
"a",
"block",
"database",
"SELECT",
"query",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/CollectionQueryHandler.php#L640-L656 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/Mapper/LayoutResolverMapper.php | LayoutResolverMapper.mapRules | public function mapRules(array $data): array
{
$rules = [];
foreach ($data as $dataItem) {
$rules[] = Rule::fromArray(
[
'id' => (int) $dataItem['id'],
'status' => (int) $dataItem['status'],
'layoutId' => $dataItem['layout_id'] !== null ? (int) $dataItem['layout_id'] : null,
'enabled' => (bool) $dataItem['enabled'],
'priority' => (int) $dataItem['priority'],
'comment' => $dataItem['comment'],
]
);
}
return $rules;
} | php | public function mapRules(array $data): array
{
$rules = [];
foreach ($data as $dataItem) {
$rules[] = Rule::fromArray(
[
'id' => (int) $dataItem['id'],
'status' => (int) $dataItem['status'],
'layoutId' => $dataItem['layout_id'] !== null ? (int) $dataItem['layout_id'] : null,
'enabled' => (bool) $dataItem['enabled'],
'priority' => (int) $dataItem['priority'],
'comment' => $dataItem['comment'],
]
);
}
return $rules;
} | [
"public",
"function",
"mapRules",
"(",
"array",
"$",
"data",
")",
":",
"array",
"{",
"$",
"rules",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"dataItem",
")",
"{",
"$",
"rules",
"[",
"]",
"=",
"Rule",
"::",
"fromArray",
"(",
"[",... | Maps data from database to rule values.
@return \Netgen\BlockManager\Persistence\Values\LayoutResolver\Rule[] | [
"Maps",
"data",
"from",
"database",
"to",
"rule",
"values",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/Mapper/LayoutResolverMapper.php#L18-L36 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/Mapper/LayoutResolverMapper.php | LayoutResolverMapper.mapTargets | public function mapTargets(array $data): array
{
$targets = [];
foreach ($data as $dataItem) {
$targets[] = Target::fromArray(
[
'id' => (int) $dataItem['id'],
'status' => (int) $dataItem['status'],
'ruleId' => (int) $dataItem['rule_id'],
'type' => $dataItem['type'],
'value' => $dataItem['value'],
]
);
}
return $targets;
} | php | public function mapTargets(array $data): array
{
$targets = [];
foreach ($data as $dataItem) {
$targets[] = Target::fromArray(
[
'id' => (int) $dataItem['id'],
'status' => (int) $dataItem['status'],
'ruleId' => (int) $dataItem['rule_id'],
'type' => $dataItem['type'],
'value' => $dataItem['value'],
]
);
}
return $targets;
} | [
"public",
"function",
"mapTargets",
"(",
"array",
"$",
"data",
")",
":",
"array",
"{",
"$",
"targets",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"dataItem",
")",
"{",
"$",
"targets",
"[",
"]",
"=",
"Target",
"::",
"fromArray",
"("... | Maps data from database to target values.
@return \Netgen\BlockManager\Persistence\Values\LayoutResolver\Target[] | [
"Maps",
"data",
"from",
"database",
"to",
"target",
"values",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/Mapper/LayoutResolverMapper.php#L43-L60 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/Mapper/LayoutResolverMapper.php | LayoutResolverMapper.mapConditions | public function mapConditions(array $data): array
{
$conditions = [];
foreach ($data as $dataItem) {
$conditions[] = Condition::fromArray(
[
'id' => (int) $dataItem['id'],
'status' => (int) $dataItem['status'],
'ruleId' => (int) $dataItem['rule_id'],
'type' => $dataItem['type'],
'value' => json_decode($dataItem['value'], true),
]
);
}
return $conditions;
} | php | public function mapConditions(array $data): array
{
$conditions = [];
foreach ($data as $dataItem) {
$conditions[] = Condition::fromArray(
[
'id' => (int) $dataItem['id'],
'status' => (int) $dataItem['status'],
'ruleId' => (int) $dataItem['rule_id'],
'type' => $dataItem['type'],
'value' => json_decode($dataItem['value'], true),
]
);
}
return $conditions;
} | [
"public",
"function",
"mapConditions",
"(",
"array",
"$",
"data",
")",
":",
"array",
"{",
"$",
"conditions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"dataItem",
")",
"{",
"$",
"conditions",
"[",
"]",
"=",
"Condition",
"::",
"fromA... | Maps data from database to condition values.
@return \Netgen\BlockManager\Persistence\Values\LayoutResolver\Condition[] | [
"Maps",
"data",
"from",
"database",
"to",
"condition",
"values",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/Mapper/LayoutResolverMapper.php#L67-L84 | train |
netgen-layouts/layouts-core | lib/Block/BlockType/BlockTypeFactory.php | BlockTypeFactory.buildBlockType | public static function buildBlockType(string $identifier, array $config, BlockDefinitionInterface $blockDefinition): BlockType
{
return BlockType::fromArray(
[
'identifier' => $identifier,
'isEnabled' => $config['enabled'],
'name' => $config['name'],
'icon' => $config['icon'],
'definition' => $blockDefinition,
'defaults' => $config['defaults'],
]
);
} | php | public static function buildBlockType(string $identifier, array $config, BlockDefinitionInterface $blockDefinition): BlockType
{
return BlockType::fromArray(
[
'identifier' => $identifier,
'isEnabled' => $config['enabled'],
'name' => $config['name'],
'icon' => $config['icon'],
'definition' => $blockDefinition,
'defaults' => $config['defaults'],
]
);
} | [
"public",
"static",
"function",
"buildBlockType",
"(",
"string",
"$",
"identifier",
",",
"array",
"$",
"config",
",",
"BlockDefinitionInterface",
"$",
"blockDefinition",
")",
":",
"BlockType",
"{",
"return",
"BlockType",
"::",
"fromArray",
"(",
"[",
"'identifier'"... | Builds the block type. | [
"Builds",
"the",
"block",
"type",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Block/BlockType/BlockTypeFactory.php#L14-L26 | train |
netgen-layouts/layouts-core | lib/Block/BlockDefinitionFactory.php | BlockDefinitionFactory.buildContainerDefinition | public function buildContainerDefinition(
string $identifier,
ContainerDefinitionHandlerInterface $handler,
array $config,
array $configDefinitionHandlers
): ContainerDefinitionInterface {
$commonData = $this->getCommonBlockDefinitionData(
$identifier,
$handler,
$config,
$configDefinitionHandlers
);
return ContainerDefinition::fromArray($commonData);
} | php | public function buildContainerDefinition(
string $identifier,
ContainerDefinitionHandlerInterface $handler,
array $config,
array $configDefinitionHandlers
): ContainerDefinitionInterface {
$commonData = $this->getCommonBlockDefinitionData(
$identifier,
$handler,
$config,
$configDefinitionHandlers
);
return ContainerDefinition::fromArray($commonData);
} | [
"public",
"function",
"buildContainerDefinition",
"(",
"string",
"$",
"identifier",
",",
"ContainerDefinitionHandlerInterface",
"$",
"handler",
",",
"array",
"$",
"config",
",",
"array",
"$",
"configDefinitionHandlers",
")",
":",
"ContainerDefinitionInterface",
"{",
"$"... | Builds the container definition.
@param string $identifier
@param \Netgen\BlockManager\Block\BlockDefinition\ContainerDefinitionHandlerInterface $handler
@param array<string, mixed> $config
@param \Netgen\BlockManager\Config\ConfigDefinitionHandlerInterface[] $configDefinitionHandlers
@return \Netgen\BlockManager\Block\ContainerDefinitionInterface | [
"Builds",
"the",
"container",
"definition",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Block/BlockDefinitionFactory.php#L108-L122 | train |
netgen-layouts/layouts-core | lib/Block/BlockDefinitionFactory.php | BlockDefinitionFactory.getCommonBlockDefinitionData | private function getCommonBlockDefinitionData(
string $identifier,
BlockDefinitionHandlerInterface $handler,
array $config,
array $configDefinitionHandlers
): array {
$parameterBuilder = $this->parameterBuilderFactory->createParameterBuilder();
$handler->buildParameters($parameterBuilder);
$handlerPlugins = $this->handlerPluginRegistry->getPlugins(get_class($handler));
foreach ($handlerPlugins as $handlerPlugin) {
$handlerPlugin->buildParameters($parameterBuilder);
}
$parameterDefinitions = $parameterBuilder->buildParameterDefinitions();
$configDefinitions = [];
foreach ($configDefinitionHandlers as $configKey => $configDefinitionHandler) {
$configDefinitions[$configKey] = $this->configDefinitionFactory->buildConfigDefinition(
$configKey,
$configDefinitionHandler
);
}
return [
'identifier' => $identifier,
'handler' => $handler,
'handlerPlugins' => $handlerPlugins,
'parameterDefinitions' => $parameterDefinitions,
'configDefinitions' => $configDefinitions,
] + $this->processConfig($identifier, $config);
} | php | private function getCommonBlockDefinitionData(
string $identifier,
BlockDefinitionHandlerInterface $handler,
array $config,
array $configDefinitionHandlers
): array {
$parameterBuilder = $this->parameterBuilderFactory->createParameterBuilder();
$handler->buildParameters($parameterBuilder);
$handlerPlugins = $this->handlerPluginRegistry->getPlugins(get_class($handler));
foreach ($handlerPlugins as $handlerPlugin) {
$handlerPlugin->buildParameters($parameterBuilder);
}
$parameterDefinitions = $parameterBuilder->buildParameterDefinitions();
$configDefinitions = [];
foreach ($configDefinitionHandlers as $configKey => $configDefinitionHandler) {
$configDefinitions[$configKey] = $this->configDefinitionFactory->buildConfigDefinition(
$configKey,
$configDefinitionHandler
);
}
return [
'identifier' => $identifier,
'handler' => $handler,
'handlerPlugins' => $handlerPlugins,
'parameterDefinitions' => $parameterDefinitions,
'configDefinitions' => $configDefinitions,
] + $this->processConfig($identifier, $config);
} | [
"private",
"function",
"getCommonBlockDefinitionData",
"(",
"string",
"$",
"identifier",
",",
"BlockDefinitionHandlerInterface",
"$",
"handler",
",",
"array",
"$",
"config",
",",
"array",
"$",
"configDefinitionHandlers",
")",
":",
"array",
"{",
"$",
"parameterBuilder"... | Returns the data common to all block definition types.
@param string $identifier
@param \Netgen\BlockManager\Block\BlockDefinition\BlockDefinitionHandlerInterface $handler
@param array<string, mixed> $config
@param \Netgen\BlockManager\Config\ConfigDefinitionHandlerInterface[] $configDefinitionHandlers
@return array<string, mixed> | [
"Returns",
"the",
"data",
"common",
"to",
"all",
"block",
"definition",
"types",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Block/BlockDefinitionFactory.php#L134-L165 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/Templating/Twig/Node/RenderZone.php | RenderZone.compileContextNode | private function compileContextNode(Compiler $compiler): void
{
$contextNode = null;
if ($this->hasNode('context')) {
$contextNode = $this->getNode('context');
}
if ($contextNode instanceof Node) {
$compiler
->write('$ngbmContext = ')
->subcompile($this->getNode('context'))
->write(';' . PHP_EOL);
return;
}
$compiler->write('$ngbmContext = ' . ViewInterface::class . '::CONTEXT_DEFAULT;' . PHP_EOL);
} | php | private function compileContextNode(Compiler $compiler): void
{
$contextNode = null;
if ($this->hasNode('context')) {
$contextNode = $this->getNode('context');
}
if ($contextNode instanceof Node) {
$compiler
->write('$ngbmContext = ')
->subcompile($this->getNode('context'))
->write(';' . PHP_EOL);
return;
}
$compiler->write('$ngbmContext = ' . ViewInterface::class . '::CONTEXT_DEFAULT;' . PHP_EOL);
} | [
"private",
"function",
"compileContextNode",
"(",
"Compiler",
"$",
"compiler",
")",
":",
"void",
"{",
"$",
"contextNode",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"hasNode",
"(",
"'context'",
")",
")",
"{",
"$",
"contextNode",
"=",
"$",
"this",
... | Compiles the context node. | [
"Compiles",
"the",
"context",
"node",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/Templating/Twig/Node/RenderZone.php#L45-L62 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/Templating/Twig/Runtime/CollectionPagerRuntime.php | CollectionPagerRuntime.renderCollectionPager | public function renderCollectionPager(Pagerfanta $pagerfanta, Block $block, string $collectionIdentifier, array $options = []): string
{
$options['block'] = $block;
$options['collection_identifier'] = $collectionIdentifier;
return $this->pagerfantaView->render($pagerfanta, $this->routeGenerator, $options);
} | php | public function renderCollectionPager(Pagerfanta $pagerfanta, Block $block, string $collectionIdentifier, array $options = []): string
{
$options['block'] = $block;
$options['collection_identifier'] = $collectionIdentifier;
return $this->pagerfantaView->render($pagerfanta, $this->routeGenerator, $options);
} | [
"public",
"function",
"renderCollectionPager",
"(",
"Pagerfanta",
"$",
"pagerfanta",
",",
"Block",
"$",
"block",
",",
"string",
"$",
"collectionIdentifier",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"options",
"[",
"'block'",... | Renders the provided Pagerfanta view. | [
"Renders",
"the",
"provided",
"Pagerfanta",
"view",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/Templating/Twig/Runtime/CollectionPagerRuntime.php#L33-L39 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/Templating/Twig/Runtime/CollectionPagerRuntime.php | CollectionPagerRuntime.getCollectionPageUrl | public function getCollectionPageUrl(Pagerfanta $pagerfanta, Block $block, string $collectionIdentifier, int $page = 1): string
{
if ($page < 1 || $page > $pagerfanta->getNbPages()) {
throw new InvalidArgumentException(
'page',
sprintf('Page %d is out of bounds', $page)
);
}
return call_user_func($this->routeGenerator, $block, $collectionIdentifier, $page);
} | php | public function getCollectionPageUrl(Pagerfanta $pagerfanta, Block $block, string $collectionIdentifier, int $page = 1): string
{
if ($page < 1 || $page > $pagerfanta->getNbPages()) {
throw new InvalidArgumentException(
'page',
sprintf('Page %d is out of bounds', $page)
);
}
return call_user_func($this->routeGenerator, $block, $collectionIdentifier, $page);
} | [
"public",
"function",
"getCollectionPageUrl",
"(",
"Pagerfanta",
"$",
"pagerfanta",
",",
"Block",
"$",
"block",
",",
"string",
"$",
"collectionIdentifier",
",",
"int",
"$",
"page",
"=",
"1",
")",
":",
"string",
"{",
"if",
"(",
"$",
"page",
"<",
"1",
"||"... | Returns the URL of the provided pager and page number. | [
"Returns",
"the",
"URL",
"of",
"the",
"provided",
"pager",
"and",
"page",
"number",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/Templating/Twig/Runtime/CollectionPagerRuntime.php#L44-L54 | train |
netgen-layouts/layouts-core | migrations/Doctrine/Version000900.php | Version000900.hasLayouts | private function hasLayouts(): bool
{
$queryBuilder = $this->connection->createQueryBuilder();
$queryBuilder->select('COUNT(id) as count')
->from('ngbm_layout');
$result = $queryBuilder->execute()->fetchAll(PDO::FETCH_ASSOC);
return (int) $result[0]['count'] > 0;
} | php | private function hasLayouts(): bool
{
$queryBuilder = $this->connection->createQueryBuilder();
$queryBuilder->select('COUNT(id) as count')
->from('ngbm_layout');
$result = $queryBuilder->execute()->fetchAll(PDO::FETCH_ASSOC);
return (int) $result[0]['count'] > 0;
} | [
"private",
"function",
"hasLayouts",
"(",
")",
":",
"bool",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"select",
"(",
"'COUNT(id) as count'",
")",
"->",
"from",
"(",
... | Returns if the database already contains some layouts. | [
"Returns",
"if",
"the",
"database",
"already",
"contains",
"some",
"layouts",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/migrations/Doctrine/Version000900.php#L163-L172 | train |
netgen-layouts/layouts-core | migrations/Doctrine/Version000900.php | Version000900.askDefaultLocale | private function askDefaultLocale(): string
{
$io = new SymfonyStyle(new ArgvInput(), new ConsoleOutput());
return $io->ask(
'Please input the default locale for existing layouts',
'',
static function (string $locale): string {
if (!Locales::exists($locale)) {
throw new RuntimeException('Specified locale is not valid');
}
return $locale;
}
);
} | php | private function askDefaultLocale(): string
{
$io = new SymfonyStyle(new ArgvInput(), new ConsoleOutput());
return $io->ask(
'Please input the default locale for existing layouts',
'',
static function (string $locale): string {
if (!Locales::exists($locale)) {
throw new RuntimeException('Specified locale is not valid');
}
return $locale;
}
);
} | [
"private",
"function",
"askDefaultLocale",
"(",
")",
":",
"string",
"{",
"$",
"io",
"=",
"new",
"SymfonyStyle",
"(",
"new",
"ArgvInput",
"(",
")",
",",
"new",
"ConsoleOutput",
"(",
")",
")",
";",
"return",
"$",
"io",
"->",
"ask",
"(",
"'Please input the ... | Asks the user for default layout locale and returns it. | [
"Asks",
"the",
"user",
"for",
"default",
"layout",
"locale",
"and",
"returns",
"it",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/migrations/Doctrine/Version000900.php#L177-L192 | train |
netgen-layouts/layouts-core | lib/Block/BlockType/BlockTypeGroupFactory.php | BlockTypeGroupFactory.buildBlockTypeGroup | public static function buildBlockTypeGroup(string $identifier, array $config, array $blockTypes): BlockTypeGroup
{
return BlockTypeGroup::fromArray(
[
'identifier' => $identifier,
'isEnabled' => $config['enabled'],
'name' => $config['name'],
'blockTypes' => $blockTypes,
]
);
} | php | public static function buildBlockTypeGroup(string $identifier, array $config, array $blockTypes): BlockTypeGroup
{
return BlockTypeGroup::fromArray(
[
'identifier' => $identifier,
'isEnabled' => $config['enabled'],
'name' => $config['name'],
'blockTypes' => $blockTypes,
]
);
} | [
"public",
"static",
"function",
"buildBlockTypeGroup",
"(",
"string",
"$",
"identifier",
",",
"array",
"$",
"config",
",",
"array",
"$",
"blockTypes",
")",
":",
"BlockTypeGroup",
"{",
"return",
"BlockTypeGroup",
"::",
"fromArray",
"(",
"[",
"'identifier'",
"=>",... | Builds the block type group.
@param string $identifier
@param array<string, mixed> $config
@param \Netgen\BlockManager\Block\BlockType\BlockType[] $blockTypes
@return \Netgen\BlockManager\Block\BlockType\BlockTypeGroup | [
"Builds",
"the",
"block",
"type",
"group",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Block/BlockType/BlockTypeGroupFactory.php#L18-L28 | train |
netgen-layouts/layouts-core | lib/Core/Mapper/LayoutResolverMapper.php | LayoutResolverMapper.mapRule | public function mapRule(PersistenceRule $rule): Rule
{
$ruleData = [
'id' => $rule->id,
'status' => $rule->status,
'layout' => function () use ($rule): ?Layout {
try {
// Layouts used by rule are always in published status
return $rule->layoutId !== null ? $this->layoutService->loadLayout($rule->layoutId) : null;
} catch (NotFoundException $e) {
return null;
}
},
'enabled' => $rule->enabled,
'priority' => $rule->priority,
'comment' => $rule->comment,
'targets' => new LazyCollection(
function () use ($rule): array {
return array_map(
function (PersistenceTarget $target): Target {
return $this->mapTarget($target);
},
$this->layoutResolverHandler->loadRuleTargets($rule)
);
}
),
'conditions' => new LazyCollection(
function () use ($rule): array {
return array_map(
function (PersistenceCondition $condition): Condition {
return $this->mapCondition($condition);
},
$this->layoutResolverHandler->loadRuleConditions($rule)
);
}
),
];
return Rule::fromArray($ruleData);
} | php | public function mapRule(PersistenceRule $rule): Rule
{
$ruleData = [
'id' => $rule->id,
'status' => $rule->status,
'layout' => function () use ($rule): ?Layout {
try {
// Layouts used by rule are always in published status
return $rule->layoutId !== null ? $this->layoutService->loadLayout($rule->layoutId) : null;
} catch (NotFoundException $e) {
return null;
}
},
'enabled' => $rule->enabled,
'priority' => $rule->priority,
'comment' => $rule->comment,
'targets' => new LazyCollection(
function () use ($rule): array {
return array_map(
function (PersistenceTarget $target): Target {
return $this->mapTarget($target);
},
$this->layoutResolverHandler->loadRuleTargets($rule)
);
}
),
'conditions' => new LazyCollection(
function () use ($rule): array {
return array_map(
function (PersistenceCondition $condition): Condition {
return $this->mapCondition($condition);
},
$this->layoutResolverHandler->loadRuleConditions($rule)
);
}
),
];
return Rule::fromArray($ruleData);
} | [
"public",
"function",
"mapRule",
"(",
"PersistenceRule",
"$",
"rule",
")",
":",
"Rule",
"{",
"$",
"ruleData",
"=",
"[",
"'id'",
"=>",
"$",
"rule",
"->",
"id",
",",
"'status'",
"=>",
"$",
"rule",
"->",
"status",
",",
"'layout'",
"=>",
"function",
"(",
... | Builds the API rule value from persistence one. | [
"Builds",
"the",
"API",
"rule",
"value",
"from",
"persistence",
"one",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Mapper/LayoutResolverMapper.php#L62-L101 | train |
netgen-layouts/layouts-core | lib/Core/Mapper/LayoutResolverMapper.php | LayoutResolverMapper.mapTarget | public function mapTarget(PersistenceTarget $target): Target
{
try {
$targetType = $this->targetTypeRegistry->getTargetType(
$target->type
);
} catch (TargetTypeException $e) {
$targetType = new NullTargetType();
}
$targetData = [
'id' => $target->id,
'status' => $target->status,
'ruleId' => $target->ruleId,
'targetType' => $targetType,
'value' => $target->value,
];
return Target::fromArray($targetData);
} | php | public function mapTarget(PersistenceTarget $target): Target
{
try {
$targetType = $this->targetTypeRegistry->getTargetType(
$target->type
);
} catch (TargetTypeException $e) {
$targetType = new NullTargetType();
}
$targetData = [
'id' => $target->id,
'status' => $target->status,
'ruleId' => $target->ruleId,
'targetType' => $targetType,
'value' => $target->value,
];
return Target::fromArray($targetData);
} | [
"public",
"function",
"mapTarget",
"(",
"PersistenceTarget",
"$",
"target",
")",
":",
"Target",
"{",
"try",
"{",
"$",
"targetType",
"=",
"$",
"this",
"->",
"targetTypeRegistry",
"->",
"getTargetType",
"(",
"$",
"target",
"->",
"type",
")",
";",
"}",
"catch... | Builds the API target value from persistence one. | [
"Builds",
"the",
"API",
"target",
"value",
"from",
"persistence",
"one",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Mapper/LayoutResolverMapper.php#L106-L125 | train |
netgen-layouts/layouts-core | lib/Core/Mapper/LayoutResolverMapper.php | LayoutResolverMapper.mapCondition | public function mapCondition(PersistenceCondition $condition): Condition
{
try {
$conditionType = $this->conditionTypeRegistry->getConditionType(
$condition->type
);
} catch (ConditionTypeException $e) {
$conditionType = new NullConditionType();
}
$conditionData = [
'id' => $condition->id,
'status' => $condition->status,
'ruleId' => $condition->ruleId,
'conditionType' => $conditionType,
'value' => $condition->value,
];
return Condition::fromArray($conditionData);
} | php | public function mapCondition(PersistenceCondition $condition): Condition
{
try {
$conditionType = $this->conditionTypeRegistry->getConditionType(
$condition->type
);
} catch (ConditionTypeException $e) {
$conditionType = new NullConditionType();
}
$conditionData = [
'id' => $condition->id,
'status' => $condition->status,
'ruleId' => $condition->ruleId,
'conditionType' => $conditionType,
'value' => $condition->value,
];
return Condition::fromArray($conditionData);
} | [
"public",
"function",
"mapCondition",
"(",
"PersistenceCondition",
"$",
"condition",
")",
":",
"Condition",
"{",
"try",
"{",
"$",
"conditionType",
"=",
"$",
"this",
"->",
"conditionTypeRegistry",
"->",
"getConditionType",
"(",
"$",
"condition",
"->",
"type",
")"... | Builds the API condition value from persistence one. | [
"Builds",
"the",
"API",
"condition",
"value",
"from",
"persistence",
"one",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Mapper/LayoutResolverMapper.php#L130-L149 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/DependencyInjection/CompilerPass/View/DefaultViewTemplatesPass.php | DefaultViewTemplatesPass.updateRules | protected function updateRules(ContainerBuilder $container, ?array $allRules): array
{
$allRules = is_array($allRules) ? $allRules : [];
$defaultTemplates = $container->getParameter('netgen_block_manager.default_view_templates');
foreach ($defaultTemplates as $viewName => $viewTemplates) {
foreach ($viewTemplates as $context => $template) {
$rules = [];
if (isset($allRules[$viewName][$context]) && is_array($allRules[$viewName][$context])) {
$rules = $allRules[$viewName][$context];
}
$rules = $this->addDefaultRule($viewName, $context, $rules, $template);
$allRules[$viewName][$context] = $rules;
}
}
return $allRules;
} | php | protected function updateRules(ContainerBuilder $container, ?array $allRules): array
{
$allRules = is_array($allRules) ? $allRules : [];
$defaultTemplates = $container->getParameter('netgen_block_manager.default_view_templates');
foreach ($defaultTemplates as $viewName => $viewTemplates) {
foreach ($viewTemplates as $context => $template) {
$rules = [];
if (isset($allRules[$viewName][$context]) && is_array($allRules[$viewName][$context])) {
$rules = $allRules[$viewName][$context];
}
$rules = $this->addDefaultRule($viewName, $context, $rules, $template);
$allRules[$viewName][$context] = $rules;
}
}
return $allRules;
} | [
"protected",
"function",
"updateRules",
"(",
"ContainerBuilder",
"$",
"container",
",",
"?",
"array",
"$",
"allRules",
")",
":",
"array",
"{",
"$",
"allRules",
"=",
"is_array",
"(",
"$",
"allRules",
")",
"?",
"$",
"allRules",
":",
"[",
"]",
";",
"$",
"... | Updates all view rules to add the default template match. | [
"Updates",
"all",
"view",
"rules",
"to",
"add",
"the",
"default",
"template",
"match",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/DependencyInjection/CompilerPass/View/DefaultViewTemplatesPass.php#L27-L48 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/DependencyInjection/CompilerPass/View/DefaultViewTemplatesPass.php | DefaultViewTemplatesPass.addDefaultRule | protected function addDefaultRule(string $viewName, string $context, array $rules, string $defaultTemplate): array
{
$rules += [
"___{$viewName}_{$context}_default___" => [
'template' => $defaultTemplate,
'match' => [],
'parameters' => [],
],
];
return $rules;
} | php | protected function addDefaultRule(string $viewName, string $context, array $rules, string $defaultTemplate): array
{
$rules += [
"___{$viewName}_{$context}_default___" => [
'template' => $defaultTemplate,
'match' => [],
'parameters' => [],
],
];
return $rules;
} | [
"protected",
"function",
"addDefaultRule",
"(",
"string",
"$",
"viewName",
",",
"string",
"$",
"context",
",",
"array",
"$",
"rules",
",",
"string",
"$",
"defaultTemplate",
")",
":",
"array",
"{",
"$",
"rules",
"+=",
"[",
"\"___{$viewName}_{$context}_default___\... | Adds the default view template as a fallback to specified view rules. | [
"Adds",
"the",
"default",
"view",
"template",
"as",
"a",
"fallback",
"to",
"specified",
"view",
"rules",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/DependencyInjection/CompilerPass/View/DefaultViewTemplatesPass.php#L53-L64 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/EventListener/ExceptionConversionListener.php | ExceptionConversionListener.onException | public function onException(GetResponseForExceptionEvent $event): void
{
if (!$event->isMasterRequest()) {
return;
}
$attributes = $event->getRequest()->attributes;
if ($attributes->get(SetIsApiRequestListener::API_FLAG_NAME) !== true) {
return;
}
$exception = $event->getException();
if ($exception instanceof HttpExceptionInterface) {
return;
}
$exceptionClass = null;
foreach ($this->exceptionMap as $sourceException => $targetException) {
if (is_a($exception, $sourceException, true)) {
$exceptionClass = $targetException;
break;
}
}
if ($exceptionClass !== null) {
$convertedException = new $exceptionClass(
$exception->getMessage(),
$exception,
$exception->getCode()
);
$event->setException($convertedException);
}
} | php | public function onException(GetResponseForExceptionEvent $event): void
{
if (!$event->isMasterRequest()) {
return;
}
$attributes = $event->getRequest()->attributes;
if ($attributes->get(SetIsApiRequestListener::API_FLAG_NAME) !== true) {
return;
}
$exception = $event->getException();
if ($exception instanceof HttpExceptionInterface) {
return;
}
$exceptionClass = null;
foreach ($this->exceptionMap as $sourceException => $targetException) {
if (is_a($exception, $sourceException, true)) {
$exceptionClass = $targetException;
break;
}
}
if ($exceptionClass !== null) {
$convertedException = new $exceptionClass(
$exception->getMessage(),
$exception,
$exception->getCode()
);
$event->setException($convertedException);
}
} | [
"public",
"function",
"onException",
"(",
"GetResponseForExceptionEvent",
"$",
"event",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"event",
"->",
"isMasterRequest",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"attributes",
"=",
"$",
"event",
"->",
"get... | Converts exceptions to Symfony HTTP exceptions. | [
"Converts",
"exceptions",
"to",
"Symfony",
"HTTP",
"exceptions",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/EventListener/ExceptionConversionListener.php#L45-L79 | train |
netgen-layouts/layouts-core | lib/API/Values/Block/Block.php | Block.getPlaceholder | public function getPlaceholder(string $identifier): APIPlaceholder
{
if ($this->hasPlaceholder($identifier)) {
return $this->placeholders[$identifier];
}
throw BlockException::noPlaceholder($identifier);
} | php | public function getPlaceholder(string $identifier): APIPlaceholder
{
if ($this->hasPlaceholder($identifier)) {
return $this->placeholders[$identifier];
}
throw BlockException::noPlaceholder($identifier);
} | [
"public",
"function",
"getPlaceholder",
"(",
"string",
"$",
"identifier",
")",
":",
"APIPlaceholder",
"{",
"if",
"(",
"$",
"this",
"->",
"hasPlaceholder",
"(",
"$",
"identifier",
")",
")",
"{",
"return",
"$",
"this",
"->",
"placeholders",
"[",
"$",
"identi... | Returns the specified placeholder.
@throws \Netgen\BlockManager\Exception\API\BlockException If the placeholder does not exist | [
"Returns",
"the",
"specified",
"placeholder",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/API/Values/Block/Block.php#L213-L220 | train |
netgen-layouts/layouts-core | lib/API/Values/Block/Block.php | Block.getCollection | public function getCollection(string $identifier): Collection
{
if (!$this->hasCollection($identifier)) {
throw BlockException::noCollection($identifier);
}
return $this->collections->get($identifier);
} | php | public function getCollection(string $identifier): Collection
{
if (!$this->hasCollection($identifier)) {
throw BlockException::noCollection($identifier);
}
return $this->collections->get($identifier);
} | [
"public",
"function",
"getCollection",
"(",
"string",
"$",
"identifier",
")",
":",
"Collection",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasCollection",
"(",
"$",
"identifier",
")",
")",
"{",
"throw",
"BlockException",
"::",
"noCollection",
"(",
"$",
"ide... | Returns the specified block collection.
@throws \Netgen\BlockManager\Exception\API\BlockException If the block collection does not exist | [
"Returns",
"the",
"specified",
"block",
"collection",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/API/Values/Block/Block.php#L243-L250 | train |
netgen-layouts/layouts-core | lib/API/Values/Block/Block.php | Block.hasDynamicParameter | public function hasDynamicParameter(string $parameter): bool
{
$this->buildDynamicParameters();
return $this->dynamicParameters->offsetExists($parameter);
} | php | public function hasDynamicParameter(string $parameter): bool
{
$this->buildDynamicParameters();
return $this->dynamicParameters->offsetExists($parameter);
} | [
"public",
"function",
"hasDynamicParameter",
"(",
"string",
"$",
"parameter",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"buildDynamicParameters",
"(",
")",
";",
"return",
"$",
"this",
"->",
"dynamicParameters",
"->",
"offsetExists",
"(",
"$",
"parameter",
")",... | Returns if the object has a specified dynamic parameter. | [
"Returns",
"if",
"the",
"object",
"has",
"a",
"specified",
"dynamic",
"parameter",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/API/Values/Block/Block.php#L275-L280 | train |
netgen-layouts/layouts-core | lib/API/Values/Block/Block.php | Block.buildDynamicParameters | private function buildDynamicParameters(): void
{
$this->dynamicParameters = $this->dynamicParameters ?? $this->definition->getDynamicParameters($this);
} | php | private function buildDynamicParameters(): void
{
$this->dynamicParameters = $this->dynamicParameters ?? $this->definition->getDynamicParameters($this);
} | [
"private",
"function",
"buildDynamicParameters",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"dynamicParameters",
"=",
"$",
"this",
"->",
"dynamicParameters",
"??",
"$",
"this",
"->",
"definition",
"->",
"getDynamicParameters",
"(",
"$",
"this",
")",
";",
... | Builds the dynamic parameters of the block from the block definition. | [
"Builds",
"the",
"dynamic",
"parameters",
"of",
"the",
"block",
"from",
"the",
"block",
"definition",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/API/Values/Block/Block.php#L335-L338 | train |
netgen-layouts/layouts-core | lib/Core/Mapper/BlockMapper.php | BlockMapper.mapBlock | public function mapBlock(PersistenceBlock $block, ?array $locales = null, bool $useMainLocale = true): Block
{
try {
$blockDefinition = $this->blockDefinitionRegistry->getBlockDefinition(
$block->definitionIdentifier
);
} catch (BlockDefinitionException $e) {
$blockDefinition = new NullBlockDefinition($block->definitionIdentifier);
}
$locales = is_array($locales) && count($locales) > 0 ? $locales : [$block->mainLocale];
if ($useMainLocale && $block->alwaysAvailable) {
$locales[] = $block->mainLocale;
}
$validLocales = array_unique(array_intersect($locales, $block->availableLocales));
if (count($validLocales) === 0) {
throw new NotFoundException('block', $block->id);
}
/** @var string $blockLocale */
$blockLocale = array_values($validLocales)[0];
$untranslatableParams = iterator_to_array(
$this->parameterMapper->extractUntranslatableParameters(
$blockDefinition,
$block->parameters[$block->mainLocale]
)
);
$blockData = [
'id' => $block->id,
'layoutId' => $block->layoutId,
'definition' => $blockDefinition,
'viewType' => $block->viewType,
'itemViewType' => $block->itemViewType,
'name' => $block->name,
'position' => $block->position,
'parentBlockId' => $block->depth > 1 ? $block->parentId : null,
'parentPlaceholder' => $block->depth > 1 ? $block->placeholder : null,
'status' => $block->status,
'placeholders' => iterator_to_array($this->mapPlaceholders($block, $blockDefinition, $locales)),
'collections' => new LazyCollection(
function () use ($block, $locales): array {
return array_map(
function (PersistenceCollection $collection) use ($locales): Collection {
return $this->collectionMapper->mapCollection($collection, $locales);
},
iterator_to_array($this->loadCollections($block))
);
}
),
'configs' => iterator_to_array(
$this->configMapper->mapConfig(
$block->config,
$blockDefinition->getConfigDefinitions()
)
),
'isTranslatable' => $block->isTranslatable,
'mainLocale' => $block->mainLocale,
'alwaysAvailable' => $block->alwaysAvailable,
'availableLocales' => $block->availableLocales,
'locale' => $blockLocale,
'parameters' => iterator_to_array(
$this->parameterMapper->mapParameters(
$blockDefinition,
$untranslatableParams + $block->parameters[$blockLocale]
)
),
];
return Block::fromArray($blockData);
} | php | public function mapBlock(PersistenceBlock $block, ?array $locales = null, bool $useMainLocale = true): Block
{
try {
$blockDefinition = $this->blockDefinitionRegistry->getBlockDefinition(
$block->definitionIdentifier
);
} catch (BlockDefinitionException $e) {
$blockDefinition = new NullBlockDefinition($block->definitionIdentifier);
}
$locales = is_array($locales) && count($locales) > 0 ? $locales : [$block->mainLocale];
if ($useMainLocale && $block->alwaysAvailable) {
$locales[] = $block->mainLocale;
}
$validLocales = array_unique(array_intersect($locales, $block->availableLocales));
if (count($validLocales) === 0) {
throw new NotFoundException('block', $block->id);
}
/** @var string $blockLocale */
$blockLocale = array_values($validLocales)[0];
$untranslatableParams = iterator_to_array(
$this->parameterMapper->extractUntranslatableParameters(
$blockDefinition,
$block->parameters[$block->mainLocale]
)
);
$blockData = [
'id' => $block->id,
'layoutId' => $block->layoutId,
'definition' => $blockDefinition,
'viewType' => $block->viewType,
'itemViewType' => $block->itemViewType,
'name' => $block->name,
'position' => $block->position,
'parentBlockId' => $block->depth > 1 ? $block->parentId : null,
'parentPlaceholder' => $block->depth > 1 ? $block->placeholder : null,
'status' => $block->status,
'placeholders' => iterator_to_array($this->mapPlaceholders($block, $blockDefinition, $locales)),
'collections' => new LazyCollection(
function () use ($block, $locales): array {
return array_map(
function (PersistenceCollection $collection) use ($locales): Collection {
return $this->collectionMapper->mapCollection($collection, $locales);
},
iterator_to_array($this->loadCollections($block))
);
}
),
'configs' => iterator_to_array(
$this->configMapper->mapConfig(
$block->config,
$blockDefinition->getConfigDefinitions()
)
),
'isTranslatable' => $block->isTranslatable,
'mainLocale' => $block->mainLocale,
'alwaysAvailable' => $block->alwaysAvailable,
'availableLocales' => $block->availableLocales,
'locale' => $blockLocale,
'parameters' => iterator_to_array(
$this->parameterMapper->mapParameters(
$blockDefinition,
$untranslatableParams + $block->parameters[$blockLocale]
)
),
];
return Block::fromArray($blockData);
} | [
"public",
"function",
"mapBlock",
"(",
"PersistenceBlock",
"$",
"block",
",",
"?",
"array",
"$",
"locales",
"=",
"null",
",",
"bool",
"$",
"useMainLocale",
"=",
"true",
")",
":",
"Block",
"{",
"try",
"{",
"$",
"blockDefinition",
"=",
"$",
"this",
"->",
... | Builds the API block value from persistence one.
If not empty, the first available locale in $locales array will be returned.
If the block is always available and $useMainLocale is set to true,
block in main locale will be returned if none of the locales in $locales
array are found.
@throws \Netgen\BlockManager\Exception\NotFoundException If the block does not have any requested translations | [
"Builds",
"the",
"API",
"block",
"value",
"from",
"persistence",
"one",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Mapper/BlockMapper.php#L82-L153 | train |
netgen-layouts/layouts-core | lib/Core/Mapper/BlockMapper.php | BlockMapper.loadCollections | private function loadCollections(PersistenceBlock $block): Generator
{
$collectionReferences = $this->blockHandler->loadCollectionReferences($block);
foreach ($collectionReferences as $collectionReference) {
yield $collectionReference->identifier => $this->collectionHandler->loadCollection(
$collectionReference->collectionId,
$collectionReference->collectionStatus
);
}
} | php | private function loadCollections(PersistenceBlock $block): Generator
{
$collectionReferences = $this->blockHandler->loadCollectionReferences($block);
foreach ($collectionReferences as $collectionReference) {
yield $collectionReference->identifier => $this->collectionHandler->loadCollection(
$collectionReference->collectionId,
$collectionReference->collectionStatus
);
}
} | [
"private",
"function",
"loadCollections",
"(",
"PersistenceBlock",
"$",
"block",
")",
":",
"Generator",
"{",
"$",
"collectionReferences",
"=",
"$",
"this",
"->",
"blockHandler",
"->",
"loadCollectionReferences",
"(",
"$",
"block",
")",
";",
"foreach",
"(",
"$",
... | Loads all persistence collections belonging to the provided block. | [
"Loads",
"all",
"persistence",
"collections",
"belonging",
"to",
"the",
"provided",
"block",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Mapper/BlockMapper.php#L158-L168 | train |
netgen-layouts/layouts-core | lib/Core/Mapper/BlockMapper.php | BlockMapper.mapPlaceholders | private function mapPlaceholders(PersistenceBlock $block, BlockDefinitionInterface $blockDefinition, ?array $locales = null): Generator
{
if (!$blockDefinition instanceof ContainerDefinitionInterface) {
return;
}
foreach ($blockDefinition->getPlaceholders() as $placeholderIdentifier) {
yield $placeholderIdentifier => Placeholder::fromArray(
[
'identifier' => $placeholderIdentifier,
'blocks' => new LazyCollection(
function () use ($block, $placeholderIdentifier, $locales): array {
return array_map(
function (PersistenceBlock $childBlock) use ($locales): Block {
return $this->mapBlock($childBlock, $locales, false);
},
$this->blockHandler->loadChildBlocks($block, $placeholderIdentifier)
);
}
),
]
);
}
} | php | private function mapPlaceholders(PersistenceBlock $block, BlockDefinitionInterface $blockDefinition, ?array $locales = null): Generator
{
if (!$blockDefinition instanceof ContainerDefinitionInterface) {
return;
}
foreach ($blockDefinition->getPlaceholders() as $placeholderIdentifier) {
yield $placeholderIdentifier => Placeholder::fromArray(
[
'identifier' => $placeholderIdentifier,
'blocks' => new LazyCollection(
function () use ($block, $placeholderIdentifier, $locales): array {
return array_map(
function (PersistenceBlock $childBlock) use ($locales): Block {
return $this->mapBlock($childBlock, $locales, false);
},
$this->blockHandler->loadChildBlocks($block, $placeholderIdentifier)
);
}
),
]
);
}
} | [
"private",
"function",
"mapPlaceholders",
"(",
"PersistenceBlock",
"$",
"block",
",",
"BlockDefinitionInterface",
"$",
"blockDefinition",
",",
"?",
"array",
"$",
"locales",
"=",
"null",
")",
":",
"Generator",
"{",
"if",
"(",
"!",
"$",
"blockDefinition",
"instanc... | Maps the placeholder from persistence parameters. | [
"Maps",
"the",
"placeholder",
"from",
"persistence",
"parameters",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Mapper/BlockMapper.php#L173-L196 | train |
netgen-layouts/layouts-core | lib/API/Values/ParameterStructTrait.php | ParameterStructTrait.getParameterValue | public function getParameterValue(string $parameterName)
{
if (!$this->hasParameterValue($parameterName)) {
return null;
}
return $this->parameterValues[$parameterName];
} | php | public function getParameterValue(string $parameterName)
{
if (!$this->hasParameterValue($parameterName)) {
return null;
}
return $this->parameterValues[$parameterName];
} | [
"public",
"function",
"getParameterValue",
"(",
"string",
"$",
"parameterName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasParameterValue",
"(",
"$",
"parameterName",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"parameterV... | Returns the parameter value with provided name or null if parameter does not exist.
@return mixed | [
"Returns",
"the",
"parameter",
"value",
"with",
"provided",
"name",
"or",
"null",
"if",
"parameter",
"does",
"not",
"exist",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/API/Values/ParameterStructTrait.php#L54-L61 | train |
netgen-layouts/layouts-core | lib/API/Values/ParameterStructTrait.php | ParameterStructTrait.fillDefault | private function fillDefault(ParameterDefinitionCollectionInterface $definitionCollection): void
{
foreach ($definitionCollection->getParameterDefinitions() as $name => $definition) {
$this->setParameterValue($name, $definition->getDefaultValue());
if ($definition instanceof CompoundParameterDefinition) {
$this->fillDefault($definition);
}
}
} | php | private function fillDefault(ParameterDefinitionCollectionInterface $definitionCollection): void
{
foreach ($definitionCollection->getParameterDefinitions() as $name => $definition) {
$this->setParameterValue($name, $definition->getDefaultValue());
if ($definition instanceof CompoundParameterDefinition) {
$this->fillDefault($definition);
}
}
} | [
"private",
"function",
"fillDefault",
"(",
"ParameterDefinitionCollectionInterface",
"$",
"definitionCollection",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"definitionCollection",
"->",
"getParameterDefinitions",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"definition",... | Fills the struct with the default parameter values as defined in provided
parameter definition collection. | [
"Fills",
"the",
"struct",
"with",
"the",
"default",
"parameter",
"values",
"as",
"defined",
"in",
"provided",
"parameter",
"definition",
"collection",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/API/Values/ParameterStructTrait.php#L75-L84 | train |
netgen-layouts/layouts-core | lib/API/Values/ParameterStructTrait.php | ParameterStructTrait.fillFromCollection | private function fillFromCollection(
ParameterDefinitionCollectionInterface $definitionCollection,
ParameterCollectionInterface $parameters
): void {
foreach ($definitionCollection->getParameterDefinitions() as $name => $definition) {
$value = null;
if ($parameters->hasParameter($name)) {
$parameter = $parameters->getParameter($name);
if ($parameter->getParameterDefinition()->getType()::getIdentifier() === $definition->getType()::getIdentifier()) {
$value = $parameter->getValue();
$value = is_object($value) ? clone $value : $value;
}
}
$this->setParameterValue($name, $value);
if ($definition instanceof CompoundParameterDefinition) {
$this->fillFromCollection($definition, $parameters);
}
}
} | php | private function fillFromCollection(
ParameterDefinitionCollectionInterface $definitionCollection,
ParameterCollectionInterface $parameters
): void {
foreach ($definitionCollection->getParameterDefinitions() as $name => $definition) {
$value = null;
if ($parameters->hasParameter($name)) {
$parameter = $parameters->getParameter($name);
if ($parameter->getParameterDefinition()->getType()::getIdentifier() === $definition->getType()::getIdentifier()) {
$value = $parameter->getValue();
$value = is_object($value) ? clone $value : $value;
}
}
$this->setParameterValue($name, $value);
if ($definition instanceof CompoundParameterDefinition) {
$this->fillFromCollection($definition, $parameters);
}
}
} | [
"private",
"function",
"fillFromCollection",
"(",
"ParameterDefinitionCollectionInterface",
"$",
"definitionCollection",
",",
"ParameterCollectionInterface",
"$",
"parameters",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"definitionCollection",
"->",
"getParameterDefinitions"... | Fills the struct values based on provided parameter collection. | [
"Fills",
"the",
"struct",
"values",
"based",
"on",
"provided",
"parameter",
"collection",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/API/Values/ParameterStructTrait.php#L89-L110 | train |
netgen-layouts/layouts-core | lib/API/Values/ParameterStructTrait.php | ParameterStructTrait.fillFromHash | private function fillFromHash(
ParameterDefinitionCollectionInterface $definitionCollection,
array $values,
bool $doImport = false
): void {
foreach ($definitionCollection->getParameterDefinitions() as $name => $definition) {
$value = $definition->getDefaultValue();
$parameterType = $definition->getType();
if (array_key_exists($name, $values)) {
$value = $doImport ?
$parameterType->import($definition, $values[$name]) :
$parameterType->fromHash($definition, $values[$name]);
}
$this->setParameterValue($name, $value);
if ($definition instanceof CompoundParameterDefinition) {
$this->fillFromHash($definition, $values, $doImport);
}
}
} | php | private function fillFromHash(
ParameterDefinitionCollectionInterface $definitionCollection,
array $values,
bool $doImport = false
): void {
foreach ($definitionCollection->getParameterDefinitions() as $name => $definition) {
$value = $definition->getDefaultValue();
$parameterType = $definition->getType();
if (array_key_exists($name, $values)) {
$value = $doImport ?
$parameterType->import($definition, $values[$name]) :
$parameterType->fromHash($definition, $values[$name]);
}
$this->setParameterValue($name, $value);
if ($definition instanceof CompoundParameterDefinition) {
$this->fillFromHash($definition, $values, $doImport);
}
}
} | [
"private",
"function",
"fillFromHash",
"(",
"ParameterDefinitionCollectionInterface",
"$",
"definitionCollection",
",",
"array",
"$",
"values",
",",
"bool",
"$",
"doImport",
"=",
"false",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"definitionCollection",
"->",
"g... | Fills the struct values based on provided array of values.
If any of the parameters is missing from the input array, the default value
based on parameter definition from the definition collection will be used.
The values in the array need to be in hash format of the value
i.e. the format acceptable by the ParameterTypeInterface::fromHash method.
If $doImport is set to true, the values will be considered as coming from an import,
meaning it will be processed using ParameterTypeInterface::import method instead of
ParameterTypeInterface::fromHash method. | [
"Fills",
"the",
"struct",
"values",
"based",
"on",
"provided",
"array",
"of",
"values",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/API/Values/ParameterStructTrait.php#L125-L146 | train |
netgen-layouts/layouts-core | lib/Block/BlockDefinition/Configuration/ViewType.php | ViewType.getItemViewType | public function getItemViewType(string $itemViewType): ItemViewType
{
if (!$this->hasItemViewType($itemViewType)) {
throw BlockDefinitionException::noItemViewType($this->identifier, $itemViewType);
}
return $this->itemViewTypes[$itemViewType];
} | php | public function getItemViewType(string $itemViewType): ItemViewType
{
if (!$this->hasItemViewType($itemViewType)) {
throw BlockDefinitionException::noItemViewType($this->identifier, $itemViewType);
}
return $this->itemViewTypes[$itemViewType];
} | [
"public",
"function",
"getItemViewType",
"(",
"string",
"$",
"itemViewType",
")",
":",
"ItemViewType",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasItemViewType",
"(",
"$",
"itemViewType",
")",
")",
"{",
"throw",
"BlockDefinitionException",
"::",
"noItemViewType"... | Returns the item view type with provided identifier.
@throws \Netgen\BlockManager\Exception\Block\BlockDefinitionException If item view type does not exist | [
"Returns",
"the",
"item",
"view",
"type",
"with",
"provided",
"identifier",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Block/BlockDefinition/Configuration/ViewType.php#L93-L100 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/Templating/Twig/Runtime/PluginRenderingRuntime.php | PluginRenderingRuntime.renderPlugins | public function renderPlugins(array $context, string $pluginName): string
{
try {
return $this->pluginRenderer->renderPlugins(
$pluginName,
$context
);
} catch (Throwable $t) {
$this->errorHandler->handleError($t);
}
return '';
} | php | public function renderPlugins(array $context, string $pluginName): string
{
try {
return $this->pluginRenderer->renderPlugins(
$pluginName,
$context
);
} catch (Throwable $t) {
$this->errorHandler->handleError($t);
}
return '';
} | [
"public",
"function",
"renderPlugins",
"(",
"array",
"$",
"context",
",",
"string",
"$",
"pluginName",
")",
":",
"string",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"pluginRenderer",
"->",
"renderPlugins",
"(",
"$",
"pluginName",
",",
"$",
"context",
"... | Renders all the template plugins with provided name. | [
"Renders",
"all",
"the",
"template",
"plugins",
"with",
"provided",
"name",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/Templating/Twig/Runtime/PluginRenderingRuntime.php#L32-L44 | train |
netgen-layouts/layouts-core | lib/Config/ConfigDefinitionFactory.php | ConfigDefinitionFactory.buildConfigDefinition | public function buildConfigDefinition(
string $configKey,
ConfigDefinitionHandlerInterface $handler
): ConfigDefinitionInterface {
$parameterBuilder = $this->parameterBuilderFactory->createParameterBuilder();
$handler->buildParameters($parameterBuilder);
$parameterDefinitions = $parameterBuilder->buildParameterDefinitions();
return ConfigDefinition::fromArray(
[
'configKey' => $configKey,
'handler' => $handler,
'parameterDefinitions' => $parameterDefinitions,
]
);
} | php | public function buildConfigDefinition(
string $configKey,
ConfigDefinitionHandlerInterface $handler
): ConfigDefinitionInterface {
$parameterBuilder = $this->parameterBuilderFactory->createParameterBuilder();
$handler->buildParameters($parameterBuilder);
$parameterDefinitions = $parameterBuilder->buildParameterDefinitions();
return ConfigDefinition::fromArray(
[
'configKey' => $configKey,
'handler' => $handler,
'parameterDefinitions' => $parameterDefinitions,
]
);
} | [
"public",
"function",
"buildConfigDefinition",
"(",
"string",
"$",
"configKey",
",",
"ConfigDefinitionHandlerInterface",
"$",
"handler",
")",
":",
"ConfigDefinitionInterface",
"{",
"$",
"parameterBuilder",
"=",
"$",
"this",
"->",
"parameterBuilderFactory",
"->",
"create... | Builds the config definition. | [
"Builds",
"the",
"config",
"definition",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Config/ConfigDefinitionFactory.php#L24-L39 | train |
netgen-layouts/layouts-core | lib/Parameters/ParameterCollectionTrait.php | ParameterCollectionTrait.getParameter | public function getParameter(string $parameterName): Parameter
{
if (!$this->hasParameter($parameterName)) {
throw ParameterException::noParameter($parameterName);
}
return $this->parameters[$parameterName];
} | php | public function getParameter(string $parameterName): Parameter
{
if (!$this->hasParameter($parameterName)) {
throw ParameterException::noParameter($parameterName);
}
return $this->parameters[$parameterName];
} | [
"public",
"function",
"getParameter",
"(",
"string",
"$",
"parameterName",
")",
":",
"Parameter",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasParameter",
"(",
"$",
"parameterName",
")",
")",
"{",
"throw",
"ParameterException",
"::",
"noParameter",
"(",
"$",
... | Returns the parameter with provided name.
@throws \Netgen\BlockManager\Exception\Parameters\ParameterException If the requested parameter does not exist | [
"Returns",
"the",
"parameter",
"with",
"provided",
"name",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Parameters/ParameterCollectionTrait.php#L31-L38 | train |
netgen-layouts/layouts-core | lib/Error/DebugErrorHandler.php | DebugErrorHandler.logError | private function logError(Throwable $throwable, ?string $message = null, array $context = []): void
{
$context['error'] = $throwable;
$this->logger->critical($message ?? $throwable->getMessage(), $context);
} | php | private function logError(Throwable $throwable, ?string $message = null, array $context = []): void
{
$context['error'] = $throwable;
$this->logger->critical($message ?? $throwable->getMessage(), $context);
} | [
"private",
"function",
"logError",
"(",
"Throwable",
"$",
"throwable",
",",
"?",
"string",
"$",
"message",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
":",
"void",
"{",
"$",
"context",
"[",
"'error'",
"]",
"=",
"$",
"throwable",
";... | Logs the error. | [
"Logs",
"the",
"error",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Error/DebugErrorHandler.php#L44-L49 | train |
netgen-layouts/layouts-core | lib/API/Values/Config/ConfigAwareValueTrait.php | ConfigAwareValueTrait.getConfig | public function getConfig(string $configKey): APIConfig
{
if ($this->hasConfig($configKey)) {
return $this->configs[$configKey];
}
throw ConfigException::noConfig($configKey);
} | php | public function getConfig(string $configKey): APIConfig
{
if ($this->hasConfig($configKey)) {
return $this->configs[$configKey];
}
throw ConfigException::noConfig($configKey);
} | [
"public",
"function",
"getConfig",
"(",
"string",
"$",
"configKey",
")",
":",
"APIConfig",
"{",
"if",
"(",
"$",
"this",
"->",
"hasConfig",
"(",
"$",
"configKey",
")",
")",
"{",
"return",
"$",
"this",
"->",
"configs",
"[",
"$",
"configKey",
"]",
";",
... | Returns the config with specified config key.
@throws \Netgen\BlockManager\Exception\API\ConfigException If the config does not exist | [
"Returns",
"the",
"config",
"with",
"specified",
"config",
"key",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/API/Values/Config/ConfigAwareValueTrait.php#L30-L37 | train |
netgen-layouts/layouts-core | lib/Transfer/Output/Serializer.php | Serializer.loadLayouts | private function loadLayouts(array $layoutIds): Generator
{
foreach ($layoutIds as $layoutId) {
try {
yield $this->layoutService->loadLayout($layoutId);
} catch (NotFoundException $e) {
continue;
}
}
} | php | private function loadLayouts(array $layoutIds): Generator
{
foreach ($layoutIds as $layoutId) {
try {
yield $this->layoutService->loadLayout($layoutId);
} catch (NotFoundException $e) {
continue;
}
}
} | [
"private",
"function",
"loadLayouts",
"(",
"array",
"$",
"layoutIds",
")",
":",
"Generator",
"{",
"foreach",
"(",
"$",
"layoutIds",
"as",
"$",
"layoutId",
")",
"{",
"try",
"{",
"yield",
"$",
"this",
"->",
"layoutService",
"->",
"loadLayout",
"(",
"$",
"l... | Loads the layouts for provided IDs. | [
"Loads",
"the",
"layouts",
"for",
"provided",
"IDs",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Transfer/Output/Serializer.php#L72-L81 | train |
netgen-layouts/layouts-core | lib/Transfer/Output/Serializer.php | Serializer.loadRules | private function loadRules(array $ruleIds): Generator
{
foreach ($ruleIds as $ruleId) {
try {
yield $this->layoutResolverService->loadRule($ruleId);
} catch (NotFoundException $e) {
continue;
}
}
} | php | private function loadRules(array $ruleIds): Generator
{
foreach ($ruleIds as $ruleId) {
try {
yield $this->layoutResolverService->loadRule($ruleId);
} catch (NotFoundException $e) {
continue;
}
}
} | [
"private",
"function",
"loadRules",
"(",
"array",
"$",
"ruleIds",
")",
":",
"Generator",
"{",
"foreach",
"(",
"$",
"ruleIds",
"as",
"$",
"ruleId",
")",
"{",
"try",
"{",
"yield",
"$",
"this",
"->",
"layoutResolverService",
"->",
"loadRule",
"(",
"$",
"rul... | Loads the rules for provided IDs. | [
"Loads",
"the",
"rules",
"for",
"provided",
"IDs",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Transfer/Output/Serializer.php#L86-L95 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/EventListener/ContextListener.php | ContextListener.onKernelRequest | public function onKernelRequest(GetResponseEvent $event): void
{
if (!$event->isMasterRequest()) {
return;
}
$request = $event->getRequest();
if ($request->attributes->has('ngbmContext')) {
$context = $request->attributes->get('ngbmContext');
$context = is_array($context) ? $context : [];
$this->context->add($context);
return;
}
if ($request->query->has('ngbmContext')) {
$this->context->add($this->getUriContext($request));
return;
}
$this->contextBuilder->buildContext($this->context);
} | php | public function onKernelRequest(GetResponseEvent $event): void
{
if (!$event->isMasterRequest()) {
return;
}
$request = $event->getRequest();
if ($request->attributes->has('ngbmContext')) {
$context = $request->attributes->get('ngbmContext');
$context = is_array($context) ? $context : [];
$this->context->add($context);
return;
}
if ($request->query->has('ngbmContext')) {
$this->context->add($this->getUriContext($request));
return;
}
$this->contextBuilder->buildContext($this->context);
} | [
"public",
"function",
"onKernelRequest",
"(",
"GetResponseEvent",
"$",
"event",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"event",
"->",
"isMasterRequest",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
... | Builds the context object.
If the context is available in query parameters and the URI signature is valid,
it will be used, otherwise, provided builder will be used. | [
"Builds",
"the",
"context",
"object",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/EventListener/ContextListener.php#L53-L76 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/EventListener/ContextListener.php | ContextListener.getUriContext | private function getUriContext(Request $request): array
{
$context = $request->query->get('ngbmContext');
$context = is_array($context) ? $context : [];
if (!$this->uriSigner->check($this->getUri($request))) {
return [];
}
return $context;
} | php | private function getUriContext(Request $request): array
{
$context = $request->query->get('ngbmContext');
$context = is_array($context) ? $context : [];
if (!$this->uriSigner->check($this->getUri($request))) {
return [];
}
return $context;
} | [
"private",
"function",
"getUriContext",
"(",
"Request",
"$",
"request",
")",
":",
"array",
"{",
"$",
"context",
"=",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'ngbmContext'",
")",
";",
"$",
"context",
"=",
"is_array",
"(",
"$",
"context",
")",
... | Validates and returns the array with context information filled from the URI. | [
"Validates",
"and",
"returns",
"the",
"array",
"with",
"context",
"information",
"filled",
"from",
"the",
"URI",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/EventListener/ContextListener.php#L81-L91 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/EventListener/ContextListener.php | ContextListener.getUri | private function getUri(Request $request): string
{
if ($request->attributes->has('ngbmContextUri')) {
return $request->attributes->get('ngbmContextUri');
}
return $request->getRequestUri();
} | php | private function getUri(Request $request): string
{
if ($request->attributes->has('ngbmContextUri')) {
return $request->attributes->get('ngbmContextUri');
}
return $request->getRequestUri();
} | [
"private",
"function",
"getUri",
"(",
"Request",
"$",
"request",
")",
":",
"string",
"{",
"if",
"(",
"$",
"request",
"->",
"attributes",
"->",
"has",
"(",
"'ngbmContextUri'",
")",
")",
"{",
"return",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
... | Returns the URI with the context from the request. This allows
overriding the URI with a value stored in request attributes if,
for example, there's need to pre-process the URI before checking
the signature. | [
"Returns",
"the",
"URI",
"with",
"the",
"context",
"from",
"the",
"request",
".",
"This",
"allows",
"overriding",
"the",
"URI",
"with",
"a",
"value",
"stored",
"in",
"request",
"attributes",
"if",
"for",
"example",
"there",
"s",
"need",
"to",
"pre",
"-",
... | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/EventListener/ContextListener.php#L99-L106 | train |
netgen-layouts/layouts-core | lib/Validator/ValidatorTrait.php | ValidatorTrait.validate | protected function validate($value, $constraints, ?string $propertyPath = null): void
{
try {
$violations = $this->validator->validate($value, $constraints);
} catch (Throwable $t) {
throw ValidationException::validationFailed($propertyPath ?? '', $t->getMessage(), $t);
}
if (count($violations) === 0) {
return;
}
$propertyName = $violations[0]->getPropertyPath() ?? '';
if ($propertyName === '') {
$propertyName = $propertyPath ?? '';
}
throw ValidationException::validationFailed($propertyName, $violations[0]->getMessage());
} | php | protected function validate($value, $constraints, ?string $propertyPath = null): void
{
try {
$violations = $this->validator->validate($value, $constraints);
} catch (Throwable $t) {
throw ValidationException::validationFailed($propertyPath ?? '', $t->getMessage(), $t);
}
if (count($violations) === 0) {
return;
}
$propertyName = $violations[0]->getPropertyPath() ?? '';
if ($propertyName === '') {
$propertyName = $propertyPath ?? '';
}
throw ValidationException::validationFailed($propertyName, $violations[0]->getMessage());
} | [
"protected",
"function",
"validate",
"(",
"$",
"value",
",",
"$",
"constraints",
",",
"?",
"string",
"$",
"propertyPath",
"=",
"null",
")",
":",
"void",
"{",
"try",
"{",
"$",
"violations",
"=",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"$"... | Validates the value against a set of provided constraints.
@param mixed $value
@param \Symfony\Component\Validator\Constraint|\Symfony\Component\Validator\Constraint[] $constraints
@param string $propertyPath
@throws \Netgen\BlockManager\Exception\Validation\ValidationException If the validation failed | [
"Validates",
"the",
"value",
"against",
"a",
"set",
"of",
"provided",
"constraints",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Validator/ValidatorTrait.php#L32-L50 | train |
netgen-layouts/layouts-core | lib/Config/ConfigDefinitionAwareTrait.php | ConfigDefinitionAwareTrait.getConfigDefinition | public function getConfigDefinition(string $configKey): ConfigDefinitionInterface
{
if (!$this->hasConfigDefinition($configKey)) {
throw ConfigDefinitionException::noConfigDefinition($configKey);
}
return $this->configDefinitions[$configKey];
} | php | public function getConfigDefinition(string $configKey): ConfigDefinitionInterface
{
if (!$this->hasConfigDefinition($configKey)) {
throw ConfigDefinitionException::noConfigDefinition($configKey);
}
return $this->configDefinitions[$configKey];
} | [
"public",
"function",
"getConfigDefinition",
"(",
"string",
"$",
"configKey",
")",
":",
"ConfigDefinitionInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasConfigDefinition",
"(",
"$",
"configKey",
")",
")",
"{",
"throw",
"ConfigDefinitionException",
"::",
... | Returns the config definition with provided config key.
@throws \Netgen\BlockManager\Exception\Config\ConfigDefinitionException if config definition does not exist | [
"Returns",
"the",
"config",
"definition",
"with",
"provided",
"config",
"key",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Config/ConfigDefinitionAwareTrait.php#L21-L28 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/EventListener/HttpCache/LayoutResponseListener.php | LayoutResponseListener.onKernelResponse | public function onKernelResponse(FilterResponseEvent $event): void
{
if (!$event->isMasterRequest()) {
return;
}
$layoutView = $event->getRequest()->attributes->get(
$this->isExceptionResponse ?
'ngbmExceptionLayoutView' :
'ngbmLayoutView'
);
if (!$layoutView instanceof LayoutViewInterface) {
return;
}
$this->tagger->tagLayout($event->getResponse(), $layoutView->getLayout());
} | php | public function onKernelResponse(FilterResponseEvent $event): void
{
if (!$event->isMasterRequest()) {
return;
}
$layoutView = $event->getRequest()->attributes->get(
$this->isExceptionResponse ?
'ngbmExceptionLayoutView' :
'ngbmLayoutView'
);
if (!$layoutView instanceof LayoutViewInterface) {
return;
}
$this->tagger->tagLayout($event->getResponse(), $layoutView->getLayout());
} | [
"public",
"function",
"onKernelResponse",
"(",
"FilterResponseEvent",
"$",
"event",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"event",
"->",
"isMasterRequest",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"layoutView",
"=",
"$",
"event",
"->",
"getRequ... | Tags the response with the data for layout provided by the event. | [
"Tags",
"the",
"response",
"with",
"the",
"data",
"for",
"layout",
"provided",
"by",
"the",
"event",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/EventListener/HttpCache/LayoutResponseListener.php#L42-L59 | train |
netgen-layouts/layouts-core | lib/Serializer/Normalizer/V1/CollectionResultNormalizer.php | CollectionResultNormalizer.normalizeResultItem | private function normalizeResultItem(CmsItemInterface $resultItem, int $version, ?string $format = null, array $context = []): array
{
$collectionItem = null;
$cmsItem = $resultItem;
$isDynamic = true;
if ($resultItem instanceof ManualItem) {
$collectionItem = $resultItem->getCollectionItem();
$cmsItem = $collectionItem->getCmsItem();
$isDynamic = false;
}
$configuration = (function () use ($collectionItem, $version): Generator {
$itemConfigs = $collectionItem !== null ? $collectionItem->getConfigs() : [];
foreach ($itemConfigs as $configKey => $config) {
yield $configKey => $this->buildVersionedValues($config->getParameters(), $version);
}
})();
$data = [
'id' => $collectionItem !== null ? $collectionItem->getId() : null,
'collection_id' => $collectionItem !== null ? $collectionItem->getCollectionId() : null,
'visible' => $collectionItem !== null ?
$this->visibilityResolver->isVisible($collectionItem) :
true,
'is_dynamic' => $isDynamic,
'value' => $cmsItem->getValue(),
'value_type' => $cmsItem->getValueType(),
'name' => $cmsItem->getName(),
'cms_visible' => $cmsItem->isVisible(),
'cms_url' => '',
'config' => $this->normalizer->normalize($configuration, $format, $context),
];
try {
$data['cms_url'] = $this->urlGenerator->generate($cmsItem);
} catch (ItemException $e) {
// Do nothing
}
return $data;
} | php | private function normalizeResultItem(CmsItemInterface $resultItem, int $version, ?string $format = null, array $context = []): array
{
$collectionItem = null;
$cmsItem = $resultItem;
$isDynamic = true;
if ($resultItem instanceof ManualItem) {
$collectionItem = $resultItem->getCollectionItem();
$cmsItem = $collectionItem->getCmsItem();
$isDynamic = false;
}
$configuration = (function () use ($collectionItem, $version): Generator {
$itemConfigs = $collectionItem !== null ? $collectionItem->getConfigs() : [];
foreach ($itemConfigs as $configKey => $config) {
yield $configKey => $this->buildVersionedValues($config->getParameters(), $version);
}
})();
$data = [
'id' => $collectionItem !== null ? $collectionItem->getId() : null,
'collection_id' => $collectionItem !== null ? $collectionItem->getCollectionId() : null,
'visible' => $collectionItem !== null ?
$this->visibilityResolver->isVisible($collectionItem) :
true,
'is_dynamic' => $isDynamic,
'value' => $cmsItem->getValue(),
'value_type' => $cmsItem->getValueType(),
'name' => $cmsItem->getName(),
'cms_visible' => $cmsItem->isVisible(),
'cms_url' => '',
'config' => $this->normalizer->normalize($configuration, $format, $context),
];
try {
$data['cms_url'] = $this->urlGenerator->generate($cmsItem);
} catch (ItemException $e) {
// Do nothing
}
return $data;
} | [
"private",
"function",
"normalizeResultItem",
"(",
"CmsItemInterface",
"$",
"resultItem",
",",
"int",
"$",
"version",
",",
"?",
"string",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"collectionItem"... | Normalizes the provided result item into an array. | [
"Normalizes",
"the",
"provided",
"result",
"item",
"into",
"an",
"array",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Serializer/Normalizer/V1/CollectionResultNormalizer.php#L67-L108 | train |
netgen-layouts/layouts-core | lib/Validator/Structs/ParameterStructValidator.php | ParameterStructValidator.buildConstraintFields | private function buildConstraintFields(
ParameterStruct $parameterStruct,
ParameterStructConstraint $constraint
): Generator {
foreach ($constraint->parameterDefinitions->getParameterDefinitions() as $parameterDefinition) {
$constraints = $this->getParameterConstraints($parameterDefinition, $parameterStruct);
if (!$parameterDefinition->isRequired()) {
$constraints = new Constraints\Optional($constraints);
}
yield $parameterDefinition->getName() => $constraints;
if ($parameterDefinition instanceof CompoundParameterDefinition) {
foreach ($parameterDefinition->getParameterDefinitions() as $subParameterDefinition) {
yield $subParameterDefinition->getName() => new Constraints\Optional(
// Sub parameter values are always optional (either missing or set to null)
// so we don't have to validate empty values
$this->getParameterConstraints($subParameterDefinition, $parameterStruct, false)
);
}
}
}
} | php | private function buildConstraintFields(
ParameterStruct $parameterStruct,
ParameterStructConstraint $constraint
): Generator {
foreach ($constraint->parameterDefinitions->getParameterDefinitions() as $parameterDefinition) {
$constraints = $this->getParameterConstraints($parameterDefinition, $parameterStruct);
if (!$parameterDefinition->isRequired()) {
$constraints = new Constraints\Optional($constraints);
}
yield $parameterDefinition->getName() => $constraints;
if ($parameterDefinition instanceof CompoundParameterDefinition) {
foreach ($parameterDefinition->getParameterDefinitions() as $subParameterDefinition) {
yield $subParameterDefinition->getName() => new Constraints\Optional(
// Sub parameter values are always optional (either missing or set to null)
// so we don't have to validate empty values
$this->getParameterConstraints($subParameterDefinition, $parameterStruct, false)
);
}
}
}
} | [
"private",
"function",
"buildConstraintFields",
"(",
"ParameterStruct",
"$",
"parameterStruct",
",",
"ParameterStructConstraint",
"$",
"constraint",
")",
":",
"Generator",
"{",
"foreach",
"(",
"$",
"constraint",
"->",
"parameterDefinitions",
"->",
"getParameterDefinitions... | Builds the "fields" array of the Collection constraint from provided parameters
and parameter values. | [
"Builds",
"the",
"fields",
"array",
"of",
"the",
"Collection",
"constraint",
"from",
"provided",
"parameters",
"and",
"parameter",
"values",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Validator/Structs/ParameterStructValidator.php#L75-L98 | train |
netgen-layouts/layouts-core | lib/Validator/Structs/ParameterStructValidator.php | ParameterStructValidator.getParameterConstraints | private function getParameterConstraints(
ParameterDefinition $parameterDefinition,
ParameterStruct $parameterStruct,
bool $validateEmptyValue = true
): array {
$parameterValue = $parameterStruct->getParameterValue(
$parameterDefinition->getName()
);
if (!$validateEmptyValue && $parameterValue === null) {
return [];
}
return $parameterDefinition->getType()->getConstraints(
$parameterDefinition,
$parameterValue
);
} | php | private function getParameterConstraints(
ParameterDefinition $parameterDefinition,
ParameterStruct $parameterStruct,
bool $validateEmptyValue = true
): array {
$parameterValue = $parameterStruct->getParameterValue(
$parameterDefinition->getName()
);
if (!$validateEmptyValue && $parameterValue === null) {
return [];
}
return $parameterDefinition->getType()->getConstraints(
$parameterDefinition,
$parameterValue
);
} | [
"private",
"function",
"getParameterConstraints",
"(",
"ParameterDefinition",
"$",
"parameterDefinition",
",",
"ParameterStruct",
"$",
"parameterStruct",
",",
"bool",
"$",
"validateEmptyValue",
"=",
"true",
")",
":",
"array",
"{",
"$",
"parameterValue",
"=",
"$",
"p... | Returns all constraints applied on a parameter coming directly from parameter type.
If $validateEmptyValue is false, values equal to null will not be validated
and will simply return an empty array of constraints. | [
"Returns",
"all",
"constraints",
"applied",
"on",
"a",
"parameter",
"coming",
"directly",
"from",
"parameter",
"type",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Validator/Structs/ParameterStructValidator.php#L106-L123 | train |
netgen-layouts/layouts-core | lib/Validator/Structs/ParameterStructValidator.php | ParameterStructValidator.getRuntimeParameterConstraints | private function getRuntimeParameterConstraints(
ParameterDefinition $parameterDefinition,
$parameterValue,
array $allParameterValues
): Generator {
foreach ($parameterDefinition->getConstraints() as $constraint) {
if ($constraint instanceof Closure) {
$constraint = $constraint($parameterValue, $allParameterValues, $parameterDefinition);
}
if ($constraint instanceof Constraint) {
yield $constraint;
}
}
} | php | private function getRuntimeParameterConstraints(
ParameterDefinition $parameterDefinition,
$parameterValue,
array $allParameterValues
): Generator {
foreach ($parameterDefinition->getConstraints() as $constraint) {
if ($constraint instanceof Closure) {
$constraint = $constraint($parameterValue, $allParameterValues, $parameterDefinition);
}
if ($constraint instanceof Constraint) {
yield $constraint;
}
}
} | [
"private",
"function",
"getRuntimeParameterConstraints",
"(",
"ParameterDefinition",
"$",
"parameterDefinition",
",",
"$",
"parameterValue",
",",
"array",
"$",
"allParameterValues",
")",
":",
"Generator",
"{",
"foreach",
"(",
"$",
"parameterDefinition",
"->",
"getConstr... | Returns all constraints applied on a parameter coming from the parameter definition.
@param mixed $parameterValue | [
"Returns",
"all",
"constraints",
"applied",
"on",
"a",
"parameter",
"coming",
"from",
"the",
"parameter",
"definition",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Validator/Structs/ParameterStructValidator.php#L130-L144 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/EventListener/BlockView/GetTwigBlockContentListener.php | GetTwigBlockContentListener.onRenderView | public function onRenderView(CollectViewParametersEvent $event): void
{
$view = $event->getView();
if (!$view instanceof BlockViewInterface) {
return;
}
$block = $view->getBlock();
$blockDefinition = $block->getDefinition();
if (!$blockDefinition instanceof TwigBlockDefinitionInterface) {
return;
}
$twigContent = $this->getTwigBlockContent(
$blockDefinition,
$block,
$view->getParameters()
);
$event->addParameter('twig_content', $twigContent);
} | php | public function onRenderView(CollectViewParametersEvent $event): void
{
$view = $event->getView();
if (!$view instanceof BlockViewInterface) {
return;
}
$block = $view->getBlock();
$blockDefinition = $block->getDefinition();
if (!$blockDefinition instanceof TwigBlockDefinitionInterface) {
return;
}
$twigContent = $this->getTwigBlockContent(
$blockDefinition,
$block,
$view->getParameters()
);
$event->addParameter('twig_content', $twigContent);
} | [
"public",
"function",
"onRenderView",
"(",
"CollectViewParametersEvent",
"$",
"event",
")",
":",
"void",
"{",
"$",
"view",
"=",
"$",
"event",
"->",
"getView",
"(",
")",
";",
"if",
"(",
"!",
"$",
"view",
"instanceof",
"BlockViewInterface",
")",
"{",
"return... | Adds a parameter to the view with the Twig block content. | [
"Adds",
"a",
"parameter",
"to",
"the",
"view",
"with",
"the",
"Twig",
"block",
"content",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/EventListener/BlockView/GetTwigBlockContentListener.php#L25-L46 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/EventListener/BlockView/GetTwigBlockContentListener.php | GetTwigBlockContentListener.getTwigBlockContent | private function getTwigBlockContent(
TwigBlockDefinitionInterface $blockDefinition,
Block $block,
array $parameters
): string {
if (!isset($parameters['twig_template'])) {
return '';
}
if (!$parameters['twig_template'] instanceof ContextualizedTwigTemplate) {
return '';
}
return $parameters['twig_template']->renderBlock(
$blockDefinition->getTwigBlockName($block)
);
} | php | private function getTwigBlockContent(
TwigBlockDefinitionInterface $blockDefinition,
Block $block,
array $parameters
): string {
if (!isset($parameters['twig_template'])) {
return '';
}
if (!$parameters['twig_template'] instanceof ContextualizedTwigTemplate) {
return '';
}
return $parameters['twig_template']->renderBlock(
$blockDefinition->getTwigBlockName($block)
);
} | [
"private",
"function",
"getTwigBlockContent",
"(",
"TwigBlockDefinitionInterface",
"$",
"blockDefinition",
",",
"Block",
"$",
"block",
",",
"array",
"$",
"parameters",
")",
":",
"string",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"parameters",
"[",
"'twig_template... | Returns the Twig block content from the provided block. | [
"Returns",
"the",
"Twig",
"block",
"content",
"from",
"the",
"provided",
"block",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/EventListener/BlockView/GetTwigBlockContentListener.php#L51-L67 | train |
netgen-layouts/layouts-core | lib/Core/Validator/LayoutResolverValidator.php | LayoutResolverValidator.validateRuleCreateStruct | public function validateRuleCreateStruct(RuleCreateStruct $ruleCreateStruct): void
{
if ($ruleCreateStruct->layoutId !== null) {
$this->validate(
$ruleCreateStruct->layoutId,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'scalar']),
],
'layoutId'
);
}
if ($ruleCreateStruct->priority !== null) {
$this->validate(
$ruleCreateStruct->priority,
[
new Constraints\Type(['type' => 'int']),
],
'priority'
);
}
if ($ruleCreateStruct->enabled !== null) {
$this->validate(
$ruleCreateStruct->enabled,
[
new Constraints\Type(['type' => 'bool']),
],
'enabled'
);
}
if ($ruleCreateStruct->comment !== null) {
$this->validate(
$ruleCreateStruct->comment,
[
new Constraints\Type(['type' => 'string']),
],
'comment'
);
}
} | php | public function validateRuleCreateStruct(RuleCreateStruct $ruleCreateStruct): void
{
if ($ruleCreateStruct->layoutId !== null) {
$this->validate(
$ruleCreateStruct->layoutId,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'scalar']),
],
'layoutId'
);
}
if ($ruleCreateStruct->priority !== null) {
$this->validate(
$ruleCreateStruct->priority,
[
new Constraints\Type(['type' => 'int']),
],
'priority'
);
}
if ($ruleCreateStruct->enabled !== null) {
$this->validate(
$ruleCreateStruct->enabled,
[
new Constraints\Type(['type' => 'bool']),
],
'enabled'
);
}
if ($ruleCreateStruct->comment !== null) {
$this->validate(
$ruleCreateStruct->comment,
[
new Constraints\Type(['type' => 'string']),
],
'comment'
);
}
} | [
"public",
"function",
"validateRuleCreateStruct",
"(",
"RuleCreateStruct",
"$",
"ruleCreateStruct",
")",
":",
"void",
"{",
"if",
"(",
"$",
"ruleCreateStruct",
"->",
"layoutId",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"ruleCreateStruct",... | Validates the provided rule create struct.
@throws \Netgen\BlockManager\Exception\Validation\ValidationException If the validation failed | [
"Validates",
"the",
"provided",
"rule",
"create",
"struct",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Validator/LayoutResolverValidator.php#L45-L87 | train |
netgen-layouts/layouts-core | lib/Core/Validator/LayoutResolverValidator.php | LayoutResolverValidator.validateRuleUpdateStruct | public function validateRuleUpdateStruct(RuleUpdateStruct $ruleUpdateStruct): void
{
if ($ruleUpdateStruct->layoutId !== null) {
$this->validate(
$ruleUpdateStruct->layoutId,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'scalar']),
],
'layoutId'
);
}
if ($ruleUpdateStruct->comment !== null) {
$this->validate(
$ruleUpdateStruct->comment,
[
new Constraints\Type(['type' => 'string']),
],
'comment'
);
}
} | php | public function validateRuleUpdateStruct(RuleUpdateStruct $ruleUpdateStruct): void
{
if ($ruleUpdateStruct->layoutId !== null) {
$this->validate(
$ruleUpdateStruct->layoutId,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'scalar']),
],
'layoutId'
);
}
if ($ruleUpdateStruct->comment !== null) {
$this->validate(
$ruleUpdateStruct->comment,
[
new Constraints\Type(['type' => 'string']),
],
'comment'
);
}
} | [
"public",
"function",
"validateRuleUpdateStruct",
"(",
"RuleUpdateStruct",
"$",
"ruleUpdateStruct",
")",
":",
"void",
"{",
"if",
"(",
"$",
"ruleUpdateStruct",
"->",
"layoutId",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"ruleUpdateStruct",... | Validates the provided rule update struct.
@throws \Netgen\BlockManager\Exception\Validation\ValidationException If the validation failed | [
"Validates",
"the",
"provided",
"rule",
"update",
"struct",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Validator/LayoutResolverValidator.php#L94-L116 | train |
netgen-layouts/layouts-core | lib/Core/Validator/LayoutResolverValidator.php | LayoutResolverValidator.validateRuleMetadataUpdateStruct | public function validateRuleMetadataUpdateStruct(RuleMetadataUpdateStruct $ruleUpdateStruct): void
{
if ($ruleUpdateStruct->priority !== null) {
$this->validate(
$ruleUpdateStruct->priority,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'int']),
],
'priority'
);
}
} | php | public function validateRuleMetadataUpdateStruct(RuleMetadataUpdateStruct $ruleUpdateStruct): void
{
if ($ruleUpdateStruct->priority !== null) {
$this->validate(
$ruleUpdateStruct->priority,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'int']),
],
'priority'
);
}
} | [
"public",
"function",
"validateRuleMetadataUpdateStruct",
"(",
"RuleMetadataUpdateStruct",
"$",
"ruleUpdateStruct",
")",
":",
"void",
"{",
"if",
"(",
"$",
"ruleUpdateStruct",
"->",
"priority",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"ru... | Validates the provided rule metadata update struct.
@throws \Netgen\BlockManager\Exception\Validation\ValidationException If the validation failed | [
"Validates",
"the",
"provided",
"rule",
"metadata",
"update",
"struct",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Validator/LayoutResolverValidator.php#L123-L135 | train |
netgen-layouts/layouts-core | lib/Core/Validator/LayoutResolverValidator.php | LayoutResolverValidator.validateTargetCreateStruct | public function validateTargetCreateStruct(TargetCreateStruct $targetCreateStruct): void
{
$this->validate(
$targetCreateStruct->type,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'string']),
],
'type'
);
$targetType = $this->targetTypeRegistry->getTargetType($targetCreateStruct->type);
$this->validate(
$targetCreateStruct->value,
$targetType->getConstraints(),
'value'
);
} | php | public function validateTargetCreateStruct(TargetCreateStruct $targetCreateStruct): void
{
$this->validate(
$targetCreateStruct->type,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'string']),
],
'type'
);
$targetType = $this->targetTypeRegistry->getTargetType($targetCreateStruct->type);
$this->validate(
$targetCreateStruct->value,
$targetType->getConstraints(),
'value'
);
} | [
"public",
"function",
"validateTargetCreateStruct",
"(",
"TargetCreateStruct",
"$",
"targetCreateStruct",
")",
":",
"void",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"targetCreateStruct",
"->",
"type",
",",
"[",
"new",
"Constraints",
"\\",
"NotBlank",
"(",
"... | Validates the provided target create struct.
@throws \Netgen\BlockManager\Exception\Validation\ValidationException If the validation failed | [
"Validates",
"the",
"provided",
"target",
"create",
"struct",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Validator/LayoutResolverValidator.php#L142-L160 | train |
netgen-layouts/layouts-core | lib/Core/Validator/LayoutResolverValidator.php | LayoutResolverValidator.validateTargetUpdateStruct | public function validateTargetUpdateStruct(Target $target, TargetUpdateStruct $targetUpdateStruct): void
{
$targetType = $target->getTargetType();
$this->validate(
$targetUpdateStruct->value,
$targetType->getConstraints(),
'value'
);
} | php | public function validateTargetUpdateStruct(Target $target, TargetUpdateStruct $targetUpdateStruct): void
{
$targetType = $target->getTargetType();
$this->validate(
$targetUpdateStruct->value,
$targetType->getConstraints(),
'value'
);
} | [
"public",
"function",
"validateTargetUpdateStruct",
"(",
"Target",
"$",
"target",
",",
"TargetUpdateStruct",
"$",
"targetUpdateStruct",
")",
":",
"void",
"{",
"$",
"targetType",
"=",
"$",
"target",
"->",
"getTargetType",
"(",
")",
";",
"$",
"this",
"->",
"vali... | Validates the provided target update struct.
@throws \Netgen\BlockManager\Exception\Validation\ValidationException If the validation failed | [
"Validates",
"the",
"provided",
"target",
"update",
"struct",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Validator/LayoutResolverValidator.php#L167-L176 | train |
netgen-layouts/layouts-core | lib/Core/Validator/LayoutResolverValidator.php | LayoutResolverValidator.validateConditionCreateStruct | public function validateConditionCreateStruct(ConditionCreateStruct $conditionCreateStruct): void
{
$this->validate(
$conditionCreateStruct->type,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'string']),
],
'type'
);
$conditionType = $this->conditionTypeRegistry->getConditionType($conditionCreateStruct->type);
$this->validate(
$conditionCreateStruct->value,
$conditionType->getConstraints(),
'value'
);
} | php | public function validateConditionCreateStruct(ConditionCreateStruct $conditionCreateStruct): void
{
$this->validate(
$conditionCreateStruct->type,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'string']),
],
'type'
);
$conditionType = $this->conditionTypeRegistry->getConditionType($conditionCreateStruct->type);
$this->validate(
$conditionCreateStruct->value,
$conditionType->getConstraints(),
'value'
);
} | [
"public",
"function",
"validateConditionCreateStruct",
"(",
"ConditionCreateStruct",
"$",
"conditionCreateStruct",
")",
":",
"void",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"conditionCreateStruct",
"->",
"type",
",",
"[",
"new",
"Constraints",
"\\",
"NotBlank"... | Validates the provided condition create struct.
@throws \Netgen\BlockManager\Exception\Validation\ValidationException If the validation failed | [
"Validates",
"the",
"provided",
"condition",
"create",
"struct",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Validator/LayoutResolverValidator.php#L183-L201 | train |
netgen-layouts/layouts-core | lib/Core/Validator/LayoutResolverValidator.php | LayoutResolverValidator.validateConditionUpdateStruct | public function validateConditionUpdateStruct(Condition $condition, ConditionUpdateStruct $conditionUpdateStruct): void
{
$conditionType = $condition->getConditionType();
$this->validate(
$conditionUpdateStruct->value,
$conditionType->getConstraints(),
'value'
);
} | php | public function validateConditionUpdateStruct(Condition $condition, ConditionUpdateStruct $conditionUpdateStruct): void
{
$conditionType = $condition->getConditionType();
$this->validate(
$conditionUpdateStruct->value,
$conditionType->getConstraints(),
'value'
);
} | [
"public",
"function",
"validateConditionUpdateStruct",
"(",
"Condition",
"$",
"condition",
",",
"ConditionUpdateStruct",
"$",
"conditionUpdateStruct",
")",
":",
"void",
"{",
"$",
"conditionType",
"=",
"$",
"condition",
"->",
"getConditionType",
"(",
")",
";",
"$",
... | Validates the provided condition update struct.
@throws \Netgen\BlockManager\Exception\Validation\ValidationException If the validation failed | [
"Validates",
"the",
"provided",
"condition",
"update",
"struct",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Validator/LayoutResolverValidator.php#L208-L217 | train |
netgen-layouts/layouts-core | lib/Core/Mapper/LayoutMapper.php | LayoutMapper.mapZone | public function mapZone(PersistenceZone $zone): Zone
{
$zoneData = [
'identifier' => $zone->identifier,
'layoutId' => $zone->layoutId,
'status' => $zone->status,
'linkedZone' => function () use ($zone): ?Zone {
if ($zone->linkedLayoutId === null || $zone->linkedZoneIdentifier === null) {
return null;
}
try {
// We're always using published versions of linked zones
$linkedZone = $this->layoutHandler->loadZone(
$zone->linkedLayoutId,
PersistenceValue::STATUS_PUBLISHED,
$zone->linkedZoneIdentifier
);
return $this->mapZone($linkedZone);
} catch (NotFoundException $e) {
return null;
}
},
];
return Zone::fromArray($zoneData);
} | php | public function mapZone(PersistenceZone $zone): Zone
{
$zoneData = [
'identifier' => $zone->identifier,
'layoutId' => $zone->layoutId,
'status' => $zone->status,
'linkedZone' => function () use ($zone): ?Zone {
if ($zone->linkedLayoutId === null || $zone->linkedZoneIdentifier === null) {
return null;
}
try {
// We're always using published versions of linked zones
$linkedZone = $this->layoutHandler->loadZone(
$zone->linkedLayoutId,
PersistenceValue::STATUS_PUBLISHED,
$zone->linkedZoneIdentifier
);
return $this->mapZone($linkedZone);
} catch (NotFoundException $e) {
return null;
}
},
];
return Zone::fromArray($zoneData);
} | [
"public",
"function",
"mapZone",
"(",
"PersistenceZone",
"$",
"zone",
")",
":",
"Zone",
"{",
"$",
"zoneData",
"=",
"[",
"'identifier'",
"=>",
"$",
"zone",
"->",
"identifier",
",",
"'layoutId'",
"=>",
"$",
"zone",
"->",
"layoutId",
",",
"'status'",
"=>",
... | Builds the API zone value from persistence one. | [
"Builds",
"the",
"API",
"zone",
"value",
"from",
"persistence",
"one",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Mapper/LayoutMapper.php#L41-L68 | train |
netgen-layouts/layouts-core | lib/Core/Mapper/LayoutMapper.php | LayoutMapper.mapLayout | public function mapLayout(PersistenceLayout $layout): Layout
{
try {
$layoutType = $this->layoutTypeRegistry->getLayoutType($layout->type);
} catch (LayoutTypeException $e) {
$layoutType = new NullLayoutType($layout->type);
}
$layoutData = [
'id' => $layout->id,
'layoutType' => $layoutType,
'name' => $layout->name,
'description' => $layout->description,
'created' => DateTimeUtils::createFromTimestamp($layout->created),
'modified' => DateTimeUtils::createFromTimestamp($layout->modified),
'status' => $layout->status,
'shared' => $layout->shared,
'mainLocale' => $layout->mainLocale,
'availableLocales' => $layout->availableLocales,
'zones' => new LazyCollection(
function () use ($layout): array {
return array_map(
function (PersistenceZone $zone): Zone {
return $this->mapZone($zone);
},
$this->layoutHandler->loadLayoutZones($layout)
);
}
),
];
return Layout::fromArray($layoutData);
} | php | public function mapLayout(PersistenceLayout $layout): Layout
{
try {
$layoutType = $this->layoutTypeRegistry->getLayoutType($layout->type);
} catch (LayoutTypeException $e) {
$layoutType = new NullLayoutType($layout->type);
}
$layoutData = [
'id' => $layout->id,
'layoutType' => $layoutType,
'name' => $layout->name,
'description' => $layout->description,
'created' => DateTimeUtils::createFromTimestamp($layout->created),
'modified' => DateTimeUtils::createFromTimestamp($layout->modified),
'status' => $layout->status,
'shared' => $layout->shared,
'mainLocale' => $layout->mainLocale,
'availableLocales' => $layout->availableLocales,
'zones' => new LazyCollection(
function () use ($layout): array {
return array_map(
function (PersistenceZone $zone): Zone {
return $this->mapZone($zone);
},
$this->layoutHandler->loadLayoutZones($layout)
);
}
),
];
return Layout::fromArray($layoutData);
} | [
"public",
"function",
"mapLayout",
"(",
"PersistenceLayout",
"$",
"layout",
")",
":",
"Layout",
"{",
"try",
"{",
"$",
"layoutType",
"=",
"$",
"this",
"->",
"layoutTypeRegistry",
"->",
"getLayoutType",
"(",
"$",
"layout",
"->",
"type",
")",
";",
"}",
"catch... | Builds the API layout value from persistence one. | [
"Builds",
"the",
"API",
"layout",
"value",
"from",
"persistence",
"one",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Mapper/LayoutMapper.php#L73-L105 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.loadRuleData | public function loadRuleData($ruleId, int $status): array
{
$query = $this->getRuleSelectQuery();
$query->where(
$query->expr()->eq('r.id', ':id')
)
->setParameter('id', $ruleId, Type::INTEGER);
$this->applyStatusCondition($query, $status, 'r.status');
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | php | public function loadRuleData($ruleId, int $status): array
{
$query = $this->getRuleSelectQuery();
$query->where(
$query->expr()->eq('r.id', ':id')
)
->setParameter('id', $ruleId, Type::INTEGER);
$this->applyStatusCondition($query, $status, 'r.status');
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | [
"public",
"function",
"loadRuleData",
"(",
"$",
"ruleId",
",",
"int",
"$",
"status",
")",
":",
"array",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getRuleSelectQuery",
"(",
")",
";",
"$",
"query",
"->",
"where",
"(",
"$",
"query",
"->",
"expr",
"(",... | Returns all data for specified rule.
@param int|string $ruleId
@param int $status
@return array | [
"Returns",
"all",
"data",
"for",
"specified",
"rule",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L51-L62 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.loadRulesData | public function loadRulesData(int $status, ?Layout $layout = null, int $offset = 0, ?int $limit = null): array
{
$query = $this->getRuleSelectQuery();
if ($layout instanceof Layout) {
$query->andWhere(
$query->expr()->eq('layout_id', ':layout_id')
)
->setParameter('layout_id', $layout->id, Type::INTEGER);
}
$query->addOrderBy('rd.priority', 'DESC');
$this->applyStatusCondition($query, $status, 'r.status');
$this->applyOffsetAndLimit($query, $offset, $limit);
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | php | public function loadRulesData(int $status, ?Layout $layout = null, int $offset = 0, ?int $limit = null): array
{
$query = $this->getRuleSelectQuery();
if ($layout instanceof Layout) {
$query->andWhere(
$query->expr()->eq('layout_id', ':layout_id')
)
->setParameter('layout_id', $layout->id, Type::INTEGER);
}
$query->addOrderBy('rd.priority', 'DESC');
$this->applyStatusCondition($query, $status, 'r.status');
$this->applyOffsetAndLimit($query, $offset, $limit);
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | [
"public",
"function",
"loadRulesData",
"(",
"int",
"$",
"status",
",",
"?",
"Layout",
"$",
"layout",
"=",
"null",
",",
"int",
"$",
"offset",
"=",
"0",
",",
"?",
"int",
"$",
"limit",
"=",
"null",
")",
":",
"array",
"{",
"$",
"query",
"=",
"$",
"th... | Returns all data for all rules. | [
"Returns",
"all",
"data",
"for",
"all",
"rules",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L67-L84 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.getRuleCount | public function getRuleCount(int $ruleStatus, ?Layout $layout = null): int
{
$query = $this->connection->createQueryBuilder();
$query->select('count(*) AS count')
->from('ngbm_rule');
if ($layout instanceof Layout) {
$query->andWhere(
$query->expr()->eq('layout_id', ':layout_id')
)
->setParameter('layout_id', $layout->id, Type::INTEGER);
}
$this->applyStatusCondition($query, $ruleStatus);
$data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
return (int) ($data[0]['count'] ?? 0);
} | php | public function getRuleCount(int $ruleStatus, ?Layout $layout = null): int
{
$query = $this->connection->createQueryBuilder();
$query->select('count(*) AS count')
->from('ngbm_rule');
if ($layout instanceof Layout) {
$query->andWhere(
$query->expr()->eq('layout_id', ':layout_id')
)
->setParameter('layout_id', $layout->id, Type::INTEGER);
}
$this->applyStatusCondition($query, $ruleStatus);
$data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
return (int) ($data[0]['count'] ?? 0);
} | [
"public",
"function",
"getRuleCount",
"(",
"int",
"$",
"ruleStatus",
",",
"?",
"Layout",
"$",
"layout",
"=",
"null",
")",
":",
"int",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->"... | Returns the number of rules. | [
"Returns",
"the",
"number",
"of",
"rules",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L89-L107 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.matchRules | public function matchRules(string $targetType, $targetValue): array
{
$query = $this->getRuleSelectQuery();
$query
->innerJoin(
'r',
'ngbm_rule_target',
'rt',
$query->expr()->eq('r.id', 'rt.rule_id')
)
->where(
$query->expr()->eq('rd.enabled', ':enabled'),
$query->expr()->eq('rt.type', ':target_type')
)
->setParameter('target_type', $targetType, Type::STRING)
->setParameter('enabled', true, Type::BOOLEAN)
->addOrderBy('rd.priority', 'DESC');
$this->applyStatusCondition($query, Value::STATUS_PUBLISHED, 'r.status');
$this->applyStatusCondition($query, Value::STATUS_PUBLISHED, 'rt.status');
if (!isset($this->targetHandlers[$targetType])) {
throw TargetHandlerException::noTargetHandler('Doctrine', $targetType);
}
$this->targetHandlers[$targetType]->handleQuery($query, $targetValue);
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | php | public function matchRules(string $targetType, $targetValue): array
{
$query = $this->getRuleSelectQuery();
$query
->innerJoin(
'r',
'ngbm_rule_target',
'rt',
$query->expr()->eq('r.id', 'rt.rule_id')
)
->where(
$query->expr()->eq('rd.enabled', ':enabled'),
$query->expr()->eq('rt.type', ':target_type')
)
->setParameter('target_type', $targetType, Type::STRING)
->setParameter('enabled', true, Type::BOOLEAN)
->addOrderBy('rd.priority', 'DESC');
$this->applyStatusCondition($query, Value::STATUS_PUBLISHED, 'r.status');
$this->applyStatusCondition($query, Value::STATUS_PUBLISHED, 'rt.status');
if (!isset($this->targetHandlers[$targetType])) {
throw TargetHandlerException::noTargetHandler('Doctrine', $targetType);
}
$this->targetHandlers[$targetType]->handleQuery($query, $targetValue);
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | [
"public",
"function",
"matchRules",
"(",
"string",
"$",
"targetType",
",",
"$",
"targetValue",
")",
":",
"array",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getRuleSelectQuery",
"(",
")",
";",
"$",
"query",
"->",
"innerJoin",
"(",
"'r'",
",",
"'ngbm_rul... | Returns all rule data for rules that match specified target type and value.
@param string $targetType
@param mixed $targetValue
@return array | [
"Returns",
"all",
"rule",
"data",
"for",
"rules",
"that",
"match",
"specified",
"target",
"type",
"and",
"value",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L117-L145 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.loadTargetData | public function loadTargetData($targetId, int $status): array
{
$query = $this->getTargetSelectQuery();
$query->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $targetId, Type::INTEGER);
$this->applyStatusCondition($query, $status);
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | php | public function loadTargetData($targetId, int $status): array
{
$query = $this->getTargetSelectQuery();
$query->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $targetId, Type::INTEGER);
$this->applyStatusCondition($query, $status);
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | [
"public",
"function",
"loadTargetData",
"(",
"$",
"targetId",
",",
"int",
"$",
"status",
")",
":",
"array",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getTargetSelectQuery",
"(",
")",
";",
"$",
"query",
"->",
"where",
"(",
"$",
"query",
"->",
"expr",
... | Returns all data for specified target.
@param int|string $targetId
@param int $status
@return array | [
"Returns",
"all",
"data",
"for",
"specified",
"target",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L155-L166 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.loadRuleTargetsData | public function loadRuleTargetsData(Rule $rule): array
{
$query = $this->getTargetSelectQuery();
$query->where(
$query->expr()->eq('rule_id', ':rule_id')
)
->setParameter('rule_id', $rule->id, Type::INTEGER)
->orderBy('id', 'ASC');
$this->applyStatusCondition($query, $rule->status);
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | php | public function loadRuleTargetsData(Rule $rule): array
{
$query = $this->getTargetSelectQuery();
$query->where(
$query->expr()->eq('rule_id', ':rule_id')
)
->setParameter('rule_id', $rule->id, Type::INTEGER)
->orderBy('id', 'ASC');
$this->applyStatusCondition($query, $rule->status);
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | [
"public",
"function",
"loadRuleTargetsData",
"(",
"Rule",
"$",
"rule",
")",
":",
"array",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getTargetSelectQuery",
"(",
")",
";",
"$",
"query",
"->",
"where",
"(",
"$",
"query",
"->",
"expr",
"(",
")",
"->",
... | Returns all data for all rule targets. | [
"Returns",
"all",
"data",
"for",
"all",
"rule",
"targets",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L171-L183 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.getTargetCount | public function getTargetCount(Rule $rule): int
{
$query = $this->connection->createQueryBuilder();
$query->select('count(*) AS count')
->from('ngbm_rule_target')
->where(
$query->expr()->eq('rule_id', ':rule_id')
)
->setParameter('rule_id', $rule->id, Type::INTEGER);
$this->applyStatusCondition($query, $rule->status);
$data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
return (int) ($data[0]['count'] ?? 0);
} | php | public function getTargetCount(Rule $rule): int
{
$query = $this->connection->createQueryBuilder();
$query->select('count(*) AS count')
->from('ngbm_rule_target')
->where(
$query->expr()->eq('rule_id', ':rule_id')
)
->setParameter('rule_id', $rule->id, Type::INTEGER);
$this->applyStatusCondition($query, $rule->status);
$data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
return (int) ($data[0]['count'] ?? 0);
} | [
"public",
"function",
"getTargetCount",
"(",
"Rule",
"$",
"rule",
")",
":",
"int",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"select",
"(",
"'count(*) AS count'",
")",
"->",
"f... | Returns the number of targets within the rule. | [
"Returns",
"the",
"number",
"of",
"targets",
"within",
"the",
"rule",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L188-L203 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.loadConditionData | public function loadConditionData($conditionId, int $status): array
{
$query = $this->getConditionSelectQuery();
$query->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $conditionId, Type::INTEGER);
$this->applyStatusCondition($query, $status);
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | php | public function loadConditionData($conditionId, int $status): array
{
$query = $this->getConditionSelectQuery();
$query->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $conditionId, Type::INTEGER);
$this->applyStatusCondition($query, $status);
return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
} | [
"public",
"function",
"loadConditionData",
"(",
"$",
"conditionId",
",",
"int",
"$",
"status",
")",
":",
"array",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getConditionSelectQuery",
"(",
")",
";",
"$",
"query",
"->",
"where",
"(",
"$",
"query",
"->",
... | Returns all data for specified condition.
@param int|string $conditionId
@param int $status
@return array | [
"Returns",
"all",
"data",
"for",
"specified",
"condition",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L213-L224 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.getLowestRulePriority | public function getLowestRulePriority(): ?int
{
$query = $this->connection->createQueryBuilder();
$query->select('priority')
->from('ngbm_rule_data');
$query->addOrderBy('priority', 'ASC');
$this->applyOffsetAndLimit($query, 0, 1);
$data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
return isset($data[0]['priority']) ? (int) $data[0]['priority'] : null;
} | php | public function getLowestRulePriority(): ?int
{
$query = $this->connection->createQueryBuilder();
$query->select('priority')
->from('ngbm_rule_data');
$query->addOrderBy('priority', 'ASC');
$this->applyOffsetAndLimit($query, 0, 1);
$data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
return isset($data[0]['priority']) ? (int) $data[0]['priority'] : null;
} | [
"public",
"function",
"getLowestRulePriority",
"(",
")",
":",
"?",
"int",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"select",
"(",
"'priority'",
")",
"->",
"from",
"(",
"'ngbm_... | Returns the lowest priority from the list of all the rules. | [
"Returns",
"the",
"lowest",
"priority",
"from",
"the",
"list",
"of",
"all",
"the",
"rules",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L273-L285 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.updateRule | public function updateRule(Rule $rule): void
{
$query = $this->connection->createQueryBuilder();
$query
->update('ngbm_rule')
->set('layout_id', ':layout_id')
->set('comment', ':comment')
->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $rule->id, Type::INTEGER)
->setParameter('layout_id', $rule->layoutId, Type::INTEGER)
->setParameter('comment', $rule->comment, Type::STRING);
$this->applyStatusCondition($query, $rule->status);
$query->execute();
} | php | public function updateRule(Rule $rule): void
{
$query = $this->connection->createQueryBuilder();
$query
->update('ngbm_rule')
->set('layout_id', ':layout_id')
->set('comment', ':comment')
->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $rule->id, Type::INTEGER)
->setParameter('layout_id', $rule->layoutId, Type::INTEGER)
->setParameter('comment', $rule->comment, Type::STRING);
$this->applyStatusCondition($query, $rule->status);
$query->execute();
} | [
"public",
"function",
"updateRule",
"(",
"Rule",
"$",
"rule",
")",
":",
"void",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"update",
"(",
"'ngbm_rule'",
")",
"->",
"set",
"(",... | Updates a rule. | [
"Updates",
"a",
"rule",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L339-L356 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.updateRuleData | public function updateRuleData(Rule $rule): void
{
$query = $this->connection->createQueryBuilder();
$query
->update('ngbm_rule_data')
->set('enabled', ':enabled')
->set('priority', ':priority')
->where(
$query->expr()->eq('rule_id', ':rule_id')
)
->setParameter('rule_id', $rule->id, Type::INTEGER)
->setParameter('enabled', $rule->enabled, Type::BOOLEAN)
->setParameter('priority', $rule->priority, Type::INTEGER);
$query->execute();
} | php | public function updateRuleData(Rule $rule): void
{
$query = $this->connection->createQueryBuilder();
$query
->update('ngbm_rule_data')
->set('enabled', ':enabled')
->set('priority', ':priority')
->where(
$query->expr()->eq('rule_id', ':rule_id')
)
->setParameter('rule_id', $rule->id, Type::INTEGER)
->setParameter('enabled', $rule->enabled, Type::BOOLEAN)
->setParameter('priority', $rule->priority, Type::INTEGER);
$query->execute();
} | [
"public",
"function",
"updateRuleData",
"(",
"Rule",
"$",
"rule",
")",
":",
"void",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"update",
"(",
"'ngbm_rule_data'",
")",
"->",
"set... | Updates rule data which is independent of statuses. | [
"Updates",
"rule",
"data",
"which",
"is",
"independent",
"of",
"statuses",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L361-L376 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.addTarget | public function addTarget(Target $target): Target
{
$query = $this->connection->createQueryBuilder()
->insert('ngbm_rule_target')
->values(
[
'id' => ':id',
'status' => ':status',
'rule_id' => ':rule_id',
'type' => ':type',
'value' => ':value',
]
)
->setValue(
'id',
$target->id !== null ?
(int) $target->id :
$this->connectionHelper->getAutoIncrementValue('ngbm_rule_target')
)
->setParameter('status', $target->status, Type::INTEGER)
->setParameter('rule_id', $target->ruleId, Type::INTEGER)
->setParameter('type', $target->type, Type::STRING)
->setParameter('value', $target->value, is_array($target->value) ? Type::JSON_ARRAY : Type::STRING);
$query->execute();
$target->id = $target->id ?? (int) $this->connectionHelper->lastInsertId('ngbm_rule_target');
return $target;
} | php | public function addTarget(Target $target): Target
{
$query = $this->connection->createQueryBuilder()
->insert('ngbm_rule_target')
->values(
[
'id' => ':id',
'status' => ':status',
'rule_id' => ':rule_id',
'type' => ':type',
'value' => ':value',
]
)
->setValue(
'id',
$target->id !== null ?
(int) $target->id :
$this->connectionHelper->getAutoIncrementValue('ngbm_rule_target')
)
->setParameter('status', $target->status, Type::INTEGER)
->setParameter('rule_id', $target->ruleId, Type::INTEGER)
->setParameter('type', $target->type, Type::STRING)
->setParameter('value', $target->value, is_array($target->value) ? Type::JSON_ARRAY : Type::STRING);
$query->execute();
$target->id = $target->id ?? (int) $this->connectionHelper->lastInsertId('ngbm_rule_target');
return $target;
} | [
"public",
"function",
"addTarget",
"(",
"Target",
"$",
"target",
")",
":",
"Target",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
"->",
"insert",
"(",
"'ngbm_rule_target'",
")",
"->",
"values",
"(",
"[",
... | Adds a target. | [
"Adds",
"a",
"target",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L460-L489 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.updateTarget | public function updateTarget(Target $target): void
{
$query = $this->connection->createQueryBuilder();
$query
->update('ngbm_rule_target')
->set('rule_id', ':rule_id')
->set('type', ':type')
->set('value', ':value')
->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $target->id, Type::INTEGER)
->setParameter('rule_id', $target->ruleId, Type::INTEGER)
->setParameter('type', $target->type, Type::STRING)
->setParameter('value', $target->value, is_array($target->value) ? Type::JSON_ARRAY : Type::STRING);
$this->applyStatusCondition($query, $target->status);
$query->execute();
} | php | public function updateTarget(Target $target): void
{
$query = $this->connection->createQueryBuilder();
$query
->update('ngbm_rule_target')
->set('rule_id', ':rule_id')
->set('type', ':type')
->set('value', ':value')
->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $target->id, Type::INTEGER)
->setParameter('rule_id', $target->ruleId, Type::INTEGER)
->setParameter('type', $target->type, Type::STRING)
->setParameter('value', $target->value, is_array($target->value) ? Type::JSON_ARRAY : Type::STRING);
$this->applyStatusCondition($query, $target->status);
$query->execute();
} | [
"public",
"function",
"updateTarget",
"(",
"Target",
"$",
"target",
")",
":",
"void",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"update",
"(",
"'ngbm_rule_target'",
")",
"->",
... | Updates a target. | [
"Updates",
"a",
"target",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L494-L513 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.addCondition | public function addCondition(Condition $condition): Condition
{
$query = $this->connection->createQueryBuilder()
->insert('ngbm_rule_condition')
->values(
[
'id' => ':id',
'status' => ':status',
'rule_id' => ':rule_id',
'type' => ':type',
'value' => ':value',
]
)
->setValue(
'id',
$condition->id !== null ?
(int) $condition->id :
$this->connectionHelper->getAutoIncrementValue('ngbm_rule_condition')
)
->setParameter('status', $condition->status, Type::INTEGER)
->setParameter('rule_id', $condition->ruleId, Type::INTEGER)
->setParameter('type', $condition->type, Type::STRING)
->setParameter('value', json_encode($condition->value), Type::STRING);
$query->execute();
$condition->id = $condition->id ?? (int) $this->connectionHelper->lastInsertId('ngbm_rule_condition');
return $condition;
} | php | public function addCondition(Condition $condition): Condition
{
$query = $this->connection->createQueryBuilder()
->insert('ngbm_rule_condition')
->values(
[
'id' => ':id',
'status' => ':status',
'rule_id' => ':rule_id',
'type' => ':type',
'value' => ':value',
]
)
->setValue(
'id',
$condition->id !== null ?
(int) $condition->id :
$this->connectionHelper->getAutoIncrementValue('ngbm_rule_condition')
)
->setParameter('status', $condition->status, Type::INTEGER)
->setParameter('rule_id', $condition->ruleId, Type::INTEGER)
->setParameter('type', $condition->type, Type::STRING)
->setParameter('value', json_encode($condition->value), Type::STRING);
$query->execute();
$condition->id = $condition->id ?? (int) $this->connectionHelper->lastInsertId('ngbm_rule_condition');
return $condition;
} | [
"public",
"function",
"addCondition",
"(",
"Condition",
"$",
"condition",
")",
":",
"Condition",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
"->",
"insert",
"(",
"'ngbm_rule_condition'",
")",
"->",
"values",
... | Adds a condition. | [
"Adds",
"a",
"condition",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L539-L568 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.updateCondition | public function updateCondition(Condition $condition): void
{
$query = $this->connection->createQueryBuilder();
$query
->update('ngbm_rule_condition')
->set('rule_id', ':rule_id')
->set('type', ':type')
->set('value', ':value')
->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $condition->id, Type::INTEGER)
->setParameter('rule_id', $condition->ruleId, Type::INTEGER)
->setParameter('type', $condition->type, Type::STRING)
->setParameter('value', json_encode($condition->value), Type::STRING);
$this->applyStatusCondition($query, $condition->status);
$query->execute();
} | php | public function updateCondition(Condition $condition): void
{
$query = $this->connection->createQueryBuilder();
$query
->update('ngbm_rule_condition')
->set('rule_id', ':rule_id')
->set('type', ':type')
->set('value', ':value')
->where(
$query->expr()->eq('id', ':id')
)
->setParameter('id', $condition->id, Type::INTEGER)
->setParameter('rule_id', $condition->ruleId, Type::INTEGER)
->setParameter('type', $condition->type, Type::STRING)
->setParameter('value', json_encode($condition->value), Type::STRING);
$this->applyStatusCondition($query, $condition->status);
$query->execute();
} | [
"public",
"function",
"updateCondition",
"(",
"Condition",
"$",
"condition",
")",
":",
"void",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"update",
"(",
"'ngbm_rule_condition'",
")"... | Updates a condition. | [
"Updates",
"a",
"condition",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L573-L592 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.getRuleSelectQuery | private function getRuleSelectQuery(): QueryBuilder
{
$query = $this->connection->createQueryBuilder();
$query->select('DISTINCT r.*', 'rd.*')
->from('ngbm_rule', 'r')
->innerJoin(
'r',
'ngbm_rule_data',
'rd',
$query->expr()->eq('rd.rule_id', 'r.id')
);
return $query;
} | php | private function getRuleSelectQuery(): QueryBuilder
{
$query = $this->connection->createQueryBuilder();
$query->select('DISTINCT r.*', 'rd.*')
->from('ngbm_rule', 'r')
->innerJoin(
'r',
'ngbm_rule_data',
'rd',
$query->expr()->eq('rd.rule_id', 'r.id')
);
return $query;
} | [
"private",
"function",
"getRuleSelectQuery",
"(",
")",
":",
"QueryBuilder",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"select",
"(",
"'DISTINCT r.*'",
",",
"'rd.*'",
")",
"->",
"... | Builds and returns a rule database SELECT query. | [
"Builds",
"and",
"returns",
"a",
"rule",
"database",
"SELECT",
"query",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L618-L631 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.getTargetSelectQuery | private function getTargetSelectQuery(): QueryBuilder
{
$query = $this->connection->createQueryBuilder();
$query->select('DISTINCT ngbm_rule_target.*')
->from('ngbm_rule_target');
return $query;
} | php | private function getTargetSelectQuery(): QueryBuilder
{
$query = $this->connection->createQueryBuilder();
$query->select('DISTINCT ngbm_rule_target.*')
->from('ngbm_rule_target');
return $query;
} | [
"private",
"function",
"getTargetSelectQuery",
"(",
")",
":",
"QueryBuilder",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"select",
"(",
"'DISTINCT ngbm_rule_target.*'",
")",
"->",
"fr... | Builds and returns a target database SELECT query. | [
"Builds",
"and",
"returns",
"a",
"target",
"database",
"SELECT",
"query",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L636-L643 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php | LayoutResolverQueryHandler.getConditionSelectQuery | private function getConditionSelectQuery(): QueryBuilder
{
$query = $this->connection->createQueryBuilder();
$query->select('DISTINCT ngbm_rule_condition.*')
->from('ngbm_rule_condition');
return $query;
} | php | private function getConditionSelectQuery(): QueryBuilder
{
$query = $this->connection->createQueryBuilder();
$query->select('DISTINCT ngbm_rule_condition.*')
->from('ngbm_rule_condition');
return $query;
} | [
"private",
"function",
"getConditionSelectQuery",
"(",
")",
":",
"QueryBuilder",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"select",
"(",
"'DISTINCT ngbm_rule_condition.*'",
")",
"->",... | Builds and returns a condition database SELECT query. | [
"Builds",
"and",
"returns",
"a",
"condition",
"database",
"SELECT",
"query",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/QueryHandler/LayoutResolverQueryHandler.php#L648-L655 | train |
netgen-layouts/layouts-core | lib/API/Values/Layout/Layout.php | Layout.getZone | public function getZone(string $zoneIdentifier): APIZone
{
if ($this->hasZone($zoneIdentifier)) {
return $this->zones->get($zoneIdentifier);
}
throw LayoutException::noZone($zoneIdentifier);
} | php | public function getZone(string $zoneIdentifier): APIZone
{
if ($this->hasZone($zoneIdentifier)) {
return $this->zones->get($zoneIdentifier);
}
throw LayoutException::noZone($zoneIdentifier);
} | [
"public",
"function",
"getZone",
"(",
"string",
"$",
"zoneIdentifier",
")",
":",
"APIZone",
"{",
"if",
"(",
"$",
"this",
"->",
"hasZone",
"(",
"$",
"zoneIdentifier",
")",
")",
"{",
"return",
"$",
"this",
"->",
"zones",
"->",
"get",
"(",
"$",
"zoneIdent... | Returns the specified zone.
@throws \Netgen\BlockManager\Exception\API\LayoutException If the zone does not exist | [
"Returns",
"the",
"specified",
"zone",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/API/Values/Layout/Layout.php#L178-L185 | train |
netgen-layouts/layouts-core | lib/Core/Validator/LayoutValidator.php | LayoutValidator.validateLayoutCreateStruct | public function validateLayoutCreateStruct(LayoutCreateStruct $layoutCreateStruct): void
{
$layoutName = is_string($layoutCreateStruct->name) ?
trim($layoutCreateStruct->name) :
$layoutCreateStruct->name;
$this->validate(
$layoutName,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'string']),
],
'name'
);
if ($layoutCreateStruct->description !== null) {
$this->validate(
$layoutCreateStruct->description,
[
new Constraints\Type(['type' => 'string']),
],
'description'
);
}
$this->validate(
$layoutCreateStruct->layoutType,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => LayoutTypeInterface::class]),
],
'layoutType'
);
$this->validateLocale($layoutCreateStruct->mainLocale, 'mainLocale');
if ($layoutCreateStruct->shared !== null) {
$this->validate(
$layoutCreateStruct->shared,
[
new Constraints\Type(['type' => 'bool']),
],
'shared'
);
}
} | php | public function validateLayoutCreateStruct(LayoutCreateStruct $layoutCreateStruct): void
{
$layoutName = is_string($layoutCreateStruct->name) ?
trim($layoutCreateStruct->name) :
$layoutCreateStruct->name;
$this->validate(
$layoutName,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'string']),
],
'name'
);
if ($layoutCreateStruct->description !== null) {
$this->validate(
$layoutCreateStruct->description,
[
new Constraints\Type(['type' => 'string']),
],
'description'
);
}
$this->validate(
$layoutCreateStruct->layoutType,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => LayoutTypeInterface::class]),
],
'layoutType'
);
$this->validateLocale($layoutCreateStruct->mainLocale, 'mainLocale');
if ($layoutCreateStruct->shared !== null) {
$this->validate(
$layoutCreateStruct->shared,
[
new Constraints\Type(['type' => 'bool']),
],
'shared'
);
}
} | [
"public",
"function",
"validateLayoutCreateStruct",
"(",
"LayoutCreateStruct",
"$",
"layoutCreateStruct",
")",
":",
"void",
"{",
"$",
"layoutName",
"=",
"is_string",
"(",
"$",
"layoutCreateStruct",
"->",
"name",
")",
"?",
"trim",
"(",
"$",
"layoutCreateStruct",
"-... | Validates the provided layout create struct.
@throws \Netgen\BlockManager\Exception\Validation\ValidationException If the validation failed | [
"Validates",
"the",
"provided",
"layout",
"create",
"struct",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Validator/LayoutValidator.php#L23-L68 | train |
netgen-layouts/layouts-core | lib/Core/Validator/LayoutValidator.php | LayoutValidator.validateLayoutUpdateStruct | public function validateLayoutUpdateStruct(LayoutUpdateStruct $layoutUpdateStruct): void
{
$layoutName = is_string($layoutUpdateStruct->name) ?
trim($layoutUpdateStruct->name) :
$layoutUpdateStruct->name;
if ($layoutName !== null) {
$this->validate(
$layoutName,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'string']),
],
'name'
);
}
if ($layoutUpdateStruct->description !== null) {
$this->validate(
$layoutUpdateStruct->description,
[
new Constraints\Type(['type' => 'string']),
],
'description'
);
}
} | php | public function validateLayoutUpdateStruct(LayoutUpdateStruct $layoutUpdateStruct): void
{
$layoutName = is_string($layoutUpdateStruct->name) ?
trim($layoutUpdateStruct->name) :
$layoutUpdateStruct->name;
if ($layoutName !== null) {
$this->validate(
$layoutName,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'string']),
],
'name'
);
}
if ($layoutUpdateStruct->description !== null) {
$this->validate(
$layoutUpdateStruct->description,
[
new Constraints\Type(['type' => 'string']),
],
'description'
);
}
} | [
"public",
"function",
"validateLayoutUpdateStruct",
"(",
"LayoutUpdateStruct",
"$",
"layoutUpdateStruct",
")",
":",
"void",
"{",
"$",
"layoutName",
"=",
"is_string",
"(",
"$",
"layoutUpdateStruct",
"->",
"name",
")",
"?",
"trim",
"(",
"$",
"layoutUpdateStruct",
"-... | Validates the provided layout update struct.
@throws \Netgen\BlockManager\Exception\Validation\ValidationException If the validation failed | [
"Validates",
"the",
"provided",
"layout",
"update",
"struct",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Validator/LayoutValidator.php#L75-L101 | train |
netgen-layouts/layouts-core | lib/Core/Validator/LayoutValidator.php | LayoutValidator.validateLayoutCopyStruct | public function validateLayoutCopyStruct(LayoutCopyStruct $layoutCopyStruct): void
{
$layoutName = is_string($layoutCopyStruct->name) ?
trim($layoutCopyStruct->name) :
$layoutCopyStruct->name;
$this->validate(
$layoutName,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'string']),
],
'name'
);
if ($layoutCopyStruct->description !== null) {
$this->validate(
$layoutCopyStruct->description,
[
new Constraints\Type(['type' => 'string']),
],
'description'
);
}
} | php | public function validateLayoutCopyStruct(LayoutCopyStruct $layoutCopyStruct): void
{
$layoutName = is_string($layoutCopyStruct->name) ?
trim($layoutCopyStruct->name) :
$layoutCopyStruct->name;
$this->validate(
$layoutName,
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'string']),
],
'name'
);
if ($layoutCopyStruct->description !== null) {
$this->validate(
$layoutCopyStruct->description,
[
new Constraints\Type(['type' => 'string']),
],
'description'
);
}
} | [
"public",
"function",
"validateLayoutCopyStruct",
"(",
"LayoutCopyStruct",
"$",
"layoutCopyStruct",
")",
":",
"void",
"{",
"$",
"layoutName",
"=",
"is_string",
"(",
"$",
"layoutCopyStruct",
"->",
"name",
")",
"?",
"trim",
"(",
"$",
"layoutCopyStruct",
"->",
"nam... | Validates the provided layout copy struct.
@throws \Netgen\BlockManager\Exception\Validation\ValidationException If the validation failed | [
"Validates",
"the",
"provided",
"layout",
"copy",
"struct",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Validator/LayoutValidator.php#L108-L132 | train |
netgen-layouts/layouts-core | lib/Core/Validator/LayoutValidator.php | LayoutValidator.validateChangeLayoutType | public function validateChangeLayoutType(Layout $layout, LayoutTypeInterface $targetLayoutType, array $zoneMappings, bool $preserveSharedZones = true): void
{
$seenZones = [];
foreach ($zoneMappings as $newZone => $oldZones) {
if (!$targetLayoutType->hasZone($newZone)) {
throw ValidationException::validationFailed(
'zoneMappings',
sprintf(
'Zone "%s" does not exist in "%s" layout type.',
$newZone,
$targetLayoutType->getIdentifier()
)
);
}
if (!is_array($oldZones)) {
throw ValidationException::validationFailed(
'zoneMappings',
sprintf(
'The list of mapped zones for "%s" zone must be an array.',
$newZone
)
);
}
$oldLayoutZones = [];
foreach ($oldZones as $oldZone) {
if (in_array($oldZone, $seenZones, true)) {
throw ValidationException::validationFailed(
'zoneMappings',
sprintf(
'Zone "%s" is specified more than once.',
$oldZone
)
);
}
$seenZones[] = $oldZone;
$oldLayoutZones[] = $layout->getZone($oldZone);
}
if ($preserveSharedZones && count($oldLayoutZones) > 1) {
foreach ($oldLayoutZones as $oldZone) {
if ($oldZone->getLinkedZone() instanceof Zone) {
throw ValidationException::validationFailed(
'zoneMappings',
sprintf(
'When preserving shared layout zones, mapping for zone "%s" needs to be 1:1.',
$newZone
)
);
}
}
}
}
} | php | public function validateChangeLayoutType(Layout $layout, LayoutTypeInterface $targetLayoutType, array $zoneMappings, bool $preserveSharedZones = true): void
{
$seenZones = [];
foreach ($zoneMappings as $newZone => $oldZones) {
if (!$targetLayoutType->hasZone($newZone)) {
throw ValidationException::validationFailed(
'zoneMappings',
sprintf(
'Zone "%s" does not exist in "%s" layout type.',
$newZone,
$targetLayoutType->getIdentifier()
)
);
}
if (!is_array($oldZones)) {
throw ValidationException::validationFailed(
'zoneMappings',
sprintf(
'The list of mapped zones for "%s" zone must be an array.',
$newZone
)
);
}
$oldLayoutZones = [];
foreach ($oldZones as $oldZone) {
if (in_array($oldZone, $seenZones, true)) {
throw ValidationException::validationFailed(
'zoneMappings',
sprintf(
'Zone "%s" is specified more than once.',
$oldZone
)
);
}
$seenZones[] = $oldZone;
$oldLayoutZones[] = $layout->getZone($oldZone);
}
if ($preserveSharedZones && count($oldLayoutZones) > 1) {
foreach ($oldLayoutZones as $oldZone) {
if ($oldZone->getLinkedZone() instanceof Zone) {
throw ValidationException::validationFailed(
'zoneMappings',
sprintf(
'When preserving shared layout zones, mapping for zone "%s" needs to be 1:1.',
$newZone
)
);
}
}
}
}
} | [
"public",
"function",
"validateChangeLayoutType",
"(",
"Layout",
"$",
"layout",
",",
"LayoutTypeInterface",
"$",
"targetLayoutType",
",",
"array",
"$",
"zoneMappings",
",",
"bool",
"$",
"preserveSharedZones",
"=",
"true",
")",
":",
"void",
"{",
"$",
"seenZones",
... | Validates zone mappings for changing the provided layout type.
@throws \Netgen\BlockManager\Exception\Validation\ValidationException If the validation failed | [
"Validates",
"zone",
"mappings",
"for",
"changing",
"the",
"provided",
"layout",
"type",
"."
] | 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Validator/LayoutValidator.php#L139-L195 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.