repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
VincentChalnot/SidusEAVModelBundle
Doctrine/EAVFinder.php
EAVFinder.getQb
public function getQb(FamilyInterface $family, array $filterBy, array $orderBy = [], $alias = 'e') { $fixedFilterBy = []; foreach ($filterBy as $attributeCode => $value) { if (\is_array($value)) { $fixedFilterBy[] = [$attributeCode, 'in', $value]; } else { $fixedFilterBy[] = [$attributeCode, '=', $value]; } } return $this->getFilterByQb($family, $fixedFilterBy, $orderBy, $alias); }
php
public function getQb(FamilyInterface $family, array $filterBy, array $orderBy = [], $alias = 'e') { $fixedFilterBy = []; foreach ($filterBy as $attributeCode => $value) { if (\is_array($value)) { $fixedFilterBy[] = [$attributeCode, 'in', $value]; } else { $fixedFilterBy[] = [$attributeCode, '=', $value]; } } return $this->getFilterByQb($family, $fixedFilterBy, $orderBy, $alias); }
[ "public", "function", "getQb", "(", "FamilyInterface", "$", "family", ",", "array", "$", "filterBy", ",", "array", "$", "orderBy", "=", "[", "]", ",", "$", "alias", "=", "'e'", ")", "{", "$", "fixedFilterBy", "=", "[", "]", ";", "foreach", "(", "$", ...
@param FamilyInterface $family @param array $filterBy @param array $orderBy @param string $alias @throws \InvalidArgumentException @throws \UnexpectedValueException @throws \LogicException @throws MissingAttributeException @return QueryBuilder
[ "@param", "FamilyInterface", "$family", "@param", "array", "$filterBy", "@param", "array", "$orderBy", "@param", "string", "$alias" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Doctrine/EAVFinder.php#L238-L250
VincentChalnot/SidusEAVModelBundle
Serializer/Normalizer/AbstractGenericNormalizer.php
AbstractGenericNormalizer.normalize
public function normalize($object, $format = null, array $context = []) { $this->maxDepthHandler->handleMaxDepth($context); if ($this->byReferenceHandler->isByShortReference($context)) { return $this->getShortReference($object, $format, $context); } if ($this->byReferenceHandler->isByReference($context)) { return $this->getReference($object, $format, $context); } try { return parent::normalize($object, $format, $context); } catch (CircularReferenceException $e) { return $this->getShortReference($object, $format, $context); } }
php
public function normalize($object, $format = null, array $context = []) { $this->maxDepthHandler->handleMaxDepth($context); if ($this->byReferenceHandler->isByShortReference($context)) { return $this->getShortReference($object, $format, $context); } if ($this->byReferenceHandler->isByReference($context)) { return $this->getReference($object, $format, $context); } try { return parent::normalize($object, $format, $context); } catch (CircularReferenceException $e) { return $this->getShortReference($object, $format, $context); } }
[ "public", "function", "normalize", "(", "$", "object", ",", "$", "format", "=", "null", ",", "array", "$", "context", "=", "[", "]", ")", "{", "$", "this", "->", "maxDepthHandler", "->", "handleMaxDepth", "(", "$", "context", ")", ";", "if", "(", "$"...
{@inheritdoc} @throws \Symfony\Component\Serializer\Exception\RuntimeException
[ "{" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Serializer/Normalizer/AbstractGenericNormalizer.php#L60-L77
VincentChalnot/SidusEAVModelBundle
Event/EAVEvent.php
EAVEvent.getDataChangeset
public function getDataChangeset($forceRecompute = false) { if (null === $this->dataChangeset || $forceRecompute) { $this->computeDataChangeset(); } return $this->dataChangeset; }
php
public function getDataChangeset($forceRecompute = false) { if (null === $this->dataChangeset || $forceRecompute) { $this->computeDataChangeset(); } return $this->dataChangeset; }
[ "public", "function", "getDataChangeset", "(", "$", "forceRecompute", "=", "false", ")", "{", "if", "(", "null", "===", "$", "this", "->", "dataChangeset", "||", "$", "forceRecompute", ")", "{", "$", "this", "->", "computeDataChangeset", "(", ")", ";", "}"...
@param bool $forceRecompute @return array
[ "@param", "bool", "$forceRecompute" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Event/EAVEvent.php#L91-L98
VincentChalnot/SidusEAVModelBundle
Event/EAVEvent.php
EAVEvent.getValuesChangeset
public function getValuesChangeset($forceRecompute = false) { if (null === $this->valuesChangeset || $forceRecompute) { $this->computeValuesChangeset(); } return $this->valuesChangeset; }
php
public function getValuesChangeset($forceRecompute = false) { if (null === $this->valuesChangeset || $forceRecompute) { $this->computeValuesChangeset(); } return $this->valuesChangeset; }
[ "public", "function", "getValuesChangeset", "(", "$", "forceRecompute", "=", "false", ")", "{", "if", "(", "null", "===", "$", "this", "->", "valuesChangeset", "||", "$", "forceRecompute", ")", "{", "$", "this", "->", "computeValuesChangeset", "(", ")", ";",...
@param bool $forceRecompute @return ValueChangeset[]
[ "@param", "bool", "$forceRecompute" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Event/EAVEvent.php#L105-L112
VincentChalnot/SidusEAVModelBundle
Event/EAVEvent.php
EAVEvent.getAttributeChangeset
public function getAttributeChangeset(AttributeInterface $attribute) { if (!array_key_exists($attribute->getCode(), $this->getValuesChangeset())) { return []; } return $this->getValuesChangeset()[$attribute->getCode()]; }
php
public function getAttributeChangeset(AttributeInterface $attribute) { if (!array_key_exists($attribute->getCode(), $this->getValuesChangeset())) { return []; } return $this->getValuesChangeset()[$attribute->getCode()]; }
[ "public", "function", "getAttributeChangeset", "(", "AttributeInterface", "$", "attribute", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "attribute", "->", "getCode", "(", ")", ",", "$", "this", "->", "getValuesChangeset", "(", ")", ")", ")", "{",...
@param AttributeInterface $attribute @return ValueChangeset[]
[ "@param", "AttributeInterface", "$attribute" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Event/EAVEvent.php#L119-L126
VincentChalnot/SidusEAVModelBundle
Event/EAVEvent.php
EAVEvent.computeDataChangeset
protected function computeDataChangeset() { $uow = $this->entityManager->getUnitOfWork(); $this->dataChangeset = $uow->getEntityChangeSet($this->data); }
php
protected function computeDataChangeset() { $uow = $this->entityManager->getUnitOfWork(); $this->dataChangeset = $uow->getEntityChangeSet($this->data); }
[ "protected", "function", "computeDataChangeset", "(", ")", "{", "$", "uow", "=", "$", "this", "->", "entityManager", "->", "getUnitOfWork", "(", ")", ";", "$", "this", "->", "dataChangeset", "=", "$", "uow", "->", "getEntityChangeSet", "(", "$", "this", "-...
Compute the changeset of the entity
[ "Compute", "the", "changeset", "of", "the", "entity" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Event/EAVEvent.php#L172-L177
VincentChalnot/SidusEAVModelBundle
Event/EAVEvent.php
EAVEvent.computeValuesChangeset
protected function computeValuesChangeset() { $uow = $this->entityManager->getUnitOfWork(); $this->valuesChangeset = []; foreach ($this->changedValues as $state => $changedValues) { foreach ($changedValues as $changedValue) { $changeset = $uow->getEntityChangeSet($changedValue); $databaseType = $changedValue->getAttribute()->getType()->getDatabaseType(); if (!array_key_exists($databaseType, $changeset)) { throw new \LogicException('Change in value without change to value data'); } $valueChangeset = new ValueChangeset( $changedValue, $changeset[$databaseType][0], $state ); $uid = spl_object_hash($changedValue); $this->valuesChangeset[$changedValue->getAttributeCode()][$uid] = $valueChangeset; } } }
php
protected function computeValuesChangeset() { $uow = $this->entityManager->getUnitOfWork(); $this->valuesChangeset = []; foreach ($this->changedValues as $state => $changedValues) { foreach ($changedValues as $changedValue) { $changeset = $uow->getEntityChangeSet($changedValue); $databaseType = $changedValue->getAttribute()->getType()->getDatabaseType(); if (!array_key_exists($databaseType, $changeset)) { throw new \LogicException('Change in value without change to value data'); } $valueChangeset = new ValueChangeset( $changedValue, $changeset[$databaseType][0], $state ); $uid = spl_object_hash($changedValue); $this->valuesChangeset[$changedValue->getAttributeCode()][$uid] = $valueChangeset; } } }
[ "protected", "function", "computeValuesChangeset", "(", ")", "{", "$", "uow", "=", "$", "this", "->", "entityManager", "->", "getUnitOfWork", "(", ")", ";", "$", "this", "->", "valuesChangeset", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "cha...
Compute the changeset of the entity
[ "Compute", "the", "changeset", "of", "the", "entity" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Event/EAVEvent.php#L182-L204
VincentChalnot/SidusEAVModelBundle
Validator/Constraints/DataValidator.php
DataValidator.validate
public function validate($data, Constraint $constraint) { if (!$data instanceof $this->dataClass) { $class = \get_class($data); throw new \UnexpectedValueException("Can't validate data of class {$class}"); } $context = $this->context; // VERY IMPORTANT ! context will be lost otherwise foreach ($data->getFamily()->getAttributes() as $attribute) { if ($attribute->isRequired() && $data->isEmpty($attribute)) { $this->buildAttributeViolation( $data, $context, $attribute, 'required', $data->get($attribute->getCode()) ); } if ($attribute->isUnique()) { $this->checkUnique($context, $attribute, $data); } if ($attribute->getOption('allowed_families')) { $this->validateFamilies($context, $attribute, $data); } if (\count($attribute->getValidationRules())) { $this->validateRules($context, $attribute, $data); } } }
php
public function validate($data, Constraint $constraint) { if (!$data instanceof $this->dataClass) { $class = \get_class($data); throw new \UnexpectedValueException("Can't validate data of class {$class}"); } $context = $this->context; // VERY IMPORTANT ! context will be lost otherwise foreach ($data->getFamily()->getAttributes() as $attribute) { if ($attribute->isRequired() && $data->isEmpty($attribute)) { $this->buildAttributeViolation( $data, $context, $attribute, 'required', $data->get($attribute->getCode()) ); } if ($attribute->isUnique()) { $this->checkUnique($context, $attribute, $data); } if ($attribute->getOption('allowed_families')) { $this->validateFamilies($context, $attribute, $data); } if (\count($attribute->getValidationRules())) { $this->validateRules($context, $attribute, $data); } } }
[ "public", "function", "validate", "(", "$", "data", ",", "Constraint", "$", "constraint", ")", "{", "if", "(", "!", "$", "data", "instanceof", "$", "this", "->", "dataClass", ")", "{", "$", "class", "=", "\\", "get_class", "(", "$", "data", ")", ";",...
Checks if the passed value is valid. @param DataInterface $data The value that should be validated @param Constraint $constraint The constraint for the validation @throws Exception
[ "Checks", "if", "the", "passed", "value", "is", "valid", "." ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Validator/Constraints/DataValidator.php#L79-L108
VincentChalnot/SidusEAVModelBundle
Validator/Constraints/DataValidator.php
DataValidator.checkUnique
protected function checkUnique( ExecutionContextInterface $context, AttributeInterface $attribute, DataInterface $data ) { $family = $data->getFamily(); $valueData = $data->get($attribute->getCode()); if (null === $valueData) { // Do not check uniqueness for null values return; } $query = [ 'attributeCode' => $attribute->getCode(), 'familyCode' => $family->getCode(), $attribute->getType()->getDatabaseType() => $valueData, ]; if ($attribute->getOption('global_unique')) { unset($query['familyCode']); } if ($attribute->getOption('unique_families')) { $query['familyCode'] = $attribute->getOption('unique_families'); } /** @var ValueRepository $repo */ $repo = $this->entityManager->getRepository($family->getValueClass()); $values = $repo->findBy($query); /** @var ValueInterface $value */ foreach ($values as $value) { if (!$value->getData()) { $this->logger->critical( "Very weird Doctrine behavior: missing data for value #{$value->getIdentifier()}" ); continue; } if ($value->getData()->getId() !== $data->getId()) { $this->buildAttributeViolation($data, $context, $attribute, 'unique', $valueData); return; } } }
php
protected function checkUnique( ExecutionContextInterface $context, AttributeInterface $attribute, DataInterface $data ) { $family = $data->getFamily(); $valueData = $data->get($attribute->getCode()); if (null === $valueData) { // Do not check uniqueness for null values return; } $query = [ 'attributeCode' => $attribute->getCode(), 'familyCode' => $family->getCode(), $attribute->getType()->getDatabaseType() => $valueData, ]; if ($attribute->getOption('global_unique')) { unset($query['familyCode']); } if ($attribute->getOption('unique_families')) { $query['familyCode'] = $attribute->getOption('unique_families'); } /** @var ValueRepository $repo */ $repo = $this->entityManager->getRepository($family->getValueClass()); $values = $repo->findBy($query); /** @var ValueInterface $value */ foreach ($values as $value) { if (!$value->getData()) { $this->logger->critical( "Very weird Doctrine behavior: missing data for value #{$value->getIdentifier()}" ); continue; } if ($value->getData()->getId() !== $data->getId()) { $this->buildAttributeViolation($data, $context, $attribute, 'unique', $valueData); return; } } }
[ "protected", "function", "checkUnique", "(", "ExecutionContextInterface", "$", "context", ",", "AttributeInterface", "$", "attribute", ",", "DataInterface", "$", "data", ")", "{", "$", "family", "=", "$", "data", "->", "getFamily", "(", ")", ";", "$", "valueDa...
@param ExecutionContextInterface $context @param AttributeInterface $attribute @param DataInterface $data @throws Exception
[ "@param", "ExecutionContextInterface", "$context", "@param", "AttributeInterface", "$attribute", "@param", "DataInterface", "$data" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Validator/Constraints/DataValidator.php#L117-L160
VincentChalnot/SidusEAVModelBundle
Validator/Constraints/DataValidator.php
DataValidator.validateFamilies
protected function validateFamilies( ExecutionContextInterface $context, AttributeInterface $attribute, DataInterface $data ) { $allowedFamilies = []; $allowedFamilyCodes = $attribute->getOption('allowed_families'); if ($allowedFamilyCodes) { if (!\is_array($allowedFamilyCodes)) { $allowedFamilyCodes = [$allowedFamilyCodes]; } /** @var array $allowedFamilyCodes */ foreach ($allowedFamilyCodes as $familyCode) { $allowedFamilies[$familyCode] = $this->familyRegistry->getFamily($familyCode); } } if (0 === \count($allowedFamilies)) { return; } $valueData = $data->get($attribute->getCode()); if (null === $valueData) { return; } if (!$attribute->isCollection()) { $valueData = [$valueData]; } /** @var array $valueData */ foreach ($valueData as $value) { if (!$value instanceof DataInterface) { $this->buildAttributeViolation($data, $context, $attribute, 'invalid_data', $value); continue; } if (!array_key_exists($value->getFamilyCode(), $allowedFamilies)) { $this->buildAttributeViolation($data, $context, $attribute, 'invalid_family', $value); } } }
php
protected function validateFamilies( ExecutionContextInterface $context, AttributeInterface $attribute, DataInterface $data ) { $allowedFamilies = []; $allowedFamilyCodes = $attribute->getOption('allowed_families'); if ($allowedFamilyCodes) { if (!\is_array($allowedFamilyCodes)) { $allowedFamilyCodes = [$allowedFamilyCodes]; } /** @var array $allowedFamilyCodes */ foreach ($allowedFamilyCodes as $familyCode) { $allowedFamilies[$familyCode] = $this->familyRegistry->getFamily($familyCode); } } if (0 === \count($allowedFamilies)) { return; } $valueData = $data->get($attribute->getCode()); if (null === $valueData) { return; } if (!$attribute->isCollection()) { $valueData = [$valueData]; } /** @var array $valueData */ foreach ($valueData as $value) { if (!$value instanceof DataInterface) { $this->buildAttributeViolation($data, $context, $attribute, 'invalid_data', $value); continue; } if (!array_key_exists($value->getFamilyCode(), $allowedFamilies)) { $this->buildAttributeViolation($data, $context, $attribute, 'invalid_family', $value); } } }
[ "protected", "function", "validateFamilies", "(", "ExecutionContextInterface", "$", "context", ",", "AttributeInterface", "$", "attribute", ",", "DataInterface", "$", "data", ")", "{", "$", "allowedFamilies", "=", "[", "]", ";", "$", "allowedFamilyCodes", "=", "$"...
@param ExecutionContextInterface $context @param AttributeInterface $attribute @param DataInterface $data @throws \Sidus\EAVModelBundle\Exception\MissingFamilyException @throws \InvalidArgumentException @throws \Sidus\EAVModelBundle\Exception\ContextException @throws \Sidus\EAVModelBundle\Exception\InvalidValueDataException @throws \Sidus\EAVModelBundle\Exception\MissingAttributeException
[ "@param", "ExecutionContextInterface", "$context", "@param", "AttributeInterface", "$attribute", "@param", "DataInterface", "$data" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Validator/Constraints/DataValidator.php#L173-L211
VincentChalnot/SidusEAVModelBundle
Validator/Constraints/DataValidator.php
DataValidator.validateRules
protected function validateRules( ExecutionContextInterface $context, AttributeInterface $attribute, DataInterface $data ) { $valueData = $data->get($attribute->getCode()); $loader = new BaseLoader(); foreach ($loader->loadCustomConstraints($attribute->getValidationRules()) as $constraint) { $violations = $context->getValidator()->validate($valueData, $constraint, $context->getGroup()); /** @var ConstraintViolationInterface $violation */ foreach ($violations as $violation) { /** @noinspection DisconnectedForeachInstructionInspection */ $path = $attribute->getCode(); // If attribute is a relation this can lead to some weird error reporting but at least the path is right if ($attribute->getType()->isEmbedded() || $attribute->getType()->isRelation()) { if (!$attribute->isCollection()) { $path .= '.'; } $path .= $violation->getPropertyPath(); } if ($violation->getMessage()) { $context->buildViolation($violation->getMessage()) ->setTranslationDomain(false) ->atPath($path) ->setInvalidValue($valueData) ->addViolation(); } else { $this->buildAttributeViolation( $data, $context, $attribute, $this->getConstraintType($constraint), $valueData, $path ); } } } }
php
protected function validateRules( ExecutionContextInterface $context, AttributeInterface $attribute, DataInterface $data ) { $valueData = $data->get($attribute->getCode()); $loader = new BaseLoader(); foreach ($loader->loadCustomConstraints($attribute->getValidationRules()) as $constraint) { $violations = $context->getValidator()->validate($valueData, $constraint, $context->getGroup()); /** @var ConstraintViolationInterface $violation */ foreach ($violations as $violation) { /** @noinspection DisconnectedForeachInstructionInspection */ $path = $attribute->getCode(); // If attribute is a relation this can lead to some weird error reporting but at least the path is right if ($attribute->getType()->isEmbedded() || $attribute->getType()->isRelation()) { if (!$attribute->isCollection()) { $path .= '.'; } $path .= $violation->getPropertyPath(); } if ($violation->getMessage()) { $context->buildViolation($violation->getMessage()) ->setTranslationDomain(false) ->atPath($path) ->setInvalidValue($valueData) ->addViolation(); } else { $this->buildAttributeViolation( $data, $context, $attribute, $this->getConstraintType($constraint), $valueData, $path ); } } } }
[ "protected", "function", "validateRules", "(", "ExecutionContextInterface", "$", "context", ",", "AttributeInterface", "$", "attribute", ",", "DataInterface", "$", "data", ")", "{", "$", "valueData", "=", "$", "data", "->", "get", "(", "$", "attribute", "->", ...
@param ExecutionContextInterface $context @param AttributeInterface $attribute @param DataInterface $data @throws \Symfony\Component\Validator\Exception\MappingException @throws \InvalidArgumentException @throws \Sidus\EAVModelBundle\Exception\ContextException @throws \Sidus\EAVModelBundle\Exception\InvalidValueDataException @throws \Sidus\EAVModelBundle\Exception\MissingAttributeException @throws \ReflectionException
[ "@param", "ExecutionContextInterface", "$context", "@param", "AttributeInterface", "$attribute", "@param", "DataInterface", "$data" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Validator/Constraints/DataValidator.php#L225-L264
VincentChalnot/SidusEAVModelBundle
Validator/Constraints/DataValidator.php
DataValidator.buildAttributeViolation
protected function buildAttributeViolation( DataInterface $data, ExecutionContextInterface $context, AttributeInterface $attribute, $type, $invalidValue = null, $path = null ) { if (null === $path) { $path = $attribute->getCode(); } $context->buildViolation($this->buildMessage($data, $attribute, $type)) ->setTranslationDomain(false) ->atPath($path) ->setInvalidValue($invalidValue) ->addViolation(); }
php
protected function buildAttributeViolation( DataInterface $data, ExecutionContextInterface $context, AttributeInterface $attribute, $type, $invalidValue = null, $path = null ) { if (null === $path) { $path = $attribute->getCode(); } $context->buildViolation($this->buildMessage($data, $attribute, $type)) ->setTranslationDomain(false) ->atPath($path) ->setInvalidValue($invalidValue) ->addViolation(); }
[ "protected", "function", "buildAttributeViolation", "(", "DataInterface", "$", "data", ",", "ExecutionContextInterface", "$", "context", ",", "AttributeInterface", "$", "attribute", ",", "$", "type", ",", "$", "invalidValue", "=", "null", ",", "$", "path", "=", ...
@param DataInterface $data @param ExecutionContextInterface $context @param AttributeInterface $attribute @param string $type @param mixed $invalidValue @param string $path @throws \InvalidArgumentException
[ "@param", "DataInterface", "$data", "@param", "ExecutionContextInterface", "$context", "@param", "AttributeInterface", "$attribute", "@param", "string", "$type", "@param", "mixed", "$invalidValue", "@param", "string", "$path" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Validator/Constraints/DataValidator.php#L276-L292
VincentChalnot/SidusEAVModelBundle
Validator/Constraints/DataValidator.php
DataValidator.buildMessage
protected function buildMessage(DataInterface $data, AttributeInterface $attribute, $type) { return $this->tryTranslate( [ "eav.family.{$data->getFamilyCode()}.attribute.{$attribute->getCode()}.validation.{$type}", "eav.attribute.{$attribute->getCode()}.validation.{$type}", "eav.validation.{$type}", ], [ '%attribute%' => $this->translator->trans((string) $attribute), '%family%' => $this->translator->trans((string) $data->getFamily()), ], $type ); }
php
protected function buildMessage(DataInterface $data, AttributeInterface $attribute, $type) { return $this->tryTranslate( [ "eav.family.{$data->getFamilyCode()}.attribute.{$attribute->getCode()}.validation.{$type}", "eav.attribute.{$attribute->getCode()}.validation.{$type}", "eav.validation.{$type}", ], [ '%attribute%' => $this->translator->trans((string) $attribute), '%family%' => $this->translator->trans((string) $data->getFamily()), ], $type ); }
[ "protected", "function", "buildMessage", "(", "DataInterface", "$", "data", ",", "AttributeInterface", "$", "attribute", ",", "$", "type", ")", "{", "return", "$", "this", "->", "tryTranslate", "(", "[", "\"eav.family.{$data->getFamilyCode()}.attribute.{$attribute->getC...
@param DataInterface $data @param AttributeInterface $attribute @param string $type @throws \Symfony\Component\Translation\Exception\InvalidArgumentException @return string
[ "@param", "DataInterface", "$data", "@param", "AttributeInterface", "$attribute", "@param", "string", "$type" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Validator/Constraints/DataValidator.php#L303-L317
VincentChalnot/SidusEAVModelBundle
DependencyInjection/Configuration.php
Configuration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('sidus_eav_model'); /** @var NodeBuilder $attributeDefinition */ $attributeDefinition = $rootNode ->children() ->scalarNode('data_class')->isRequired()->end() ->scalarNode('value_class')->isRequired()->end() ->booleanNode('serializer_enabled')->defaultFalse()->end() ->scalarNode('collection_type')->defaultValue(CollectionType::class)->end() ->scalarNode('context_form_type')->defaultNull()->end() ->variableNode('default_context')->defaultValue([])->end() ->arrayNode('global_context_mask') ->prototype('scalar')->defaultValue([])->end() ->end() ->arrayNode('attributes') ->useAttributeAsKey('code') ->prototype('array') ->performNoDeepMerging() ->cannotBeOverwritten() ->children(); $this->appendAttributeDefinition($attributeDefinition); /** @var NodeBuilder $familyDefinition */ $familyDefinition = $attributeDefinition ->end() ->end() ->end() ->arrayNode('families') ->useAttributeAsKey('code') ->prototype('array') ->performNoDeepMerging() ->cannotBeOverwritten() ->children(); $this->appendFamilyDefinition($familyDefinition); $familyDefinition ->end() ->end() ->end() ->end(); return $treeBuilder; }
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('sidus_eav_model'); /** @var NodeBuilder $attributeDefinition */ $attributeDefinition = $rootNode ->children() ->scalarNode('data_class')->isRequired()->end() ->scalarNode('value_class')->isRequired()->end() ->booleanNode('serializer_enabled')->defaultFalse()->end() ->scalarNode('collection_type')->defaultValue(CollectionType::class)->end() ->scalarNode('context_form_type')->defaultNull()->end() ->variableNode('default_context')->defaultValue([])->end() ->arrayNode('global_context_mask') ->prototype('scalar')->defaultValue([])->end() ->end() ->arrayNode('attributes') ->useAttributeAsKey('code') ->prototype('array') ->performNoDeepMerging() ->cannotBeOverwritten() ->children(); $this->appendAttributeDefinition($attributeDefinition); /** @var NodeBuilder $familyDefinition */ $familyDefinition = $attributeDefinition ->end() ->end() ->end() ->arrayNode('families') ->useAttributeAsKey('code') ->prototype('array') ->performNoDeepMerging() ->cannotBeOverwritten() ->children(); $this->appendFamilyDefinition($familyDefinition); $familyDefinition ->end() ->end() ->end() ->end(); return $treeBuilder; }
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "'sidus_eav_model'", ")", ";", "/** @var NodeBuilder $attributeDefinition */", "...
{@inheritdoc} @throws \RuntimeException
[ "{" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/DependencyInjection/Configuration.php#L29-L75
VincentChalnot/SidusEAVModelBundle
Serializer/MaxDepthHandler.php
MaxDepthHandler.handleMaxDepth
public function handleMaxDepth(array &$context, $defaultMaxDepth = 10) { if (!array_key_exists(static::DEPTH_KEY, $context)) { $context[static::DEPTH_KEY] = 0; } $context[static::DEPTH_KEY]++; if (!array_key_exists(static::MAX_DEPTH_KEY, $context)) { $context[static::MAX_DEPTH_KEY] = $defaultMaxDepth; } if ($context[static::DEPTH_KEY] > $context[static::MAX_DEPTH_KEY]) { throw new RuntimeException('Max depth reached'); } }
php
public function handleMaxDepth(array &$context, $defaultMaxDepth = 10) { if (!array_key_exists(static::DEPTH_KEY, $context)) { $context[static::DEPTH_KEY] = 0; } $context[static::DEPTH_KEY]++; if (!array_key_exists(static::MAX_DEPTH_KEY, $context)) { $context[static::MAX_DEPTH_KEY] = $defaultMaxDepth; } if ($context[static::DEPTH_KEY] > $context[static::MAX_DEPTH_KEY]) { throw new RuntimeException('Max depth reached'); } }
[ "public", "function", "handleMaxDepth", "(", "array", "&", "$", "context", ",", "$", "defaultMaxDepth", "=", "10", ")", "{", "if", "(", "!", "array_key_exists", "(", "static", "::", "DEPTH_KEY", ",", "$", "context", ")", ")", "{", "$", "context", "[", ...
@param array $context @param int $defaultMaxDepth @throws \Symfony\Component\Serializer\Exception\RuntimeException
[ "@param", "array", "$context", "@param", "int", "$defaultMaxDepth" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Serializer/MaxDepthHandler.php#L31-L43
VincentChalnot/SidusEAVModelBundle
Model/Attribute.php
Attribute.isContextMatching
public function isContextMatching(ContextualValueInterface $value, array $context) { if (!$value->getContext()) { return true; } $value::checkContext($context); foreach ($this->getContextMask() as $key) { $contextKey = array_key_exists($key, $context) ? $context[$key] : null; if ($contextKey !== $value->getContextValue($key)) { return false; } } return true; }
php
public function isContextMatching(ContextualValueInterface $value, array $context) { if (!$value->getContext()) { return true; } $value::checkContext($context); foreach ($this->getContextMask() as $key) { $contextKey = array_key_exists($key, $context) ? $context[$key] : null; if ($contextKey !== $value->getContextValue($key)) { return false; } } return true; }
[ "public", "function", "isContextMatching", "(", "ContextualValueInterface", "$", "value", ",", "array", "$", "context", ")", "{", "if", "(", "!", "$", "value", "->", "getContext", "(", ")", ")", "{", "return", "true", ";", "}", "$", "value", "::", "check...
Warning, the context array must contain all context axis @param ContextualValueInterface $value @param array $context @throws ContextException @return bool
[ "Warning", "the", "context", "array", "must", "contain", "all", "context", "axis" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Model/Attribute.php#L419-L433
VincentChalnot/SidusEAVModelBundle
Model/Attribute.php
Attribute.mergeConfiguration
public function mergeConfiguration(array $configuration) { if (isset($configuration['type'])) { try { $newType = $this->attributeTypeRegistry->getType($configuration['type']); } catch (\UnexpectedValueException $e) { $attributeTypeCodes = implode(', ', array_keys($this->attributeTypeRegistry->getTypes())); $m = "The attribute {$this->code} has an unknown type '{$configuration['type']}'.\n"; $m .= "Available types are: {$attributeTypeCodes}"; throw new AttributeConfigurationException($m, 0, $e); } if ($this->type && $this->type->getDatabaseType() !== $newType->getDatabaseType()) { $e = "The attribute '{$this->code}' cannot be overridden with a new attribute type that don't match "; $e .= "the database type '{$this->type->getDatabaseType()}'"; throw new AttributeConfigurationException($e); } $this->type = $newType; unset($configuration['type']); } $accessor = PropertyAccess::createPropertyAccessor(); foreach ($configuration as $key => $value) { try { $accessor->setValue($this, $key, $value); } catch (\Exception $e) { throw new AttributeConfigurationException( "The attribute {$this->code} has an invalid configuration for option '{$key}'", 0, $e ); } } $this->type->setAttributeDefaults($this); // Allow attribute type service to configure attribute $this->checkConflicts(); }
php
public function mergeConfiguration(array $configuration) { if (isset($configuration['type'])) { try { $newType = $this->attributeTypeRegistry->getType($configuration['type']); } catch (\UnexpectedValueException $e) { $attributeTypeCodes = implode(', ', array_keys($this->attributeTypeRegistry->getTypes())); $m = "The attribute {$this->code} has an unknown type '{$configuration['type']}'.\n"; $m .= "Available types are: {$attributeTypeCodes}"; throw new AttributeConfigurationException($m, 0, $e); } if ($this->type && $this->type->getDatabaseType() !== $newType->getDatabaseType()) { $e = "The attribute '{$this->code}' cannot be overridden with a new attribute type that don't match "; $e .= "the database type '{$this->type->getDatabaseType()}'"; throw new AttributeConfigurationException($e); } $this->type = $newType; unset($configuration['type']); } $accessor = PropertyAccess::createPropertyAccessor(); foreach ($configuration as $key => $value) { try { $accessor->setValue($this, $key, $value); } catch (\Exception $e) { throw new AttributeConfigurationException( "The attribute {$this->code} has an invalid configuration for option '{$key}'", 0, $e ); } } $this->type->setAttributeDefaults($this); // Allow attribute type service to configure attribute $this->checkConflicts(); }
[ "public", "function", "mergeConfiguration", "(", "array", "$", "configuration", ")", "{", "if", "(", "isset", "(", "$", "configuration", "[", "'type'", "]", ")", ")", "{", "try", "{", "$", "newType", "=", "$", "this", "->", "attributeTypeRegistry", "->", ...
@param array $configuration @throws AttributeConfigurationException
[ "@param", "array", "$configuration" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Model/Attribute.php#L460-L496
VincentChalnot/SidusEAVModelBundle
Doctrine/ContextualizedOptimizedDataLoader.php
ContextualizedOptimizedDataLoader.load
public function load($entities, $depth = 1) { if (null !== $this->currentContext) { if (!\is_array($entities) && !$entities instanceof \Traversable) { throw new \InvalidArgumentException(self::E_MSG); } foreach ($entities as $entity) { if ($entity instanceof ContextualDataInterface) { $entity->setCurrentContext($this->currentContext); } } } parent::load($entities, $depth); }
php
public function load($entities, $depth = 1) { if (null !== $this->currentContext) { if (!\is_array($entities) && !$entities instanceof \Traversable) { throw new \InvalidArgumentException(self::E_MSG); } foreach ($entities as $entity) { if ($entity instanceof ContextualDataInterface) { $entity->setCurrentContext($this->currentContext); } } } parent::load($entities, $depth); }
[ "public", "function", "load", "(", "$", "entities", ",", "$", "depth", "=", "1", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "currentContext", ")", "{", "if", "(", "!", "\\", "is_array", "(", "$", "entities", ")", "&&", "!", "$", "enti...
{@inheritdoc}
[ "{" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Doctrine/ContextualizedOptimizedDataLoader.php#L34-L49
VincentChalnot/SidusEAVModelBundle
Registry/FamilyRegistry.php
FamilyRegistry.getFamily
public function getFamily($code) { if (!$this->hasFamily($code)) { throw new MissingFamilyException($code); } return $this->families[$code]; }
php
public function getFamily($code) { if (!$this->hasFamily($code)) { throw new MissingFamilyException($code); } return $this->families[$code]; }
[ "public", "function", "getFamily", "(", "$", "code", ")", "{", "if", "(", "!", "$", "this", "->", "hasFamily", "(", "$", "code", ")", ")", "{", "throw", "new", "MissingFamilyException", "(", "$", "code", ")", ";", "}", "return", "$", "this", "->", ...
@param string $code @throws MissingFamilyException @return FamilyInterface
[ "@param", "string", "$code" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Registry/FamilyRegistry.php#L57-L64
VincentChalnot/SidusEAVModelBundle
Registry/FamilyRegistry.php
FamilyRegistry.getRootFamilies
public function getRootFamilies() { $root = []; foreach ($this->getFamilies() as $family) { if ($family->isInstantiable()) { $p = $family->getParent(); if (!$p || ($p && !$p->isInstantiable())) { $root[$family->getCode()] = $family; } } } return $root; }
php
public function getRootFamilies() { $root = []; foreach ($this->getFamilies() as $family) { if ($family->isInstantiable()) { $p = $family->getParent(); if (!$p || ($p && !$p->isInstantiable())) { $root[$family->getCode()] = $family; } } } return $root; }
[ "public", "function", "getRootFamilies", "(", ")", "{", "$", "root", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getFamilies", "(", ")", "as", "$", "family", ")", "{", "if", "(", "$", "family", "->", "isInstantiable", "(", ")", ")", "{"...
Get all instantiable families with no parent @return array
[ "Get", "all", "instantiable", "families", "with", "no", "parent" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Registry/FamilyRegistry.php#L81-L94
VincentChalnot/SidusEAVModelBundle
Registry/FamilyRegistry.php
FamilyRegistry.getByParent
public function getByParent(FamilyInterface $family) { $families = []; foreach ($this->families as $subFamily) { if ($subFamily->getParent() && $subFamily->getParent()->getCode() === $family->getCode()) { $families[$subFamily->getCode()] = $subFamily; } } return $families; }
php
public function getByParent(FamilyInterface $family) { $families = []; foreach ($this->families as $subFamily) { if ($subFamily->getParent() && $subFamily->getParent()->getCode() === $family->getCode()) { $families[$subFamily->getCode()] = $subFamily; } } return $families; }
[ "public", "function", "getByParent", "(", "FamilyInterface", "$", "family", ")", "{", "$", "families", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "families", "as", "$", "subFamily", ")", "{", "if", "(", "$", "subFamily", "->", "getParent", ...
@param FamilyInterface $family @return array
[ "@param", "FamilyInterface", "$family" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Registry/FamilyRegistry.php#L101-L111
VincentChalnot/SidusEAVModelBundle
DataGrid/AbstractColumnValueRenderer.php
AbstractColumnValueRenderer.renderValue
public function renderValue($value, array $options = []): string { $object = isset($options['object']) ? $options['object'] : null; $column = isset($options['column']) ? $options['column'] : null; $attributeCode = isset($options['attribute']) ? $options['attribute'] : null; if ($column instanceof Column && null === $attributeCode) { $attributeCode = $column->getPropertyPath(); } if ($object instanceof DataInterface && $attributeCode) { try { $attribute = $object->getFamily()->getAttribute($attributeCode); } catch (\Exception $e) { // do nothing, it's okay return $this->parent->renderValue($value, $options); } $formOptions = $attribute->getFormOptions(); if (!isset($formOptions['choices']) || !\in_array($attribute->getType()->getCode(), $this->choiceTypes, true) ) { return $this->parent->renderValue($value, $options); } $key = array_search($value, $formOptions['choices'], true); if (false !== $key) { $translationDomain = null; if (array_key_exists('choice_translation_domain', $formOptions)) { $translationDomain = $formOptions['choice_translation_domain']; } if (false === $translationDomain) { return $key; } return $this->translator->trans($key, [], $translationDomain); } } return $this->parent->renderValue($value, $options); }
php
public function renderValue($value, array $options = []): string { $object = isset($options['object']) ? $options['object'] : null; $column = isset($options['column']) ? $options['column'] : null; $attributeCode = isset($options['attribute']) ? $options['attribute'] : null; if ($column instanceof Column && null === $attributeCode) { $attributeCode = $column->getPropertyPath(); } if ($object instanceof DataInterface && $attributeCode) { try { $attribute = $object->getFamily()->getAttribute($attributeCode); } catch (\Exception $e) { // do nothing, it's okay return $this->parent->renderValue($value, $options); } $formOptions = $attribute->getFormOptions(); if (!isset($formOptions['choices']) || !\in_array($attribute->getType()->getCode(), $this->choiceTypes, true) ) { return $this->parent->renderValue($value, $options); } $key = array_search($value, $formOptions['choices'], true); if (false !== $key) { $translationDomain = null; if (array_key_exists('choice_translation_domain', $formOptions)) { $translationDomain = $formOptions['choice_translation_domain']; } if (false === $translationDomain) { return $key; } return $this->translator->trans($key, [], $translationDomain); } } return $this->parent->renderValue($value, $options); }
[ "public", "function", "renderValue", "(", "$", "value", ",", "array", "$", "options", "=", "[", "]", ")", ":", "string", "{", "$", "object", "=", "isset", "(", "$", "options", "[", "'object'", "]", ")", "?", "$", "options", "[", "'object'", "]", ":...
@param mixed $value @param array $options @throws \Symfony\Component\Translation\Exception\InvalidArgumentException @return string
[ "@param", "mixed", "$value", "@param", "array", "$options" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/DataGrid/AbstractColumnValueRenderer.php#L43-L80
VincentChalnot/SidusEAVModelBundle
Entity/AbstractValue.php
AbstractValue.getAttribute
public function getAttribute() { if (!$this->getData()) { return null; } return $this->getData()->getFamily()->getAttribute($this->getAttributeCode()); }
php
public function getAttribute() { if (!$this->getData()) { return null; } return $this->getData()->getFamily()->getAttribute($this->getAttributeCode()); }
[ "public", "function", "getAttribute", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getData", "(", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "getData", "(", ")", "->", "getFamily", "(", ")", "->", "getAttribute", ...
@throws \Sidus\EAVModelBundle\Exception\MissingAttributeException @return AttributeInterface
[ "@throws", "\\", "Sidus", "\\", "EAVModelBundle", "\\", "Exception", "\\", "MissingAttributeException" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractValue.php#L187-L194
VincentChalnot/SidusEAVModelBundle
Entity/AbstractValue.php
AbstractValue.setBoolValue
public function setBoolValue($boolValue) { if (\is_array($boolValue) || \is_object($boolValue)) { $m = "Invalid value type for attribute {$this->getFamilyCode()}.{$this->getAttributeCode()}, "; $m .= 'expecting boolean, got'.gettype($boolValue); throw new \UnexpectedValueException($m); } $this->boolValue = null === $boolValue ? null : (bool) $boolValue; return $this; }
php
public function setBoolValue($boolValue) { if (\is_array($boolValue) || \is_object($boolValue)) { $m = "Invalid value type for attribute {$this->getFamilyCode()}.{$this->getAttributeCode()}, "; $m .= 'expecting boolean, got'.gettype($boolValue); throw new \UnexpectedValueException($m); } $this->boolValue = null === $boolValue ? null : (bool) $boolValue; return $this; }
[ "public", "function", "setBoolValue", "(", "$", "boolValue", ")", "{", "if", "(", "\\", "is_array", "(", "$", "boolValue", ")", "||", "\\", "is_object", "(", "$", "boolValue", ")", ")", "{", "$", "m", "=", "\"Invalid value type for attribute {$this->getFamilyC...
@param boolean|mixed $boolValue @return AbstractValue
[ "@param", "boolean|mixed", "$boolValue" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractValue.php#L209-L219
VincentChalnot/SidusEAVModelBundle
Entity/AbstractValue.php
AbstractValue.setIntegerValue
public function setIntegerValue($integerValue) { if (\is_array($integerValue) || \is_object($integerValue)) { $m = "Invalid value type for attribute {$this->getFamilyCode()}.{$this->getAttributeCode()}, "; $m .= 'expecting integer, got '.gettype($integerValue); throw new \UnexpectedValueException($m); } $this->integerValue = null === $integerValue ? null : (int) $integerValue; return $this; }
php
public function setIntegerValue($integerValue) { if (\is_array($integerValue) || \is_object($integerValue)) { $m = "Invalid value type for attribute {$this->getFamilyCode()}.{$this->getAttributeCode()}, "; $m .= 'expecting integer, got '.gettype($integerValue); throw new \UnexpectedValueException($m); } $this->integerValue = null === $integerValue ? null : (int) $integerValue; return $this; }
[ "public", "function", "setIntegerValue", "(", "$", "integerValue", ")", "{", "if", "(", "\\", "is_array", "(", "$", "integerValue", ")", "||", "\\", "is_object", "(", "$", "integerValue", ")", ")", "{", "$", "m", "=", "\"Invalid value type for attribute {$this...
@param integer|mixed $integerValue @return AbstractValue
[ "@param", "integer|mixed", "$integerValue" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractValue.php#L234-L244
VincentChalnot/SidusEAVModelBundle
Entity/AbstractValue.php
AbstractValue.setDecimalValue
public function setDecimalValue($decimalValue) { if (\is_array($decimalValue) || \is_object($decimalValue)) { $m = "Invalid value type for attribute {$this->getFamilyCode()}.{$this->getAttributeCode()}, "; $m .= 'expecting float, got '.gettype($decimalValue); throw new \UnexpectedValueException($m); } $this->decimalValue = null === $decimalValue ? null : (float) $decimalValue; return $this; }
php
public function setDecimalValue($decimalValue) { if (\is_array($decimalValue) || \is_object($decimalValue)) { $m = "Invalid value type for attribute {$this->getFamilyCode()}.{$this->getAttributeCode()}, "; $m .= 'expecting float, got '.gettype($decimalValue); throw new \UnexpectedValueException($m); } $this->decimalValue = null === $decimalValue ? null : (float) $decimalValue; return $this; }
[ "public", "function", "setDecimalValue", "(", "$", "decimalValue", ")", "{", "if", "(", "\\", "is_array", "(", "$", "decimalValue", ")", "||", "\\", "is_object", "(", "$", "decimalValue", ")", ")", "{", "$", "m", "=", "\"Invalid value type for attribute {$this...
@param float|mixed $decimalValue @return AbstractValue
[ "@param", "float|mixed", "$decimalValue" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractValue.php#L259-L269
VincentChalnot/SidusEAVModelBundle
Entity/AbstractValue.php
AbstractValue.setStringValue
public function setStringValue($stringValue) { if (\is_array($stringValue) || \is_object($stringValue)) { $m = "Invalid value type for attribute {$this->getFamilyCode()}.{$this->getAttributeCode()}, "; $m .= 'expecting string, got '.gettype($stringValue); throw new \UnexpectedValueException($m); } if (null !== $stringValue && 255 < \mb_strlen($stringValue)) { $stringValue = mb_substr($stringValue, 0, 255); } $this->stringValue = null === $stringValue ? null : (string) $stringValue; return $this; }
php
public function setStringValue($stringValue) { if (\is_array($stringValue) || \is_object($stringValue)) { $m = "Invalid value type for attribute {$this->getFamilyCode()}.{$this->getAttributeCode()}, "; $m .= 'expecting string, got '.gettype($stringValue); throw new \UnexpectedValueException($m); } if (null !== $stringValue && 255 < \mb_strlen($stringValue)) { $stringValue = mb_substr($stringValue, 0, 255); } $this->stringValue = null === $stringValue ? null : (string) $stringValue; return $this; }
[ "public", "function", "setStringValue", "(", "$", "stringValue", ")", "{", "if", "(", "\\", "is_array", "(", "$", "stringValue", ")", "||", "\\", "is_object", "(", "$", "stringValue", ")", ")", "{", "$", "m", "=", "\"Invalid value type for attribute {$this->ge...
@param string|mixed $stringValue @return AbstractValue
[ "@param", "string|mixed", "$stringValue" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractValue.php#L328-L341
VincentChalnot/SidusEAVModelBundle
Entity/AbstractValue.php
AbstractValue.setTextValue
public function setTextValue($textValue) { if (\is_array($textValue) || \is_object($textValue)) { $m = "Invalid value type for attribute {$this->getFamilyCode()}.{$this->getAttributeCode()}, "; $m .= 'expecting string, got '.gettype($textValue); throw new \UnexpectedValueException($m); } $this->textValue = null === $textValue ? null : (string) $textValue; return $this; }
php
public function setTextValue($textValue) { if (\is_array($textValue) || \is_object($textValue)) { $m = "Invalid value type for attribute {$this->getFamilyCode()}.{$this->getAttributeCode()}, "; $m .= 'expecting string, got '.gettype($textValue); throw new \UnexpectedValueException($m); } $this->textValue = null === $textValue ? null : (string) $textValue; return $this; }
[ "public", "function", "setTextValue", "(", "$", "textValue", ")", "{", "if", "(", "\\", "is_array", "(", "$", "textValue", ")", "||", "\\", "is_object", "(", "$", "textValue", ")", ")", "{", "$", "m", "=", "\"Invalid value type for attribute {$this->getFamilyC...
@param string|mixed $textValue @return AbstractValue
[ "@param", "string|mixed", "$textValue" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractValue.php#L356-L366
VincentChalnot/SidusEAVModelBundle
Entity/AbstractValue.php
AbstractValue.setValueData
public function setValueData($valueData) { $method = 'set'.ucfirst($this->getAttribute()->getType()->getDatabaseType()); return $this->$method($valueData); }
php
public function setValueData($valueData) { $method = 'set'.ucfirst($this->getAttribute()->getType()->getDatabaseType()); return $this->$method($valueData); }
[ "public", "function", "setValueData", "(", "$", "valueData", ")", "{", "$", "method", "=", "'set'", ".", "ucfirst", "(", "$", "this", "->", "getAttribute", "(", ")", "->", "getType", "(", ")", "->", "getDatabaseType", "(", ")", ")", ";", "return", "$",...
@param mixed $valueData @return mixed
[ "@param", "mixed", "$valueData" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractValue.php#L439-L444
VincentChalnot/SidusEAVModelBundle
Entity/AbstractValue.php
AbstractValue.checkContext
public static function checkContext(array $context) { $missingKeys = array_diff(static::getContextKeys(), array_keys($context)); if (0 !== \count($missingKeys)) { $flattenedContext = implode(', ', $missingKeys); throw new ContextException("Missing key(s) in context: {$flattenedContext}"); } $extraKeys = array_diff(array_keys($context), static::getContextKeys()); if (0 !== \count($extraKeys)) { $flattenedContext = implode(', ', $extraKeys); throw new ContextException("Extra key(s) in context: {$flattenedContext}"); } }
php
public static function checkContext(array $context) { $missingKeys = array_diff(static::getContextKeys(), array_keys($context)); if (0 !== \count($missingKeys)) { $flattenedContext = implode(', ', $missingKeys); throw new ContextException("Missing key(s) in context: {$flattenedContext}"); } $extraKeys = array_diff(array_keys($context), static::getContextKeys()); if (0 !== \count($extraKeys)) { $flattenedContext = implode(', ', $extraKeys); throw new ContextException("Extra key(s) in context: {$flattenedContext}"); } }
[ "public", "static", "function", "checkContext", "(", "array", "$", "context", ")", "{", "$", "missingKeys", "=", "array_diff", "(", "static", "::", "getContextKeys", "(", ")", ",", "array_keys", "(", "$", "context", ")", ")", ";", "if", "(", "0", "!==", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractValue.php#L486-L498
VincentChalnot/SidusEAVModelBundle
Entity/AbstractValue.php
AbstractValue.setContext
public function setContext(array $context) { $this->clearContext(); foreach ($context as $key => $value) { $this->setContextValue($key, $value); } }
php
public function setContext(array $context) { $this->clearContext(); foreach ($context as $key => $value) { $this->setContextValue($key, $value); } }
[ "public", "function", "setContext", "(", "array", "$", "context", ")", "{", "$", "this", "->", "clearContext", "(", ")", ";", "foreach", "(", "$", "context", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "setContextValue", "(", "...
@param array $context @throws ContextException
[ "@param", "array", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractValue.php#L519-L525
VincentChalnot/SidusEAVModelBundle
Entity/DataRepository.php
DataRepository.findByIdentifier
public function findByIdentifier(FamilyInterface $family, $reference, $idFallback = false, $partialLoad = false) { $identifierAttribute = $family->getAttributeAsIdentifier(); if (!$identifierAttribute) { if (!$idFallback) { $m = "Cannot find data with no identifier attribute for family: '{$family->getCode()}'"; throw new \UnexpectedValueException($m); } return $this->findByPrimaryKey($family, $reference, $partialLoad); } return $this->findByUniqueAttribute($family, $identifierAttribute, $reference, $partialLoad); }
php
public function findByIdentifier(FamilyInterface $family, $reference, $idFallback = false, $partialLoad = false) { $identifierAttribute = $family->getAttributeAsIdentifier(); if (!$identifierAttribute) { if (!$idFallback) { $m = "Cannot find data with no identifier attribute for family: '{$family->getCode()}'"; throw new \UnexpectedValueException($m); } return $this->findByPrimaryKey($family, $reference, $partialLoad); } return $this->findByUniqueAttribute($family, $identifierAttribute, $reference, $partialLoad); }
[ "public", "function", "findByIdentifier", "(", "FamilyInterface", "$", "family", ",", "$", "reference", ",", "$", "idFallback", "=", "false", ",", "$", "partialLoad", "=", "false", ")", "{", "$", "identifierAttribute", "=", "$", "family", "->", "getAttributeAs...
Find data based on it's family identifier @param FamilyInterface $family @param int|string $reference @param bool $idFallback @param bool $partialLoad @throws NonUniqueResultException @throws \UnexpectedValueException @throws ORMException @throws \LogicException @return DataInterface|null
[ "Find", "data", "based", "on", "it", "s", "family", "identifier" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/DataRepository.php#L53-L66
VincentChalnot/SidusEAVModelBundle
Entity/DataRepository.php
DataRepository.findByUniqueAttribute
public function findByUniqueAttribute( FamilyInterface $family, AttributeInterface $attribute, $reference, $partialLoad = false ) { if (!$attribute->isUnique()) { throw new \LogicException("Cannot find data based on a non-unique attribute '{$attribute->getCode()}'"); } $dataBaseType = $attribute->getType()->getDatabaseType(); $qb = $this->createQueryBuilder('e'); $joinCondition = "(identifier.attributeCode = :attributeCode AND identifier.{$dataBaseType} = :reference)"; $qb ->join('e.values', 'identifier', Join::WITH, $joinCondition) ->where('e.family = :familyCode') ->setParameters( [ 'attributeCode' => $attribute->getCode(), 'reference' => $reference, 'familyCode' => $family->getCode(), ] ); if ($partialLoad) { return $this->executeWithPartialLoad($qb); } return $qb->getQuery()->getOneOrNullResult(); }
php
public function findByUniqueAttribute( FamilyInterface $family, AttributeInterface $attribute, $reference, $partialLoad = false ) { if (!$attribute->isUnique()) { throw new \LogicException("Cannot find data based on a non-unique attribute '{$attribute->getCode()}'"); } $dataBaseType = $attribute->getType()->getDatabaseType(); $qb = $this->createQueryBuilder('e'); $joinCondition = "(identifier.attributeCode = :attributeCode AND identifier.{$dataBaseType} = :reference)"; $qb ->join('e.values', 'identifier', Join::WITH, $joinCondition) ->where('e.family = :familyCode') ->setParameters( [ 'attributeCode' => $attribute->getCode(), 'reference' => $reference, 'familyCode' => $family->getCode(), ] ); if ($partialLoad) { return $this->executeWithPartialLoad($qb); } return $qb->getQuery()->getOneOrNullResult(); }
[ "public", "function", "findByUniqueAttribute", "(", "FamilyInterface", "$", "family", ",", "AttributeInterface", "$", "attribute", ",", "$", "reference", ",", "$", "partialLoad", "=", "false", ")", "{", "if", "(", "!", "$", "attribute", "->", "isUnique", "(", ...
Find a data based on a unique attribute @param FamilyInterface $family @param AttributeInterface $attribute @param string|int $reference @param bool $partialLoad @throws \LogicException @throws \Doctrine\ORM\ORMException @throws NonUniqueResultException @return DataInterface|null
[ "Find", "a", "data", "based", "on", "a", "unique", "attribute" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/DataRepository.php#L82-L110
VincentChalnot/SidusEAVModelBundle
Entity/DataRepository.php
DataRepository.findByPrimaryKey
public function findByPrimaryKey( FamilyInterface $family, $reference, $partialLoad = false ) { $identifierColumn = $this->getPkColumn($family); return $this->findByIdentifierColumn($family, $identifierColumn, $reference, $partialLoad); }
php
public function findByPrimaryKey( FamilyInterface $family, $reference, $partialLoad = false ) { $identifierColumn = $this->getPkColumn($family); return $this->findByIdentifierColumn($family, $identifierColumn, $reference, $partialLoad); }
[ "public", "function", "findByPrimaryKey", "(", "FamilyInterface", "$", "family", ",", "$", "reference", ",", "$", "partialLoad", "=", "false", ")", "{", "$", "identifierColumn", "=", "$", "this", "->", "getPkColumn", "(", "$", "family", ")", ";", "return", ...
Find by the Data entity primary key like a find() @param FamilyInterface $family @param string|int $reference @param bool $partialLoad @throws \Doctrine\ORM\ORMException @return Proxy|DataInterface|null
[ "Find", "by", "the", "Data", "entity", "primary", "key", "like", "a", "find", "()" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/DataRepository.php#L123-L131
VincentChalnot/SidusEAVModelBundle
Entity/DataRepository.php
DataRepository.findByIdentifierColumn
public function findByIdentifierColumn( FamilyInterface $family, $identifierColumn, $reference, $partialLoad = false ) { if (!$partialLoad) { return $this->findOneBy( [ $identifierColumn => $reference, 'family' => $family, ] ); } $qb = $this->createQueryBuilder('e') ->where("e.{$identifierColumn} = :reference") ->andWhere('e.family = :familyCode') ->setParameters( [ 'reference' => $reference, 'familyCode' => $family->getCode(), ] ); return $this->executeWithPartialLoad($qb); }
php
public function findByIdentifierColumn( FamilyInterface $family, $identifierColumn, $reference, $partialLoad = false ) { if (!$partialLoad) { return $this->findOneBy( [ $identifierColumn => $reference, 'family' => $family, ] ); } $qb = $this->createQueryBuilder('e') ->where("e.{$identifierColumn} = :reference") ->andWhere('e.family = :familyCode') ->setParameters( [ 'reference' => $reference, 'familyCode' => $family->getCode(), ] ); return $this->executeWithPartialLoad($qb); }
[ "public", "function", "findByIdentifierColumn", "(", "FamilyInterface", "$", "family", ",", "$", "identifierColumn", ",", "$", "reference", ",", "$", "partialLoad", "=", "false", ")", "{", "if", "(", "!", "$", "partialLoad", ")", "{", "return", "$", "this", ...
Find data based on a identifier column present in the Data entity @param FamilyInterface $family @param string $identifierColumn @param int|string $reference @param bool $partialLoad @throws ORMException @return DataInterface|Proxy|null
[ "Find", "data", "based", "on", "a", "identifier", "column", "present", "in", "the", "Data", "entity" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/DataRepository.php#L145-L171
VincentChalnot/SidusEAVModelBundle
Entity/DataRepository.php
DataRepository.getInstance
public function getInstance(FamilyInterface $family) { if (!$family->isSingleton()) { throw new \LogicException("Family {$family->getCode()} is not a singleton"); } $qb = $this->createQueryBuilder('e') ->andWhere('e.family = :familyCode') ->join('e.values', 'values') ->setParameters( [ 'familyCode' => $family->getCode(), ] ); $instance = $qb->getQuery()->getOneOrNullResult(); if (!$instance) { $dataClass = $family->getDataClass(); $instance = new $dataClass($family); } return $instance; }
php
public function getInstance(FamilyInterface $family) { if (!$family->isSingleton()) { throw new \LogicException("Family {$family->getCode()} is not a singleton"); } $qb = $this->createQueryBuilder('e') ->andWhere('e.family = :familyCode') ->join('e.values', 'values') ->setParameters( [ 'familyCode' => $family->getCode(), ] ); $instance = $qb->getQuery()->getOneOrNullResult(); if (!$instance) { $dataClass = $family->getDataClass(); $instance = new $dataClass($family); } return $instance; }
[ "public", "function", "getInstance", "(", "FamilyInterface", "$", "family", ")", "{", "if", "(", "!", "$", "family", "->", "isSingleton", "(", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"Family {$family->getCode()} is not a singleton\"", ")", ...
Return singleton for a given family @param FamilyInterface $family @throws \LogicException @throws \Doctrine\ORM\NonUniqueResultException @return DataInterface
[ "Return", "singleton", "for", "a", "given", "family" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/DataRepository.php#L183-L204
VincentChalnot/SidusEAVModelBundle
Entity/DataRepository.php
DataRepository.createOptimizedQueryBuilder
public function createOptimizedQueryBuilder($alias, $indexBy = null, QueryBuilder $qb = null, $associations = false) { $m = 'Do not use this function anymore, use the OptimizedDataLoader on your query results instead'; @trigger_error($m, E_USER_DEPRECATED); if (!$qb) { $qb = $this->createQueryBuilder($alias, $indexBy); } $qb ->leftJoin($alias.'.values', 'values') ->addSelect('values'); if ($associations) { $qb ->leftJoin('values.dataValue', 'associations') ->addSelect('associations') ->leftJoin('associations.values', 'associationValues') ->addSelect('associationValues'); } return $qb; }
php
public function createOptimizedQueryBuilder($alias, $indexBy = null, QueryBuilder $qb = null, $associations = false) { $m = 'Do not use this function anymore, use the OptimizedDataLoader on your query results instead'; @trigger_error($m, E_USER_DEPRECATED); if (!$qb) { $qb = $this->createQueryBuilder($alias, $indexBy); } $qb ->leftJoin($alias.'.values', 'values') ->addSelect('values'); if ($associations) { $qb ->leftJoin('values.dataValue', 'associations') ->addSelect('associations') ->leftJoin('associations.values', 'associationValues') ->addSelect('associationValues'); } return $qb; }
[ "public", "function", "createOptimizedQueryBuilder", "(", "$", "alias", ",", "$", "indexBy", "=", "null", ",", "QueryBuilder", "$", "qb", "=", "null", ",", "$", "associations", "=", "false", ")", "{", "$", "m", "=", "'Do not use this function anymore, use the Op...
@deprecated Do not use this function anymore, use the OptimizedDataLoader on your query results instead @param string $alias @param string $indexBy @param QueryBuilder|null $qb @param bool $associations @return QueryBuilder
[ "@deprecated", "Do", "not", "use", "this", "function", "anymore", "use", "the", "OptimizedDataLoader", "on", "your", "query", "results", "instead" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/DataRepository.php#L216-L237
VincentChalnot/SidusEAVModelBundle
Entity/DataRepository.php
DataRepository.createFamilyQueryBuilder
public function createFamilyQueryBuilder(FamilyInterface $family, $alias = 'e') { return new SingleFamilyQueryBuilder($family, $this->createQueryBuilder($alias), $alias); }
php
public function createFamilyQueryBuilder(FamilyInterface $family, $alias = 'e') { return new SingleFamilyQueryBuilder($family, $this->createQueryBuilder($alias), $alias); }
[ "public", "function", "createFamilyQueryBuilder", "(", "FamilyInterface", "$", "family", ",", "$", "alias", "=", "'e'", ")", "{", "return", "new", "SingleFamilyQueryBuilder", "(", "$", "family", ",", "$", "this", "->", "createQueryBuilder", "(", "$", "alias", ...
Returns a EAVQueryBuilder to allow you to build a complex query to search your database @param FamilyInterface $family @param string $alias @return SingleFamilyQueryBuilder
[ "Returns", "a", "EAVQueryBuilder", "to", "allow", "you", "to", "build", "a", "complex", "query", "to", "search", "your", "database" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/DataRepository.php#L247-L250
VincentChalnot/SidusEAVModelBundle
Entity/DataRepository.php
DataRepository.getQbForFamilies
public function getQbForFamilies(array $families) { $familyCodes = array_map( function (FamilyInterface $family) { return $family->getCode(); }, $families ); $qb = $this->createQueryBuilder('e'); $qb ->andWhere('e.family IN (:families)') ->setParameter( 'families', $familyCodes ); return $qb; }
php
public function getQbForFamilies(array $families) { $familyCodes = array_map( function (FamilyInterface $family) { return $family->getCode(); }, $families ); $qb = $this->createQueryBuilder('e'); $qb ->andWhere('e.family IN (:families)') ->setParameter( 'families', $familyCodes ); return $qb; }
[ "public", "function", "getQbForFamilies", "(", "array", "$", "families", ")", "{", "$", "familyCodes", "=", "array_map", "(", "function", "(", "FamilyInterface", "$", "family", ")", "{", "return", "$", "family", "->", "getCode", "(", ")", ";", "}", ",", ...
@param array $families @return QueryBuilder
[ "@param", "array", "$families" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/DataRepository.php#L279-L296
VincentChalnot/SidusEAVModelBundle
Entity/DataRepository.php
DataRepository.getQbForFamiliesAndIdentifier
public function getQbForFamiliesAndIdentifier(array $families, $term) { $eavQb = $this->createEAVQueryBuilder(); $orCondition = []; foreach ($families as $family) { $identifierAttribute = $family->getAttributeAsIdentifier(); if (!$identifierAttribute) { throw new \LogicException("Family {$family->getCode()} has no identifier"); } $orCondition[] = $eavQb->attribute($identifierAttribute)->like($term); } return $eavQb->apply($eavQb->getOr($orCondition)); }
php
public function getQbForFamiliesAndIdentifier(array $families, $term) { $eavQb = $this->createEAVQueryBuilder(); $orCondition = []; foreach ($families as $family) { $identifierAttribute = $family->getAttributeAsIdentifier(); if (!$identifierAttribute) { throw new \LogicException("Family {$family->getCode()} has no identifier"); } $orCondition[] = $eavQb->attribute($identifierAttribute)->like($term); } return $eavQb->apply($eavQb->getOr($orCondition)); }
[ "public", "function", "getQbForFamiliesAndIdentifier", "(", "array", "$", "families", ",", "$", "term", ")", "{", "$", "eavQb", "=", "$", "this", "->", "createEAVQueryBuilder", "(", ")", ";", "$", "orCondition", "=", "[", "]", ";", "foreach", "(", "$", "...
@param FamilyInterface[] $families @param string $term @throws \LogicException @throws \UnexpectedValueException @return QueryBuilder
[ "@param", "FamilyInterface", "[]", "$families", "@param", "string", "$term" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/DataRepository.php#L307-L320
VincentChalnot/SidusEAVModelBundle
Entity/DataRepository.php
DataRepository.loadFullEntity
public function loadFullEntity($id) { /** @var DataInterface $data */ $data = $this->find($id); $loader = new OptimizedDataLoader($this->getEntityManager()); $loader->loadSingle($data); return $data; }
php
public function loadFullEntity($id) { /** @var DataInterface $data */ $data = $this->find($id); $loader = new OptimizedDataLoader($this->getEntityManager()); $loader->loadSingle($data); return $data; }
[ "public", "function", "loadFullEntity", "(", "$", "id", ")", "{", "/** @var DataInterface $data */", "$", "data", "=", "$", "this", "->", "find", "(", "$", "id", ")", ";", "$", "loader", "=", "new", "OptimizedDataLoader", "(", "$", "this", "->", "getEntity...
@param int $id @return DataInterface
[ "@param", "int", "$id" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/DataRepository.php#L327-L335
VincentChalnot/SidusEAVModelBundle
Entity/DataRepository.php
DataRepository.fetchEAVAssociations
public function fetchEAVAssociations(DataInterface $data) { $qb = $this->createQueryBuilder('e'); $qb ->join('e.refererValues', 'refererValues', Join::WITH, 'refererValues.data = :id') ->setParameter('id', $data->getId()); $results = $qb->getQuery()->getResult(); $loader = new OptimizedDataLoader($this->getEntityManager()); $loader->load($results); return $results; }
php
public function fetchEAVAssociations(DataInterface $data) { $qb = $this->createQueryBuilder('e'); $qb ->join('e.refererValues', 'refererValues', Join::WITH, 'refererValues.data = :id') ->setParameter('id', $data->getId()); $results = $qb->getQuery()->getResult(); $loader = new OptimizedDataLoader($this->getEntityManager()); $loader->load($results); return $results; }
[ "public", "function", "fetchEAVAssociations", "(", "DataInterface", "$", "data", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'e'", ")", ";", "$", "qb", "->", "join", "(", "'e.refererValues'", ",", "'refererValues'", ",", "Join", ...
@param DataInterface $data @return DataInterface[]
[ "@param", "DataInterface", "$data" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/DataRepository.php#L342-L353
VincentChalnot/SidusEAVModelBundle
Entity/DataRepository.php
DataRepository.executeWithPartialLoad
protected function executeWithPartialLoad(QueryBuilder $qb) { $query = $qb->getQuery(); $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); return $query->getOneOrNullResult(); }
php
protected function executeWithPartialLoad(QueryBuilder $qb) { $query = $qb->getQuery(); $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); return $query->getOneOrNullResult(); }
[ "protected", "function", "executeWithPartialLoad", "(", "QueryBuilder", "$", "qb", ")", "{", "$", "query", "=", "$", "qb", "->", "getQuery", "(", ")", ";", "$", "query", "->", "setHint", "(", "Query", "::", "HINT_FORCE_PARTIAL_LOAD", ",", "true", ")", ";",...
@param QueryBuilder $qb @throws NonUniqueResultException @return mixed
[ "@param", "QueryBuilder", "$qb" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/DataRepository.php#L376-L382
VincentChalnot/SidusEAVModelBundle
Exception/WrongFamilyException.php
WrongFamilyException.assertFamilies
public static function assertFamilies(DataInterface $data, array $familyCodes) { if (\in_array($data->getFamilyCode(), $familyCodes, true)) { return; } $backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); $function = $backtrace[1]['class'].'::'.$backtrace[1]['function']; $families = implode(', ', $familyCodes); $m = "Argument 1 passed to {$function} must be of one of the following families: {$families}, '{$data->getFamilyCode()}' given"; throw new self( "WrongFamilyException: {$m}", // message 0, // code E_RECOVERABLE_ERROR, // severity $backtrace[0]['file'], // filename $backtrace[0]['line'], // line number [] // context ); }
php
public static function assertFamilies(DataInterface $data, array $familyCodes) { if (\in_array($data->getFamilyCode(), $familyCodes, true)) { return; } $backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); $function = $backtrace[1]['class'].'::'.$backtrace[1]['function']; $families = implode(', ', $familyCodes); $m = "Argument 1 passed to {$function} must be of one of the following families: {$families}, '{$data->getFamilyCode()}' given"; throw new self( "WrongFamilyException: {$m}", // message 0, // code E_RECOVERABLE_ERROR, // severity $backtrace[0]['file'], // filename $backtrace[0]['line'], // line number [] // context ); }
[ "public", "static", "function", "assertFamilies", "(", "DataInterface", "$", "data", ",", "array", "$", "familyCodes", ")", "{", "if", "(", "\\", "in_array", "(", "$", "data", "->", "getFamilyCode", "(", ")", ",", "$", "familyCodes", ",", "true", ")", ")...
@param DataInterface $data @param array $familyCodes @throws WrongFamilyException
[ "@param", "DataInterface", "$data", "@param", "array", "$familyCodes" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Exception/WrongFamilyException.php#L39-L58
VincentChalnot/SidusEAVModelBundle
Manager/DataManager.php
DataManager.getQbForFamiliesAndLabel
public function getQbForFamiliesAndLabel(array $families, $term) { // Removing empty terms with wildcards on both sides if ('%%' === $term) { $term = '%'; } // Specific optimisation for match-all queries if ('%' === $term) { return $this->repository->getQbForFamilies($families); } $eavQb = $this->repository->createEAVQueryBuilder(); $orCondition = []; foreach ($families as $family) { $eavQbAttributes = $this->resolveEavQbAttributes($family, $eavQb); foreach ($eavQbAttributes as $eavQbAttribute) { $orCondition[] = $eavQbAttribute->like($term); } } return $eavQb->apply($eavQb->getOr($orCondition)); }
php
public function getQbForFamiliesAndLabel(array $families, $term) { // Removing empty terms with wildcards on both sides if ('%%' === $term) { $term = '%'; } // Specific optimisation for match-all queries if ('%' === $term) { return $this->repository->getQbForFamilies($families); } $eavQb = $this->repository->createEAVQueryBuilder(); $orCondition = []; foreach ($families as $family) { $eavQbAttributes = $this->resolveEavQbAttributes($family, $eavQb); foreach ($eavQbAttributes as $eavQbAttribute) { $orCondition[] = $eavQbAttribute->like($term); } } return $eavQb->apply($eavQb->getOr($orCondition)); }
[ "public", "function", "getQbForFamiliesAndLabel", "(", "array", "$", "families", ",", "$", "term", ")", "{", "// Removing empty terms with wildcards on both sides", "if", "(", "'%%'", "===", "$", "term", ")", "{", "$", "term", "=", "'%'", ";", "}", "// Specific ...
This method was moved from the DataRepository because it depends on the FamilyRegistry to resolve sub families @param FamilyInterface[] $families @param string $term @throws \Sidus\EAVModelBundle\Exception\MissingFamilyException @throws \LogicException @throws \UnexpectedValueException @return QueryBuilder
[ "This", "method", "was", "moved", "from", "the", "DataRepository", "because", "it", "depends", "on", "the", "FamilyRegistry", "to", "resolve", "sub", "families" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Manager/DataManager.php#L62-L85
VincentChalnot/SidusEAVModelBundle
Manager/DataManager.php
DataManager.resolveEavQbAttributes
public function resolveEavQbAttributes( FamilyInterface $family, EAVQueryBuilderInterface $eavQb, AttributeQueryBuilderInterface $parentAttributeQb = null ) { $attribute = $family->getAttributeAsLabel(); if (!$attribute) { throw new \LogicException("Family {$family->getCode()} does not have an attribute as label"); } if ($parentAttributeQb) { $attributeQb = $parentAttributeQb->join()->attribute($attribute); } else { $attributeQb = $eavQb->attribute($attribute); } $eavQbAttributes = [$attributeQb]; $attributeType = $attribute->getType(); if ($attributeType->isRelation() || $attributeType->isEmbedded()) { $eavQbAttributes = []; foreach ((array) $attribute->getOption('allowed_families', []) as $subFamily) { if (!$subFamily instanceof FamilyInterface) { $subFamily = $this->familyRegistry->getFamily($subFamily); } /** @noinspection SlowArrayOperationsInLoopInspection */ $eavQbAttributes = array_merge( $eavQbAttributes, $this->resolveEavQbAttributes( $subFamily, $eavQb, $attributeQb ) ); } } return $eavQbAttributes; }
php
public function resolveEavQbAttributes( FamilyInterface $family, EAVQueryBuilderInterface $eavQb, AttributeQueryBuilderInterface $parentAttributeQb = null ) { $attribute = $family->getAttributeAsLabel(); if (!$attribute) { throw new \LogicException("Family {$family->getCode()} does not have an attribute as label"); } if ($parentAttributeQb) { $attributeQb = $parentAttributeQb->join()->attribute($attribute); } else { $attributeQb = $eavQb->attribute($attribute); } $eavQbAttributes = [$attributeQb]; $attributeType = $attribute->getType(); if ($attributeType->isRelation() || $attributeType->isEmbedded()) { $eavQbAttributes = []; foreach ((array) $attribute->getOption('allowed_families', []) as $subFamily) { if (!$subFamily instanceof FamilyInterface) { $subFamily = $this->familyRegistry->getFamily($subFamily); } /** @noinspection SlowArrayOperationsInLoopInspection */ $eavQbAttributes = array_merge( $eavQbAttributes, $this->resolveEavQbAttributes( $subFamily, $eavQb, $attributeQb ) ); } } return $eavQbAttributes; }
[ "public", "function", "resolveEavQbAttributes", "(", "FamilyInterface", "$", "family", ",", "EAVQueryBuilderInterface", "$", "eavQb", ",", "AttributeQueryBuilderInterface", "$", "parentAttributeQb", "=", "null", ")", "{", "$", "attribute", "=", "$", "family", "->", ...
@param FamilyInterface $family @param EAVQueryBuilderInterface $eavQb @param AttributeQueryBuilderInterface|null $parentAttributeQb @throws \LogicException @throws \Sidus\EAVModelBundle\Exception\MissingFamilyException @return AttributeQueryBuilderInterface[]
[ "@param", "FamilyInterface", "$family", "@param", "EAVQueryBuilderInterface", "$eavQb", "@param", "AttributeQueryBuilderInterface|null", "$parentAttributeQb" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Manager/DataManager.php#L97-L134
VincentChalnot/SidusEAVModelBundle
Doctrine/IntegrityConstraintManager.php
IntegrityConstraintManager.getEntityConstraints
public function getEntityConstraints($sourceEntity) { $className = ClassUtils::getClass($sourceEntity); $entityManager = $this->doctrine->getManagerForClass($className); if (!$entityManager instanceof EntityManagerInterface) { throw new \UnexpectedValueException("No manager found for class {$className}"); } $associationsToCheck = $this->getConstrainedDataAssociations($entityManager, $className); $constrainedEntities = []; foreach ($associationsToCheck as $associationMapping) { $entityRepository = $entityManager->getRepository($associationMapping['sourceEntity']); $entities = $entityRepository->findBy( [ $associationMapping['fieldName'] => $sourceEntity, ] ); foreach ($entities as $entity) { // Small hack for EAV values if ($entity instanceof ValueInterface) { $entity = $entity->getData(); } $constrainedEntities[] = $entity; } } return $constrainedEntities; }
php
public function getEntityConstraints($sourceEntity) { $className = ClassUtils::getClass($sourceEntity); $entityManager = $this->doctrine->getManagerForClass($className); if (!$entityManager instanceof EntityManagerInterface) { throw new \UnexpectedValueException("No manager found for class {$className}"); } $associationsToCheck = $this->getConstrainedDataAssociations($entityManager, $className); $constrainedEntities = []; foreach ($associationsToCheck as $associationMapping) { $entityRepository = $entityManager->getRepository($associationMapping['sourceEntity']); $entities = $entityRepository->findBy( [ $associationMapping['fieldName'] => $sourceEntity, ] ); foreach ($entities as $entity) { // Small hack for EAV values if ($entity instanceof ValueInterface) { $entity = $entity->getData(); } $constrainedEntities[] = $entity; } } return $constrainedEntities; }
[ "public", "function", "getEntityConstraints", "(", "$", "sourceEntity", ")", "{", "$", "className", "=", "ClassUtils", "::", "getClass", "(", "$", "sourceEntity", ")", ";", "$", "entityManager", "=", "$", "this", "->", "doctrine", "->", "getManagerForClass", "...
@param mixed $sourceEntity @throws \UnexpectedValueException @return array
[ "@param", "mixed", "$sourceEntity" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Doctrine/IntegrityConstraintManager.php#L45-L73
VincentChalnot/SidusEAVModelBundle
Doctrine/IntegrityConstraintManager.php
IntegrityConstraintManager.getConstrainedDataAssociations
protected function getConstrainedDataAssociations(EntityManagerInterface $entityManager, $className) { // We must ensure that we check all the different classes in case of inheritance mapping /** @var ClassMetadata $sourceMetadata */ $sourceMetadata = $entityManager->getClassMetadata($className); $classes = $sourceMetadata->parentClasses; $classes[] = $className; /** @var ClassMetadata[] $metadatas */ $associationsToCheck = []; $metadatas = $entityManager->getMetadataFactory()->getAllMetadata(); foreach ($metadatas as $metadata) { foreach ($metadata->getAssociationMappings() as $associationMapping) { foreach ($classes as $class) { $this->checkAssociationMapping($class, $associationMapping, $associationsToCheck); } } } return $associationsToCheck; }
php
protected function getConstrainedDataAssociations(EntityManagerInterface $entityManager, $className) { // We must ensure that we check all the different classes in case of inheritance mapping /** @var ClassMetadata $sourceMetadata */ $sourceMetadata = $entityManager->getClassMetadata($className); $classes = $sourceMetadata->parentClasses; $classes[] = $className; /** @var ClassMetadata[] $metadatas */ $associationsToCheck = []; $metadatas = $entityManager->getMetadataFactory()->getAllMetadata(); foreach ($metadatas as $metadata) { foreach ($metadata->getAssociationMappings() as $associationMapping) { foreach ($classes as $class) { $this->checkAssociationMapping($class, $associationMapping, $associationsToCheck); } } } return $associationsToCheck; }
[ "protected", "function", "getConstrainedDataAssociations", "(", "EntityManagerInterface", "$", "entityManager", ",", "$", "className", ")", "{", "// We must ensure that we check all the different classes in case of inheritance mapping", "/** @var ClassMetadata $sourceMetadata */", "$", ...
@param EntityManagerInterface $entityManager @param string $className @return array
[ "@param", "EntityManagerInterface", "$entityManager", "@param", "string", "$className" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Doctrine/IntegrityConstraintManager.php#L81-L101
VincentChalnot/SidusEAVModelBundle
Event/OrphanEmbedRemovalListener.php
OrphanEmbedRemovalListener.preRemove
public function preRemove(LifecycleEventArgs $args) { $value = $args->getEntity(); if (!$value instanceof ValueInterface) { return; } // Ignore removed families if (!$this->familyRegistry->hasFamily($value->getFamilyCode())) { return; } $family = $this->familyRegistry->getFamily($value->getFamilyCode()); // Ignore removed attributes if (!$family->hasAttribute($value->getAttributeCode())) { return; } $attribute = $family->getAttribute($value->getAttributeCode()); // Trigger for attributes marked for orphan_removal, default true for embedded if ($attribute->getOption('orphan_removal', $attribute->getType()->isEmbedded())) { $args->getEntityManager()->remove($value->getValueData()); } }
php
public function preRemove(LifecycleEventArgs $args) { $value = $args->getEntity(); if (!$value instanceof ValueInterface) { return; } // Ignore removed families if (!$this->familyRegistry->hasFamily($value->getFamilyCode())) { return; } $family = $this->familyRegistry->getFamily($value->getFamilyCode()); // Ignore removed attributes if (!$family->hasAttribute($value->getAttributeCode())) { return; } $attribute = $family->getAttribute($value->getAttributeCode()); // Trigger for attributes marked for orphan_removal, default true for embedded if ($attribute->getOption('orphan_removal', $attribute->getType()->isEmbedded())) { $args->getEntityManager()->remove($value->getValueData()); } }
[ "public", "function", "preRemove", "(", "LifecycleEventArgs", "$", "args", ")", "{", "$", "value", "=", "$", "args", "->", "getEntity", "(", ")", ";", "if", "(", "!", "$", "value", "instanceof", "ValueInterface", ")", "{", "return", ";", "}", "// Ignore ...
@param LifecycleEventArgs $args @throws \Doctrine\ORM\ORMInvalidArgumentException @throws \Sidus\EAVModelBundle\Exception\MissingAttributeException @throws \Sidus\EAVModelBundle\Exception\MissingFamilyException @throws \Doctrine\ORM\ORMException
[ "@param", "LifecycleEventArgs", "$args" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Event/OrphanEmbedRemovalListener.php#L49-L72
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.getIdentifier
public function getIdentifier() { $identifierAttribute = $this->getFamily()->getAttributeAsIdentifier(); if ($identifierAttribute) { /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ return $this->get($identifierAttribute->getCode()); } return $this->getId(); }
php
public function getIdentifier() { $identifierAttribute = $this->getFamily()->getAttributeAsIdentifier(); if ($identifierAttribute) { /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ return $this->get($identifierAttribute->getCode()); } return $this->getId(); }
[ "public", "function", "getIdentifier", "(", ")", "{", "$", "identifierAttribute", "=", "$", "this", "->", "getFamily", "(", ")", "->", "getAttributeAsIdentifier", "(", ")", ";", "if", "(", "$", "identifierAttribute", ")", "{", "/** @noinspection ExceptionsAnnotati...
@throws InvalidValueDataException @return mixed
[ "@throws", "InvalidValueDataException" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L157-L167
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.addValueData
public function addValueData(AttributeInterface $attribute, $valueData, array $context = null) { $this->checkAttribute($attribute); if (!$attribute->isCollection()) { $m = "Cannot append data to a non-collection attribute '{$attribute->getCode()}'"; throw new InvalidValueDataException($m); } $newValue = $this->createValue($attribute, $context); $position = -1; foreach ($this->getInternalValues($attribute, $context) as $value) { $position = max($position, $value->getPosition()); } $newValue->setPosition($position + 1); $this->setInternalValueData($attribute, $newValue, $valueData); return $this; }
php
public function addValueData(AttributeInterface $attribute, $valueData, array $context = null) { $this->checkAttribute($attribute); if (!$attribute->isCollection()) { $m = "Cannot append data to a non-collection attribute '{$attribute->getCode()}'"; throw new InvalidValueDataException($m); } $newValue = $this->createValue($attribute, $context); $position = -1; foreach ($this->getInternalValues($attribute, $context) as $value) { $position = max($position, $value->getPosition()); } $newValue->setPosition($position + 1); $this->setInternalValueData($attribute, $newValue, $valueData); return $this; }
[ "public", "function", "addValueData", "(", "AttributeInterface", "$", "attribute", ",", "$", "valueData", ",", "array", "$", "context", "=", "null", ")", "{", "$", "this", "->", "checkAttribute", "(", "$", "attribute", ")", ";", "if", "(", "!", "$", "att...
Append data to an attribute @param AttributeInterface $attribute @param mixed $valueData @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return DataInterface
[ "Append", "data", "to", "an", "attribute" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L246-L262
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.removeValueData
public function removeValueData(AttributeInterface $attribute, $valueData, array $context = null) { $this->checkAttribute($attribute); if (!$attribute->isCollection()) { $m = "Cannot remove data from a non-collection attribute '{$attribute->getCode()}'"; throw new InvalidValueDataException($m); } foreach ($this->getValues($attribute, $context) as $value) { try { if ($value->getValueData() === $valueData) { $this->removeValue($value); break; } } catch (ExceptionInterface $e) { throw new InvalidValueDataException("Invalid data for attribute {$attribute->getCode()}", 0, $e); } } return $this; }
php
public function removeValueData(AttributeInterface $attribute, $valueData, array $context = null) { $this->checkAttribute($attribute); if (!$attribute->isCollection()) { $m = "Cannot remove data from a non-collection attribute '{$attribute->getCode()}'"; throw new InvalidValueDataException($m); } foreach ($this->getValues($attribute, $context) as $value) { try { if ($value->getValueData() === $valueData) { $this->removeValue($value); break; } } catch (ExceptionInterface $e) { throw new InvalidValueDataException("Invalid data for attribute {$attribute->getCode()}", 0, $e); } } return $this; }
[ "public", "function", "removeValueData", "(", "AttributeInterface", "$", "attribute", ",", "$", "valueData", ",", "array", "$", "context", "=", "null", ")", "{", "$", "this", "->", "checkAttribute", "(", "$", "attribute", ")", ";", "if", "(", "!", "$", "...
Remove a data from an attribute @param AttributeInterface $attribute @param mixed $valueData @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return DataInterface
[ "Remove", "a", "data", "from", "an", "attribute" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L277-L296
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.getLabel
public function getLabel(array $context = null) { if ($this->getFamily()->hasAttribute('label')) { return $this->getValueData($this->getAttribute('label'), $context); } $label = null; try { $label = $this->getLabelValue($context); } catch (\Exception $e) { } if (null === $label && $this->getIdentifier()) { $label = "[{$this->getIdentifier()}]"; } return $label; }
php
public function getLabel(array $context = null) { if ($this->getFamily()->hasAttribute('label')) { return $this->getValueData($this->getAttribute('label'), $context); } $label = null; try { $label = $this->getLabelValue($context); } catch (\Exception $e) { } if (null === $label && $this->getIdentifier()) { $label = "[{$this->getIdentifier()}]"; } return $label; }
[ "public", "function", "getLabel", "(", "array", "$", "context", "=", "null", ")", "{", "if", "(", "$", "this", "->", "getFamily", "(", ")", "->", "hasAttribute", "(", "'label'", ")", ")", "{", "return", "$", "this", "->", "getValueData", "(", "$", "t...
@param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return string
[ "@param", "array|null", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L307-L322
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.getValueData
public function getValueData(AttributeInterface $attribute, array $context = null) { $valuesData = $this->getValuesData($attribute, $context); return 0 === \count($valuesData) ? null : $valuesData->first(); }
php
public function getValueData(AttributeInterface $attribute, array $context = null) { $valuesData = $this->getValuesData($attribute, $context); return 0 === \count($valuesData) ? null : $valuesData->first(); }
[ "public", "function", "getValueData", "(", "AttributeInterface", "$", "attribute", ",", "array", "$", "context", "=", "null", ")", "{", "$", "valuesData", "=", "$", "this", "->", "getValuesData", "(", "$", "attribute", ",", "$", "context", ")", ";", "retur...
Get the value data of the value matching the attribute @param AttributeInterface $attribute @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return mixed
[ "Get", "the", "value", "data", "of", "the", "value", "matching", "the", "attribute" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L336-L341
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.getValuesData
public function getValuesData(AttributeInterface $attribute, array $context = null) { $this->checkAttribute($attribute); $valuesData = new ArrayCollection(); try { foreach ($this->getValues($attribute, $context) as $value) { $valuesData->add($value->getValueData()); } } catch (ExceptionInterface $e) { throw new InvalidValueDataException("Unable to access data for attribute {$attribute->getCode()}", 0, $e); } return $valuesData; }
php
public function getValuesData(AttributeInterface $attribute, array $context = null) { $this->checkAttribute($attribute); $valuesData = new ArrayCollection(); try { foreach ($this->getValues($attribute, $context) as $value) { $valuesData->add($value->getValueData()); } } catch (ExceptionInterface $e) { throw new InvalidValueDataException("Unable to access data for attribute {$attribute->getCode()}", 0, $e); } return $valuesData; }
[ "public", "function", "getValuesData", "(", "AttributeInterface", "$", "attribute", ",", "array", "$", "context", "=", "null", ")", "{", "$", "this", "->", "checkAttribute", "(", "$", "attribute", ")", ";", "$", "valuesData", "=", "new", "ArrayCollection", "...
Get the values data of multiple values for a given attribute @param AttributeInterface $attribute @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return ArrayCollection
[ "Get", "the", "values", "data", "of", "multiple", "values", "for", "a", "given", "attribute" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L355-L369
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.get
public function get($attributeCode, array $context = null) { $attribute = $this->getAttribute($attributeCode); $getter = 'get'.ucfirst($attributeCode); if (method_exists($this, $getter)) { return $this->$getter($context); } if ($attribute->isCollection()) { return $this->getValuesData($attribute, $context); } return $this->getValueData($attribute, $context); }
php
public function get($attributeCode, array $context = null) { $attribute = $this->getAttribute($attributeCode); $getter = 'get'.ucfirst($attributeCode); if (method_exists($this, $getter)) { return $this->$getter($context); } if ($attribute->isCollection()) { return $this->getValuesData($attribute, $context); } return $this->getValueData($attribute, $context); }
[ "public", "function", "get", "(", "$", "attributeCode", ",", "array", "$", "context", "=", "null", ")", "{", "$", "attribute", "=", "$", "this", "->", "getAttribute", "(", "$", "attributeCode", ")", ";", "$", "getter", "=", "'get'", ".", "ucfirst", "("...
Used to get values in a simple way @param string $attributeCode @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return mixed
[ "Used", "to", "get", "values", "in", "a", "simple", "way" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L457-L471
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.set
public function set($attributeCode, $value, array $context = null) { $attribute = $this->getAttribute($attributeCode); $method = 'set'.ucfirst($attributeCode); if (method_exists($this, $method)) { return $this->$method($value, $context); } if ($attribute->isCollection()) { return $this->setValuesData($attribute, $value, $context); } return $this->setValueData($attribute, $value, $context); }
php
public function set($attributeCode, $value, array $context = null) { $attribute = $this->getAttribute($attributeCode); $method = 'set'.ucfirst($attributeCode); if (method_exists($this, $method)) { return $this->$method($value, $context); } if ($attribute->isCollection()) { return $this->setValuesData($attribute, $value, $context); } return $this->setValueData($attribute, $value, $context); }
[ "public", "function", "set", "(", "$", "attributeCode", ",", "$", "value", ",", "array", "$", "context", "=", "null", ")", "{", "$", "attribute", "=", "$", "this", "->", "getAttribute", "(", "$", "attributeCode", ")", ";", "$", "method", "=", "'set'", ...
Used to set values as in a simple way @param string $attributeCode @param mixed $value @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return DataInterface
[ "Used", "to", "set", "values", "as", "in", "a", "simple", "way" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L500-L514
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.add
public function add($attributeCode, $value, array $context = null) { $attribute = $this->getAttribute($attributeCode); $method = 'add'.ucfirst($attributeCode); if (method_exists($this, $method)) { return $this->$method($value, $context); } return $this->addValueData($attribute, $value, $context); }
php
public function add($attributeCode, $value, array $context = null) { $attribute = $this->getAttribute($attributeCode); $method = 'add'.ucfirst($attributeCode); if (method_exists($this, $method)) { return $this->$method($value, $context); } return $this->addValueData($attribute, $value, $context); }
[ "public", "function", "add", "(", "$", "attributeCode", ",", "$", "value", ",", "array", "$", "context", "=", "null", ")", "{", "$", "attribute", "=", "$", "this", "->", "getAttribute", "(", "$", "attributeCode", ")", ";", "$", "method", "=", "'add'", ...
Append a new value to a collection @param string $attributeCode @param mixed $value @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return DataInterface
[ "Append", "a", "new", "value", "to", "a", "collection" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L554-L564
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.remove
public function remove($attributeCode, $value, array $context = null) { $attribute = $this->getAttribute($attributeCode); $method = 'remove'.ucfirst($attributeCode); if (method_exists($this, $method)) { return $this->$method($value, $context); } return $this->removeValueData($attribute, $value, $context); }
php
public function remove($attributeCode, $value, array $context = null) { $attribute = $this->getAttribute($attributeCode); $method = 'remove'.ucfirst($attributeCode); if (method_exists($this, $method)) { return $this->$method($value, $context); } return $this->removeValueData($attribute, $value, $context); }
[ "public", "function", "remove", "(", "$", "attributeCode", ",", "$", "value", ",", "array", "$", "context", "=", "null", ")", "{", "$", "attribute", "=", "$", "this", "->", "getAttribute", "(", "$", "attributeCode", ")", ";", "$", "method", "=", "'remo...
Search the value in the collection and remove it @param string $attributeCode @param mixed $value @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return DataInterface
[ "Search", "the", "value", "in", "the", "collection", "and", "remove", "it" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L579-L589
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.getValue
public function getValue(AttributeInterface $attribute, array $context = null) { $values = $this->getValues($attribute, $context); return 0 === \count($values) ? null : $values->first(); }
php
public function getValue(AttributeInterface $attribute, array $context = null) { $values = $this->getValues($attribute, $context); return 0 === \count($values) ? null : $values->first(); }
[ "public", "function", "getValue", "(", "AttributeInterface", "$", "attribute", ",", "array", "$", "context", "=", "null", ")", "{", "$", "values", "=", "$", "this", "->", "getValues", "(", "$", "attribute", ",", "$", "context", ")", ";", "return", "0", ...
Return first value found for attribute code in value collection @param AttributeInterface $attribute @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return null|ValueInterface
[ "Return", "first", "value", "found", "for", "attribute", "code", "in", "value", "collection" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L603-L608
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.getValues
public function getValues(AttributeInterface $attribute = null, array $context = null) { $values = $this->getInternalValues($attribute, $context); if ($attribute && 0 === \count($values) && null !== $attribute->getDefault()) { return $this->createDefaultValues($attribute, $context); } return $values; }
php
public function getValues(AttributeInterface $attribute = null, array $context = null) { $values = $this->getInternalValues($attribute, $context); if ($attribute && 0 === \count($values) && null !== $attribute->getDefault()) { return $this->createDefaultValues($attribute, $context); } return $values; }
[ "public", "function", "getValues", "(", "AttributeInterface", "$", "attribute", "=", "null", ",", "array", "$", "context", "=", "null", ")", "{", "$", "values", "=", "$", "this", "->", "getInternalValues", "(", "$", "attribute", ",", "$", "context", ")", ...
Return all values matching the attribute code @param AttributeInterface|null $attribute @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return Collection|ValueInterface[]
[ "Return", "all", "values", "matching", "the", "attribute", "code" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L622-L631
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.getRefererValues
public function getRefererValues( FamilyInterface $family = null, AttributeInterface $attribute = null, array $context = null ) { if (null === $family && null === $attribute && null === $context) { return $this->refererValues; } $values = new ArrayCollection(); if ($context) { $context = array_merge($this->getCurrentContext(), $context); } foreach ($this->refererValues as $refererValue) { if ($attribute && $attribute->getCode() !== $refererValue->getAttributeCode()) { continue; } if ($family && $family->getCode() !== $refererValue->getData()->getFamilyCode()) { continue; } if ($context && !$refererValue->getAttribute()->isContextMatching($refererValue, $context)) { continue; } $values[] = $refererValue; } return $values; }
php
public function getRefererValues( FamilyInterface $family = null, AttributeInterface $attribute = null, array $context = null ) { if (null === $family && null === $attribute && null === $context) { return $this->refererValues; } $values = new ArrayCollection(); if ($context) { $context = array_merge($this->getCurrentContext(), $context); } foreach ($this->refererValues as $refererValue) { if ($attribute && $attribute->getCode() !== $refererValue->getAttributeCode()) { continue; } if ($family && $family->getCode() !== $refererValue->getData()->getFamilyCode()) { continue; } if ($context && !$refererValue->getAttribute()->isContextMatching($refererValue, $context)) { continue; } $values[] = $refererValue; } return $values; }
[ "public", "function", "getRefererValues", "(", "FamilyInterface", "$", "family", "=", "null", ",", "AttributeInterface", "$", "attribute", "=", "null", ",", "array", "$", "context", "=", "null", ")", "{", "if", "(", "null", "===", "$", "family", "&&", "nul...
@param FamilyInterface|null $family @param AttributeInterface|null $attribute @param array|null $context @throws ContextException @return Collection|ValueInterface[]
[ "@param", "FamilyInterface|null", "$family", "@param", "AttributeInterface|null", "$attribute", "@param", "array|null", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L642-L669
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.getRefererDatas
public function getRefererDatas( FamilyInterface $family = null, AttributeInterface $attribute = null, array $context = null ) { $datas = new ArrayCollection(); foreach ($this->getRefererValues($family, $attribute, $context) as $refererValue) { $data = $refererValue->getData(); if ($data) { $datas[] = $data; } } return $datas; }
php
public function getRefererDatas( FamilyInterface $family = null, AttributeInterface $attribute = null, array $context = null ) { $datas = new ArrayCollection(); foreach ($this->getRefererValues($family, $attribute, $context) as $refererValue) { $data = $refererValue->getData(); if ($data) { $datas[] = $data; } } return $datas; }
[ "public", "function", "getRefererDatas", "(", "FamilyInterface", "$", "family", "=", "null", ",", "AttributeInterface", "$", "attribute", "=", "null", ",", "array", "$", "context", "=", "null", ")", "{", "$", "datas", "=", "new", "ArrayCollection", "(", ")",...
@param FamilyInterface|null $family @param AttributeInterface|null $attribute @param array|null $context @throws ContextException @return Collection|DataInterface[]
[ "@param", "FamilyInterface|null", "$family", "@param", "AttributeInterface|null", "$attribute", "@param", "array|null", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L680-L694
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.createValue
public function createValue(AttributeInterface $attribute, array $context = null) { $this->checkAttribute($attribute); return $this->getFamily()->createValue($this, $attribute, $context); }
php
public function createValue(AttributeInterface $attribute, array $context = null) { $this->checkAttribute($attribute); return $this->getFamily()->createValue($this, $attribute, $context); }
[ "public", "function", "createValue", "(", "AttributeInterface", "$", "attribute", ",", "array", "$", "context", "=", "null", ")", "{", "$", "this", "->", "checkAttribute", "(", "$", "attribute", ")", ";", "return", "$", "this", "->", "getFamily", "(", ")",...
@param AttributeInterface $attribute @param array|null $context @throws MissingAttributeException @return ValueInterface
[ "@param", "AttributeInterface", "$attribute", "@param", "array|null", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L740-L745
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.setValuesData
public function setValuesData(AttributeInterface $attribute, $dataValues, array $context = null) { $this->setInternalValuesData($attribute, $dataValues, $context); return $this; }
php
public function setValuesData(AttributeInterface $attribute, $dataValues, array $context = null) { $this->setInternalValuesData($attribute, $dataValues, $context); return $this; }
[ "public", "function", "setValuesData", "(", "AttributeInterface", "$", "attribute", ",", "$", "dataValues", ",", "array", "$", "context", "=", "null", ")", "{", "$", "this", "->", "setInternalValuesData", "(", "$", "attribute", ",", "$", "dataValues", ",", "...
Set the values' data of a given attribute for multiple fields @param AttributeInterface $attribute @param array|\Traversable $dataValues @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return DataInterface
[ "Set", "the", "values", "data", "of", "a", "given", "attribute", "for", "multiple", "fields" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L760-L765
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.emptyValues
public function emptyValues(AttributeInterface $attribute = null, array $context = null) { $values = $this->getInternalValues($attribute, $context); foreach ($values as $value) { $this->removeValue($value); } return $this; }
php
public function emptyValues(AttributeInterface $attribute = null, array $context = null) { $values = $this->getInternalValues($attribute, $context); foreach ($values as $value) { $this->removeValue($value); } return $this; }
[ "public", "function", "emptyValues", "(", "AttributeInterface", "$", "attribute", "=", "null", ",", "array", "$", "context", "=", "null", ")", "{", "$", "values", "=", "$", "this", "->", "getInternalValues", "(", "$", "attribute", ",", "$", "context", ")",...
@param AttributeInterface $attribute @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return DataInterface
[ "@param", "AttributeInterface", "$attribute", "@param", "array|null", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L777-L785
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.removeValue
public function removeValue(ValueInterface $value) { $this->values->removeElement($value); $value->setData(null); $this->removeValueByAttribute($value); return $this; }
php
public function removeValue(ValueInterface $value) { $this->values->removeElement($value); $value->setData(null); $this->removeValueByAttribute($value); return $this; }
[ "public", "function", "removeValue", "(", "ValueInterface", "$", "value", ")", "{", "$", "this", "->", "values", "->", "removeElement", "(", "$", "value", ")", ";", "$", "value", "->", "setData", "(", "null", ")", ";", "$", "this", "->", "removeValueByAt...
@param ValueInterface $value @return DataInterface
[ "@param", "ValueInterface", "$value" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L792-L800
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.addValue
public function addValue(ValueInterface $value) { if ($value instanceof ContextualValueInterface && !$value->getContext()) { $value->setContext($this->getCurrentContext()); } $this->getAttribute($value->getAttributeCode()); // Only to check that the attribute does exists $this->values->add($value); $value->setData($this); $this->addValueByAttribute($value); return $this; }
php
public function addValue(ValueInterface $value) { if ($value instanceof ContextualValueInterface && !$value->getContext()) { $value->setContext($this->getCurrentContext()); } $this->getAttribute($value->getAttributeCode()); // Only to check that the attribute does exists $this->values->add($value); $value->setData($this); $this->addValueByAttribute($value); return $this; }
[ "public", "function", "addValue", "(", "ValueInterface", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "ContextualValueInterface", "&&", "!", "$", "value", "->", "getContext", "(", ")", ")", "{", "$", "value", "->", "setContext", "(", "$",...
@param ValueInterface $value @throws ContextException @throws MissingAttributeException @return DataInterface
[ "@param", "ValueInterface", "$value" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L810-L823
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.setValueData
public function setValueData(AttributeInterface $attribute, $dataValue, array $context = null) { return $this->setValuesData($attribute, [$dataValue], $context); }
php
public function setValueData(AttributeInterface $attribute, $dataValue, array $context = null) { return $this->setValuesData($attribute, [$dataValue], $context); }
[ "public", "function", "setValueData", "(", "AttributeInterface", "$", "attribute", ",", "$", "dataValue", ",", "array", "$", "context", "=", "null", ")", "{", "return", "$", "this", "->", "setValuesData", "(", "$", "attribute", ",", "[", "$", "dataValue", ...
Set the value's data of a given attribute @param AttributeInterface $attribute @param mixed $dataValue @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return DataInterface
[ "Set", "the", "value", "s", "data", "of", "a", "given", "attribute" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L838-L841
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.isEmpty
public function isEmpty(AttributeInterface $attribute, array $context = null) { foreach ($this->getValuesData($attribute, $context) as $valueData) { if (null !== $valueData && '' !== $valueData) { return false; } } return true; }
php
public function isEmpty(AttributeInterface $attribute, array $context = null) { foreach ($this->getValuesData($attribute, $context) as $valueData) { if (null !== $valueData && '' !== $valueData) { return false; } } return true; }
[ "public", "function", "isEmpty", "(", "AttributeInterface", "$", "attribute", ",", "array", "$", "context", "=", "null", ")", "{", "foreach", "(", "$", "this", "->", "getValuesData", "(", "$", "attribute", ",", "$", "context", ")", "as", "$", "valueData", ...
@param AttributeInterface $attribute @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return bool
[ "@param", "AttributeInterface", "$attribute", "@param", "array|null", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L853-L862
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.createDefaultValues
protected function createDefaultValues(AttributeInterface $attribute, array $context = null) { $default = $attribute->getDefault(); if (!$attribute->isCollection()) { $default = (array) $default; } return $this->setInternalValuesData($attribute, $default, $context); }
php
protected function createDefaultValues(AttributeInterface $attribute, array $context = null) { $default = $attribute->getDefault(); if (!$attribute->isCollection()) { $default = (array) $default; } return $this->setInternalValuesData($attribute, $default, $context); }
[ "protected", "function", "createDefaultValues", "(", "AttributeInterface", "$", "attribute", ",", "array", "$", "context", "=", "null", ")", "{", "$", "default", "=", "$", "attribute", "->", "getDefault", "(", ")", ";", "if", "(", "!", "$", "attribute", "-...
@param AttributeInterface $attribute @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return Collection|ValueInterface[]
[ "@param", "AttributeInterface", "$attribute", "@param", "array|null", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L970-L978
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.getInternalValues
protected function getInternalValues(AttributeInterface $attribute = null, array $context = null) { if ($context) { $context = array_merge($this->getCurrentContext(), $context); } else { $context = $this->getCurrentContext(); } if (null === $attribute) { $values = new ArrayCollection(); foreach ($this->values as $value) { if (!$this->getFamily()->hasAttribute($value->getAttributeCode())) { $this->removeValue($value); continue; } $attribute = $this->getFamily()->getAttribute($value->getAttributeCode()); if ($attribute->isContextMatching($value, $context)) { $values->add($value); } } return $values; } $this->checkAttribute($attribute); $values = new ArrayCollection(); foreach ($this->getValuesByAttribute($attribute) as $value) { if ($value instanceof ContextualValueInterface) { if ($attribute->isContextMatching($value, $context)) { $values->add($value); } } else { $values->add($value); } } return $values; }
php
protected function getInternalValues(AttributeInterface $attribute = null, array $context = null) { if ($context) { $context = array_merge($this->getCurrentContext(), $context); } else { $context = $this->getCurrentContext(); } if (null === $attribute) { $values = new ArrayCollection(); foreach ($this->values as $value) { if (!$this->getFamily()->hasAttribute($value->getAttributeCode())) { $this->removeValue($value); continue; } $attribute = $this->getFamily()->getAttribute($value->getAttributeCode()); if ($attribute->isContextMatching($value, $context)) { $values->add($value); } } return $values; } $this->checkAttribute($attribute); $values = new ArrayCollection(); foreach ($this->getValuesByAttribute($attribute) as $value) { if ($value instanceof ContextualValueInterface) { if ($attribute->isContextMatching($value, $context)) { $values->add($value); } } else { $values->add($value); } } return $values; }
[ "protected", "function", "getInternalValues", "(", "AttributeInterface", "$", "attribute", "=", "null", ",", "array", "$", "context", "=", "null", ")", "{", "if", "(", "$", "context", ")", "{", "$", "context", "=", "array_merge", "(", "$", "this", "->", ...
@param AttributeInterface|null $attribute @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return Collection|ValueInterface[]
[ "@param", "AttributeInterface|null", "$attribute", "@param", "array|null", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L990-L1027
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.setInternalValuesData
protected function setInternalValuesData(AttributeInterface $attribute, $dataValues, array $context = null) { $this->checkAttribute($attribute); $dataValues = $this->ensureNativeArray($dataValues, $this->getFamilyCode().'.'.$attribute->getCode()); $values = new ArrayCollection(); $position = 0; // Reset position to zero foreach ($this->getInternalValues($attribute, $context) as $value) { // If there values to replace if (\count($dataValues)) { // Extract new values and replaces them one by one $dataValue = array_shift($dataValues); $value->setPosition(++$position); $this->setInternalValueData($attribute, $value, $dataValue); $values->add($value); } else { // If there are too much existing values previously, remove the extra ones $this->removeValue($value); } } // If there are still values to add foreach ($dataValues as $dataValue) { $value = $this->createValue($attribute, $context); $value->setPosition(++$position); $this->setInternalValueData($attribute, $value, $dataValue); $values->add($value); } return $values; }
php
protected function setInternalValuesData(AttributeInterface $attribute, $dataValues, array $context = null) { $this->checkAttribute($attribute); $dataValues = $this->ensureNativeArray($dataValues, $this->getFamilyCode().'.'.$attribute->getCode()); $values = new ArrayCollection(); $position = 0; // Reset position to zero foreach ($this->getInternalValues($attribute, $context) as $value) { // If there values to replace if (\count($dataValues)) { // Extract new values and replaces them one by one $dataValue = array_shift($dataValues); $value->setPosition(++$position); $this->setInternalValueData($attribute, $value, $dataValue); $values->add($value); } else { // If there are too much existing values previously, remove the extra ones $this->removeValue($value); } } // If there are still values to add foreach ($dataValues as $dataValue) { $value = $this->createValue($attribute, $context); $value->setPosition(++$position); $this->setInternalValueData($attribute, $value, $dataValue); $values->add($value); } return $values; }
[ "protected", "function", "setInternalValuesData", "(", "AttributeInterface", "$", "attribute", ",", "$", "dataValues", ",", "array", "$", "context", "=", "null", ")", "{", "$", "this", "->", "checkAttribute", "(", "$", "attribute", ")", ";", "$", "dataValues",...
@param AttributeInterface $attribute @param array|\Traversable $dataValues @param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return Collection|ValueInterface[]
[ "@param", "AttributeInterface", "$attribute", "@param", "array|", "\\", "Traversable", "$dataValues", "@param", "array|null", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L1040-L1070
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.checkAttribute
protected function checkAttribute(AttributeInterface $attribute) { if (!$this->getFamily()->hasAttribute($attribute->getCode())) { throw new MissingAttributeException( "Attribute {$attribute->getCode()} doesn't exists in family {$this->getFamilyCode()}" ); } if ($attribute->getFamily() !== $this->getFamily()) { $m = "Attribute {$attribute->getCode()} (from family '{$attribute->getFamily()->getCode()}') doesn't "; $m .= "belong to this family ('{$this->getFamilyCode()}')"; throw new MissingAttributeException($m); } }
php
protected function checkAttribute(AttributeInterface $attribute) { if (!$this->getFamily()->hasAttribute($attribute->getCode())) { throw new MissingAttributeException( "Attribute {$attribute->getCode()} doesn't exists in family {$this->getFamilyCode()}" ); } if ($attribute->getFamily() !== $this->getFamily()) { $m = "Attribute {$attribute->getCode()} (from family '{$attribute->getFamily()->getCode()}') doesn't "; $m .= "belong to this family ('{$this->getFamilyCode()}')"; throw new MissingAttributeException($m); } }
[ "protected", "function", "checkAttribute", "(", "AttributeInterface", "$", "attribute", ")", "{", "if", "(", "!", "$", "this", "->", "getFamily", "(", ")", "->", "hasAttribute", "(", "$", "attribute", "->", "getCode", "(", ")", ")", ")", "{", "throw", "n...
@param AttributeInterface $attribute @throws MissingAttributeException
[ "@param", "AttributeInterface", "$attribute" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L1094-L1106
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.getLabelValue
protected function getLabelValue(array $context = null) { $attributeAsLabel = $this->getFamily()->getAttributeAsLabel(); if ($attributeAsLabel) { return (string) $this->getValueData($attributeAsLabel, $context); } return (string) $this->getIdentifier(); }
php
protected function getLabelValue(array $context = null) { $attributeAsLabel = $this->getFamily()->getAttributeAsLabel(); if ($attributeAsLabel) { return (string) $this->getValueData($attributeAsLabel, $context); } return (string) $this->getIdentifier(); }
[ "protected", "function", "getLabelValue", "(", "array", "$", "context", "=", "null", ")", "{", "$", "attributeAsLabel", "=", "$", "this", "->", "getFamily", "(", ")", "->", "getAttributeAsLabel", "(", ")", ";", "if", "(", "$", "attributeAsLabel", ")", "{",...
@param array|null $context @throws InvalidValueDataException @throws MissingAttributeException @throws ContextException @return string
[ "@param", "array|null", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L1117-L1125
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.getValuesByAttribute
protected function getValuesByAttribute(AttributeInterface $attribute) { if (null === $this->valuesByAttributes) { $this->valuesByAttributes = []; } if (!array_key_exists($attribute->getCode(), $this->valuesByAttributes)) { $this->valuesByAttributes[$attribute->getCode()] = []; foreach ($this->values as $value) { if ($value->getAttributeCode() === $attribute->getCode()) { $this->addValueByAttribute($value); } } } return $this->valuesByAttributes[$attribute->getCode()]; }
php
protected function getValuesByAttribute(AttributeInterface $attribute) { if (null === $this->valuesByAttributes) { $this->valuesByAttributes = []; } if (!array_key_exists($attribute->getCode(), $this->valuesByAttributes)) { $this->valuesByAttributes[$attribute->getCode()] = []; foreach ($this->values as $value) { if ($value->getAttributeCode() === $attribute->getCode()) { $this->addValueByAttribute($value); } } } return $this->valuesByAttributes[$attribute->getCode()]; }
[ "protected", "function", "getValuesByAttribute", "(", "AttributeInterface", "$", "attribute", ")", "{", "if", "(", "null", "===", "$", "this", "->", "valuesByAttributes", ")", "{", "$", "this", "->", "valuesByAttributes", "=", "[", "]", ";", "}", "if", "(", ...
Cache internally the values indexed by their attribute codes to increase performances @param AttributeInterface $attribute @return ValueInterface[]
[ "Cache", "internally", "the", "values", "indexed", "by", "their", "attribute", "codes", "to", "increase", "performances" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L1134-L1150
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.parseArray
protected function parseArray(AttributeInterface $attribute, $dataValues) { $m = 'AbstractData::parseArray is deprecated and will be removed in a future version, '; $m .= 'use ensureNativeArray instead'; @trigger_error($m, E_USER_DEPRECATED); return $this->ensureNativeArray($dataValues, $this->getFamilyCode().'.'.$attribute->getCode()); }
php
protected function parseArray(AttributeInterface $attribute, $dataValues) { $m = 'AbstractData::parseArray is deprecated and will be removed in a future version, '; $m .= 'use ensureNativeArray instead'; @trigger_error($m, E_USER_DEPRECATED); return $this->ensureNativeArray($dataValues, $this->getFamilyCode().'.'.$attribute->getCode()); }
[ "protected", "function", "parseArray", "(", "AttributeInterface", "$", "attribute", ",", "$", "dataValues", ")", "{", "$", "m", "=", "'AbstractData::parseArray is deprecated and will be removed in a future version, '", ";", "$", "m", ".=", "'use ensureNativeArray instead'", ...
@deprecated Use ensureNativeArray @param AttributeInterface $attribute @param \Traversable|array $dataValues @throws InvalidValueDataException @return array
[ "@deprecated", "Use", "ensureNativeArray" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L1209-L1216
VincentChalnot/SidusEAVModelBundle
Entity/AbstractData.php
AbstractData.ensureNativeArray
protected function ensureNativeArray($dataValues, $path) { if (\is_array($dataValues)) { return $dataValues; } // Converting traversable to standard array if ($dataValues instanceof \Traversable) { $arrayDataValues = []; foreach ($dataValues as $key => $dataValue) { $arrayDataValues[$key] = $dataValue; } return $arrayDataValues; } $type = \is_object($dataValues) ? \get_class($dataValues) : \gettype($dataValues); throw new InvalidValueDataException( "Value for collection for path '{$path}' must be an array, '{$type}' given" ); }
php
protected function ensureNativeArray($dataValues, $path) { if (\is_array($dataValues)) { return $dataValues; } // Converting traversable to standard array if ($dataValues instanceof \Traversable) { $arrayDataValues = []; foreach ($dataValues as $key => $dataValue) { $arrayDataValues[$key] = $dataValue; } return $arrayDataValues; } $type = \is_object($dataValues) ? \get_class($dataValues) : \gettype($dataValues); throw new InvalidValueDataException( "Value for collection for path '{$path}' must be an array, '{$type}' given" ); }
[ "protected", "function", "ensureNativeArray", "(", "$", "dataValues", ",", "$", "path", ")", "{", "if", "(", "\\", "is_array", "(", "$", "dataValues", ")", ")", "{", "return", "$", "dataValues", ";", "}", "// Converting traversable to standard array", "if", "(...
@param array|\Traversable $dataValues @param string $path @throws \Sidus\EAVModelBundle\Exception\InvalidValueDataException @return array
[ "@param", "array|", "\\", "Traversable", "$dataValues", "@param", "string", "$path" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Entity/AbstractData.php#L1226-L1246
VincentChalnot/SidusEAVModelBundle
Context/ContextManager.php
ContextManager.setContext
public function setContext(array $context) { $context = array_merge($this->getDefaultContext(), $context); // Always save to property in service for fallback $this->context = $context; // Try to save the context in session, if ($this->session) { $this->session->set(static::SESSION_KEY, $context); $this->session->save(); } }
php
public function setContext(array $context) { $context = array_merge($this->getDefaultContext(), $context); // Always save to property in service for fallback $this->context = $context; // Try to save the context in session, if ($this->session) { $this->session->set(static::SESSION_KEY, $context); $this->session->save(); } }
[ "public", "function", "setContext", "(", "array", "$", "context", ")", "{", "$", "context", "=", "array_merge", "(", "$", "this", "->", "getDefaultContext", "(", ")", ",", "$", "context", ")", ";", "// Always save to property in service for fallback", "$", "this...
This method is exposed only for command-line applications, please use the context selector form @param array $context @internal Warning, this method will save the context without any checks on the values
[ "This", "method", "is", "exposed", "only", "for", "command", "-", "line", "applications", "please", "use", "the", "context", "selector", "form" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Context/ContextManager.php#L96-L108
VincentChalnot/SidusEAVModelBundle
Context/ContextManager.php
ContextManager.getContextSelectorForm
public function getContextSelectorForm() { if (!$this->contextSelectorForm) { if (!$this->contextSelectorType || !$this->formFactory) { return null; } $formOptions = [ 'action' => $this->requestUri, 'attr' => [ 'novalidate' => 'novalidate', 'class' => 'form-inline', ], ]; $this->contextSelectorForm = $this->formFactory->createNamed( static::SESSION_KEY, $this->contextSelectorType, $this->getContext(), $formOptions ); } return $this->contextSelectorForm; }
php
public function getContextSelectorForm() { if (!$this->contextSelectorForm) { if (!$this->contextSelectorType || !$this->formFactory) { return null; } $formOptions = [ 'action' => $this->requestUri, 'attr' => [ 'novalidate' => 'novalidate', 'class' => 'form-inline', ], ]; $this->contextSelectorForm = $this->formFactory->createNamed( static::SESSION_KEY, $this->contextSelectorType, $this->getContext(), $formOptions ); } return $this->contextSelectorForm; }
[ "public", "function", "getContextSelectorForm", "(", ")", "{", "if", "(", "!", "$", "this", "->", "contextSelectorForm", ")", "{", "if", "(", "!", "$", "this", "->", "contextSelectorType", "||", "!", "$", "this", "->", "formFactory", ")", "{", "return", ...
@throws InvalidOptionsException @return FormInterface
[ "@throws", "InvalidOptionsException" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Context/ContextManager.php#L123-L146
VincentChalnot/SidusEAVModelBundle
Context/ContextManager.php
ContextManager.onKernelRequest
public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); $this->requestUri = $request->getRequestUri(); try { $this->session = $request->getSession(); } catch (\Exception $e) { $this->logger->error("Unable to access session: {$e->getMessage()}"); } if ($this->session) { try { // If context exists in the session, use this information if ($this->session->has(static::SESSION_KEY)) { $this->context = $this->session->get(static::SESSION_KEY); } } catch (\Exception $e) { $this->logger->error("Unable to get context from session: {$e->getMessage()}"); } } $form = $this->getContextSelectorForm(); if (!$form) { return; } $form->handleRequest($request); // Check if form is submitted and redirect to same url in GET if ($form->isSubmitted() && $form->isValid()) { $this->setContext($form->getData()); $redirectResponse = new RedirectResponse($this->requestUri); $event->setResponse($redirectResponse); } }
php
public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); $this->requestUri = $request->getRequestUri(); try { $this->session = $request->getSession(); } catch (\Exception $e) { $this->logger->error("Unable to access session: {$e->getMessage()}"); } if ($this->session) { try { // If context exists in the session, use this information if ($this->session->has(static::SESSION_KEY)) { $this->context = $this->session->get(static::SESSION_KEY); } } catch (\Exception $e) { $this->logger->error("Unable to get context from session: {$e->getMessage()}"); } } $form = $this->getContextSelectorForm(); if (!$form) { return; } $form->handleRequest($request); // Check if form is submitted and redirect to same url in GET if ($form->isSubmitted() && $form->isValid()) { $this->setContext($form->getData()); $redirectResponse = new RedirectResponse($this->requestUri); $event->setResponse($redirectResponse); } }
[ "public", "function", "onKernelRequest", "(", "GetResponseEvent", "$", "event", ")", "{", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "$", "this", "->", "requestUri", "=", "$", "request", "->", "getRequestUri", "(", ")", ";", "t...
Global hook checking if context form was submitted because the context form can appear on any page @param GetResponseEvent $event @throws \InvalidArgumentException
[ "Global", "hook", "checking", "if", "context", "form", "was", "submitted", "because", "the", "context", "form", "can", "appear", "on", "any", "page" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Context/ContextManager.php#L155-L187
VincentChalnot/SidusEAVModelBundle
Model/EAVRelationAttributeType.php
EAVRelationAttributeType.getFormOptions
public function getFormOptions(AttributeInterface $attribute) { $formOptions = parent::getFormOptions($attribute); $formOptions['attribute'] = $attribute; return $formOptions; }
php
public function getFormOptions(AttributeInterface $attribute) { $formOptions = parent::getFormOptions($attribute); $formOptions['attribute'] = $attribute; return $formOptions; }
[ "public", "function", "getFormOptions", "(", "AttributeInterface", "$", "attribute", ")", "{", "$", "formOptions", "=", "parent", "::", "getFormOptions", "(", "$", "attribute", ")", ";", "$", "formOptions", "[", "'attribute'", "]", "=", "$", "attribute", ";", ...
@param AttributeInterface $attribute @return array
[ "@param", "AttributeInterface", "$attribute" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Model/EAVRelationAttributeType.php#L25-L31
VincentChalnot/SidusEAVModelBundle
Request/ParamConverter/DataParamConverter.php
DataParamConverter.convertValue
protected function convertValue($value, ParamConverter $configuration) { if (array_key_exists('family', $configuration->getOptions())) { $family = $this->familyRegistry->getFamily($configuration->getOptions()['family']); if ($family->isSingleton()) { $data = $this->repository->getInstance($family); } else { $data = $this->repository->findByIdentifier($family, $value, true); } } else { $data = $this->repository->find($value); } if ($data) { $this->dataLoader->loadSingle($data, $data->getFamily()->getOption('loader_depth', 2)); } return $data; }
php
protected function convertValue($value, ParamConverter $configuration) { if (array_key_exists('family', $configuration->getOptions())) { $family = $this->familyRegistry->getFamily($configuration->getOptions()['family']); if ($family->isSingleton()) { $data = $this->repository->getInstance($family); } else { $data = $this->repository->findByIdentifier($family, $value, true); } } else { $data = $this->repository->find($value); } if ($data) { $this->dataLoader->loadSingle($data, $data->getFamily()->getOption('loader_depth', 2)); } return $data; }
[ "protected", "function", "convertValue", "(", "$", "value", ",", "ParamConverter", "$", "configuration", ")", "{", "if", "(", "array_key_exists", "(", "'family'", ",", "$", "configuration", "->", "getOptions", "(", ")", ")", ")", "{", "$", "family", "=", "...
@param int|string $value @param ParamConverter $configuration @throws \Doctrine\ORM\NonUniqueResultException @throws \Sidus\EAVModelBundle\Exception\MissingFamilyException @throws \UnexpectedValueException @throws \LogicException @throws ORMException @return null|DataInterface
[ "@param", "int|string", "$value", "@param", "ParamConverter", "$configuration" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Request/ParamConverter/DataParamConverter.php#L68-L85
VincentChalnot/SidusEAVModelBundle
Request/ParamConverter/DataParamConverter.php
DataParamConverter.getRequestAttributeName
protected function getRequestAttributeName(Request $request, ParamConverter $configuration) { $param = parent::getRequestAttributeName($request, $configuration); if (!$request->attributes->has($param)) { if ($request->attributes->has('dataId')) { $param = 'dataId'; } elseif ($request->attributes->has('id')) { $param = 'id'; } } return $param; }
php
protected function getRequestAttributeName(Request $request, ParamConverter $configuration) { $param = parent::getRequestAttributeName($request, $configuration); if (!$request->attributes->has($param)) { if ($request->attributes->has('dataId')) { $param = 'dataId'; } elseif ($request->attributes->has('id')) { $param = 'id'; } } return $param; }
[ "protected", "function", "getRequestAttributeName", "(", "Request", "$", "request", ",", "ParamConverter", "$", "configuration", ")", "{", "$", "param", "=", "parent", "::", "getRequestAttributeName", "(", "$", "request", ",", "$", "configuration", ")", ";", "if...
Allow fallback to "dataId" or "id" in case no attribute is found @deprecated This custom behavior will be deprecated in futur versions @param Request $request @param ParamConverter $configuration @return string
[ "Allow", "fallback", "to", "dataId", "or", "id", "in", "case", "no", "attribute", "is", "found" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Request/ParamConverter/DataParamConverter.php#L105-L117
VincentChalnot/SidusEAVModelBundle
Serializer/Denormalizer/EAVDataDenormalizer.php
EAVDataDenormalizer.denormalize
public function denormalize($data, $class, $format = null, array $context = []) { if ($data instanceof DataInterface) { return $data; // Just in case... } if (empty($data)) { return null; // No need to do anything if the data is empty } $family = $this->getFamily($data, $class, $context); unset($context['family'], $context['family_code'], $context['familyCode']); // Removing family info from context $entity = $this->entityProvider->getEntity($family, $data, $this->nameConverter); if (is_scalar($data)) { return $entity; // In case we are trying to resolve a simple reference } if ($entity instanceof ContextualDataInterface) { if (isset($data['currentContext']) && \is_array($data['currentContext'])) { $entity->setCurrentContext($data['currentContext']); } if (isset($context['context']) && \is_array($context['context'])) { $entity->setCurrentContext($context['context']); } } /** @var array $data At this point we know for sure data is a \ArrayAccess or a PHP array */ foreach ($data as $attributeCode => $value) { if ($this->nameConverter) { $attributeCode = $this->nameConverter->denormalize($attributeCode); } if (!$this->isAllowedAttributes($family, $attributeCode)) { continue; } $this->handleAttributeValue($family, $attributeCode, $entity, $value, $format, $context); } return $entity; }
php
public function denormalize($data, $class, $format = null, array $context = []) { if ($data instanceof DataInterface) { return $data; // Just in case... } if (empty($data)) { return null; // No need to do anything if the data is empty } $family = $this->getFamily($data, $class, $context); unset($context['family'], $context['family_code'], $context['familyCode']); // Removing family info from context $entity = $this->entityProvider->getEntity($family, $data, $this->nameConverter); if (is_scalar($data)) { return $entity; // In case we are trying to resolve a simple reference } if ($entity instanceof ContextualDataInterface) { if (isset($data['currentContext']) && \is_array($data['currentContext'])) { $entity->setCurrentContext($data['currentContext']); } if (isset($context['context']) && \is_array($context['context'])) { $entity->setCurrentContext($context['context']); } } /** @var array $data At this point we know for sure data is a \ArrayAccess or a PHP array */ foreach ($data as $attributeCode => $value) { if ($this->nameConverter) { $attributeCode = $this->nameConverter->denormalize($attributeCode); } if (!$this->isAllowedAttributes($family, $attributeCode)) { continue; } $this->handleAttributeValue($family, $attributeCode, $entity, $value, $format, $context); } return $entity; }
[ "public", "function", "denormalize", "(", "$", "data", ",", "$", "class", ",", "$", "format", "=", "null", ",", "array", "$", "context", "=", "[", "]", ")", "{", "if", "(", "$", "data", "instanceof", "DataInterface", ")", "{", "return", "$", "data", ...
Denormalizes data back into an object of the given class. @param mixed $data data to restore @param string $class the expected class to instantiate @param string $format format the given data was extracted from @param array $context options available to the denormalizer @throws \InvalidArgumentException @throws \Sidus\EAVModelBundle\Exception\MissingAttributeException @throws SerializerExceptionInterface @return DataInterface
[ "Denormalizes", "data", "back", "into", "an", "object", "of", "the", "given", "class", "." ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Serializer/Denormalizer/EAVDataDenormalizer.php#L111-L147
VincentChalnot/SidusEAVModelBundle
Serializer/Denormalizer/EAVDataDenormalizer.php
EAVDataDenormalizer.handleAttributeValue
protected function handleAttributeValue( FamilyInterface $family, $attributeCode, DataInterface $entity, $normalizedValue, $format, array $context ) { if (null === $normalizedValue) { $value = null; } elseif ($family->hasAttribute($attributeCode)) { $attribute = $family->getAttribute($attributeCode); if ($attribute->isCollection()) { if (!\is_array($normalizedValue) && !$normalizedValue instanceof \Traversable) { throw new UnexpectedValueException( "Given data should be an array of values for attribute '{$attributeCode}'" ); } $value = new ArrayCollection(); /** @var array $normalizedValue */ foreach ($normalizedValue as $item) { $value[] = $this->denormalizeEAVAttribute( $family, $attribute, $item, $format, $context ); } } else { $value = $this->denormalizeEAVAttribute( $family, $attribute, $normalizedValue, $format, $context ); } } else { $value = $this->denormalizeAttribute( $family, $attributeCode, $normalizedValue, $format, $context ); } $this->accessor->setValue($entity, $attributeCode, $value); }
php
protected function handleAttributeValue( FamilyInterface $family, $attributeCode, DataInterface $entity, $normalizedValue, $format, array $context ) { if (null === $normalizedValue) { $value = null; } elseif ($family->hasAttribute($attributeCode)) { $attribute = $family->getAttribute($attributeCode); if ($attribute->isCollection()) { if (!\is_array($normalizedValue) && !$normalizedValue instanceof \Traversable) { throw new UnexpectedValueException( "Given data should be an array of values for attribute '{$attributeCode}'" ); } $value = new ArrayCollection(); /** @var array $normalizedValue */ foreach ($normalizedValue as $item) { $value[] = $this->denormalizeEAVAttribute( $family, $attribute, $item, $format, $context ); } } else { $value = $this->denormalizeEAVAttribute( $family, $attribute, $normalizedValue, $format, $context ); } } else { $value = $this->denormalizeAttribute( $family, $attributeCode, $normalizedValue, $format, $context ); } $this->accessor->setValue($entity, $attributeCode, $value); }
[ "protected", "function", "handleAttributeValue", "(", "FamilyInterface", "$", "family", ",", "$", "attributeCode", ",", "DataInterface", "$", "entity", ",", "$", "normalizedValue", ",", "$", "format", ",", "array", "$", "context", ")", "{", "if", "(", "null", ...
@param FamilyInterface $family @param string $attributeCode @param DataInterface $entity @param mixed $normalizedValue @param string $format @param array $context @throws SerializerExceptionInterface @throws \Sidus\EAVModelBundle\Exception\MissingAttributeException @throws \InvalidArgumentException
[ "@param", "FamilyInterface", "$family", "@param", "string", "$attributeCode", "@param", "DataInterface", "$entity", "@param", "mixed", "$normalizedValue", "@param", "string", "$format", "@param", "array", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Serializer/Denormalizer/EAVDataDenormalizer.php#L175-L224
VincentChalnot/SidusEAVModelBundle
Serializer/Denormalizer/EAVDataDenormalizer.php
EAVDataDenormalizer.getFamily
protected function getFamily($data, $class, array $context) { if (\is_array($data) || $data instanceof \ArrayAccess) { foreach (['familyCode', 'family_code', 'family'] as $property) { if (array_key_exists($property, $data) && $data[$property]) { /** @noinspection PhpIncompatibleReturnTypeInspection */ return $this->denormalizer->denormalize($data[$property], FamilyInterface::class, $context); } } } // Check if family information is present in the context if (array_key_exists('family', $context)) { /** @noinspection PhpIncompatibleReturnTypeInspection */ return $this->denormalizer->denormalize($context['family'], FamilyInterface::class, $context); } // Last attempt: try to determine the family from the class $matchingFamilies = []; foreach ($this->familyRegistry->getFamilies() as $family) { if ($family->isInstantiable() && $family->getDataClass() === $class) { $matchingFamilies[] = $family; } } // If there is only ONE family exactly matching the data class, let's use this one if (1 === \count($matchingFamilies)) { return array_pop($matchingFamilies); } throw new UnexpectedValueException("Unable to determine the Family for the class {$class}"); }
php
protected function getFamily($data, $class, array $context) { if (\is_array($data) || $data instanceof \ArrayAccess) { foreach (['familyCode', 'family_code', 'family'] as $property) { if (array_key_exists($property, $data) && $data[$property]) { /** @noinspection PhpIncompatibleReturnTypeInspection */ return $this->denormalizer->denormalize($data[$property], FamilyInterface::class, $context); } } } // Check if family information is present in the context if (array_key_exists('family', $context)) { /** @noinspection PhpIncompatibleReturnTypeInspection */ return $this->denormalizer->denormalize($context['family'], FamilyInterface::class, $context); } // Last attempt: try to determine the family from the class $matchingFamilies = []; foreach ($this->familyRegistry->getFamilies() as $family) { if ($family->isInstantiable() && $family->getDataClass() === $class) { $matchingFamilies[] = $family; } } // If there is only ONE family exactly matching the data class, let's use this one if (1 === \count($matchingFamilies)) { return array_pop($matchingFamilies); } throw new UnexpectedValueException("Unable to determine the Family for the class {$class}"); }
[ "protected", "function", "getFamily", "(", "$", "data", ",", "$", "class", ",", "array", "$", "context", ")", "{", "if", "(", "\\", "is_array", "(", "$", "data", ")", "||", "$", "data", "instanceof", "\\", "ArrayAccess", ")", "{", "foreach", "(", "["...
@param mixed $data @param string $class @param array $context @throws SerializerExceptionInterface @return FamilyInterface
[ "@param", "mixed", "$data", "@param", "string", "$class", "@param", "array", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Serializer/Denormalizer/EAVDataDenormalizer.php#L235-L268
VincentChalnot/SidusEAVModelBundle
Serializer/Denormalizer/EAVDataDenormalizer.php
EAVDataDenormalizer.isAllowedAttributes
protected function isAllowedAttributes(FamilyInterface $family, $attributeCode) { if ('label' === $attributeCode && $family->hasAttribute('label')) { return true; } return !\in_array($attributeCode, $this->ignoredAttributes, true); }
php
protected function isAllowedAttributes(FamilyInterface $family, $attributeCode) { if ('label' === $attributeCode && $family->hasAttribute('label')) { return true; } return !\in_array($attributeCode, $this->ignoredAttributes, true); }
[ "protected", "function", "isAllowedAttributes", "(", "FamilyInterface", "$", "family", ",", "$", "attributeCode", ")", "{", "if", "(", "'label'", "===", "$", "attributeCode", "&&", "$", "family", "->", "hasAttribute", "(", "'label'", ")", ")", "{", "return", ...
@param FamilyInterface $family @param string $attributeCode @return bool
[ "@param", "FamilyInterface", "$family", "@param", "string", "$attributeCode" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Serializer/Denormalizer/EAVDataDenormalizer.php#L276-L283
VincentChalnot/SidusEAVModelBundle
Serializer/Denormalizer/EAVDataDenormalizer.php
EAVDataDenormalizer.denormalizeEAVAttribute
protected function denormalizeEAVAttribute( FamilyInterface $family, AttributeInterface $attribute, $value, $format, array $context ) { $attributeType = $attribute->getType(); $valueMetadata = $this->entityManager->getClassMetadata($family->getValueClass()); $storageField = $attributeType->getDatabaseType(); if ($valueMetadata->hasAssociation($storageField)) { $targetClass = $valueMetadata->getAssociationTargetClass($attributeType->getDatabaseType()); $context['relatedAttribute'] = $attribute; // Add attribute info $allowedFamilies = $attribute->getOption('allowed_families', []); if (1 === \count($allowedFamilies)) { $context['family'] = array_pop($allowedFamilies); } return $this->denormalizeRelation($value, $targetClass, $format, $context); } if ($valueMetadata->hasField($storageField)) { $type = $valueMetadata->getTypeOfField($storageField); if ('datetime' === $type || 'date' === $type) { return $this->denormalizeRelation($value, \DateTime::class, $format, $context); } return $value; } /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ throw new UnexpectedValueException("Unknown database type {$storageField} for family {$family->getCode()}"); }
php
protected function denormalizeEAVAttribute( FamilyInterface $family, AttributeInterface $attribute, $value, $format, array $context ) { $attributeType = $attribute->getType(); $valueMetadata = $this->entityManager->getClassMetadata($family->getValueClass()); $storageField = $attributeType->getDatabaseType(); if ($valueMetadata->hasAssociation($storageField)) { $targetClass = $valueMetadata->getAssociationTargetClass($attributeType->getDatabaseType()); $context['relatedAttribute'] = $attribute; // Add attribute info $allowedFamilies = $attribute->getOption('allowed_families', []); if (1 === \count($allowedFamilies)) { $context['family'] = array_pop($allowedFamilies); } return $this->denormalizeRelation($value, $targetClass, $format, $context); } if ($valueMetadata->hasField($storageField)) { $type = $valueMetadata->getTypeOfField($storageField); if ('datetime' === $type || 'date' === $type) { return $this->denormalizeRelation($value, \DateTime::class, $format, $context); } return $value; } /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ throw new UnexpectedValueException("Unknown database type {$storageField} for family {$family->getCode()}"); }
[ "protected", "function", "denormalizeEAVAttribute", "(", "FamilyInterface", "$", "family", ",", "AttributeInterface", "$", "attribute", ",", "$", "value", ",", "$", "format", ",", "array", "$", "context", ")", "{", "$", "attributeType", "=", "$", "attribute", ...
@param FamilyInterface $family @param AttributeInterface $attribute @param mixed $value @param string $format @param array $context @throws \InvalidArgumentException @throws SerializerExceptionInterface @return mixed
[ "@param", "FamilyInterface", "$family", "@param", "AttributeInterface", "$attribute", "@param", "mixed", "$value", "@param", "string", "$format", "@param", "array", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Serializer/Denormalizer/EAVDataDenormalizer.php#L297-L330
VincentChalnot/SidusEAVModelBundle
Serializer/Denormalizer/EAVDataDenormalizer.php
EAVDataDenormalizer.denormalizeAttribute
protected function denormalizeAttribute( FamilyInterface $family, $attributeCode, $value, $format, array $context ) { // @T0D0 handles standard serializer annotations ? $classMetadata = $this->entityManager->getClassMetadata($family->getDataClass()); if ($classMetadata->hasAssociation($attributeCode)) { $targetClass = $classMetadata->getAssociationTargetClass($attributeCode); return $this->denormalizeRelation($value, $targetClass, $format, $context); } if ($classMetadata->hasField($attributeCode)) { $type = $classMetadata->getTypeOfField($attributeCode); if ('datetime' === $type || 'date' === $type) { return $this->denormalizeRelation($value, \DateTime::class, $format, $context); } } return $value; }
php
protected function denormalizeAttribute( FamilyInterface $family, $attributeCode, $value, $format, array $context ) { // @T0D0 handles standard serializer annotations ? $classMetadata = $this->entityManager->getClassMetadata($family->getDataClass()); if ($classMetadata->hasAssociation($attributeCode)) { $targetClass = $classMetadata->getAssociationTargetClass($attributeCode); return $this->denormalizeRelation($value, $targetClass, $format, $context); } if ($classMetadata->hasField($attributeCode)) { $type = $classMetadata->getTypeOfField($attributeCode); if ('datetime' === $type || 'date' === $type) { return $this->denormalizeRelation($value, \DateTime::class, $format, $context); } } return $value; }
[ "protected", "function", "denormalizeAttribute", "(", "FamilyInterface", "$", "family", ",", "$", "attributeCode", ",", "$", "value", ",", "$", "format", ",", "array", "$", "context", ")", "{", "// @T0D0 handles standard serializer annotations ?", "$", "classMetadata"...
@param FamilyInterface $family @param string $attributeCode @param mixed $value @param string $format @param array $context @throws \InvalidArgumentException @throws SerializerExceptionInterface @return mixed
[ "@param", "FamilyInterface", "$family", "@param", "string", "$attributeCode", "@param", "mixed", "$value", "@param", "string", "$format", "@param", "array", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Serializer/Denormalizer/EAVDataDenormalizer.php#L344-L367
VincentChalnot/SidusEAVModelBundle
Serializer/Denormalizer/EAVDataDenormalizer.php
EAVDataDenormalizer.denormalizeRelation
protected function denormalizeRelation($value, $targetClass, $format, array $context) { if (null === $value || '' === $value) { return null; } return $this->denormalizer->denormalize($value, $targetClass, $format, $context); }
php
protected function denormalizeRelation($value, $targetClass, $format, array $context) { if (null === $value || '' === $value) { return null; } return $this->denormalizer->denormalize($value, $targetClass, $format, $context); }
[ "protected", "function", "denormalizeRelation", "(", "$", "value", ",", "$", "targetClass", ",", "$", "format", ",", "array", "$", "context", ")", "{", "if", "(", "null", "===", "$", "value", "||", "''", "===", "$", "value", ")", "{", "return", "null",...
@param string $value @param string $targetClass @param string $format @param array $context @throws SerializerExceptionInterface @return mixed
[ "@param", "string", "$value", "@param", "string", "$targetClass", "@param", "string", "$format", "@param", "array", "$context" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Serializer/Denormalizer/EAVDataDenormalizer.php#L380-L387
VincentChalnot/SidusEAVModelBundle
Registry/AttributeTypeRegistry.php
AttributeTypeRegistry.getType
public function getType($code) { if (!$this->hasType($code)) { throw new MissingAttributeTypeException($code); } return $this->types[$code]; }
php
public function getType($code) { if (!$this->hasType($code)) { throw new MissingAttributeTypeException($code); } return $this->types[$code]; }
[ "public", "function", "getType", "(", "$", "code", ")", "{", "if", "(", "!", "$", "this", "->", "hasType", "(", "$", "code", ")", ")", "{", "throw", "new", "MissingAttributeTypeException", "(", "$", "code", ")", ";", "}", "return", "$", "this", "->",...
@param string $code @throws UnexpectedValueException @return AttributeTypeInterface
[ "@param", "string", "$code" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Registry/AttributeTypeRegistry.php#L50-L57
VincentChalnot/SidusEAVModelBundle
Doctrine/AttributeQueryBuilder.php
AttributeQueryBuilder.getDQL
public function getDQL() { if (null === $this->dql) { $msg = "No condition applied on attribute query builder for attribute {$this->attribute->getCode()}"; throw new \LogicException($msg); } if (!$this->joinApplied) { $this->applyJoin(); } return $this->dql; }
php
public function getDQL() { if (null === $this->dql) { $msg = "No condition applied on attribute query builder for attribute {$this->attribute->getCode()}"; throw new \LogicException($msg); } if (!$this->joinApplied) { $this->applyJoin(); } return $this->dql; }
[ "public", "function", "getDQL", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "dql", ")", "{", "$", "msg", "=", "\"No condition applied on attribute query builder for attribute {$this->attribute->getCode()}\"", ";", "throw", "new", "\\", "LogicException"...
@throws \LogicException @throws \Sidus\EAVModelBundle\Exception\MissingFamilyException @return string
[ "@throws", "\\", "LogicException", "@throws", "\\", "Sidus", "\\", "EAVModelBundle", "\\", "Exception", "\\", "MissingFamilyException" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Doctrine/AttributeQueryBuilder.php#L72-L83
VincentChalnot/SidusEAVModelBundle
Doctrine/AttributeQueryBuilder.php
AttributeQueryBuilder.between
public function between($lower, $upper) { $lowerParameterName = $this->generateUniqueId(); $upperParameterName = $this->generateUniqueId(); return $this->rawDQL( "{$this->getColumn()} BETWEEN :{$lowerParameterName} AND :{$upperParameterName}", [ $lowerParameterName => $lower, $upperParameterName => $upper, ] ); }
php
public function between($lower, $upper) { $lowerParameterName = $this->generateUniqueId(); $upperParameterName = $this->generateUniqueId(); return $this->rawDQL( "{$this->getColumn()} BETWEEN :{$lowerParameterName} AND :{$upperParameterName}", [ $lowerParameterName => $lower, $upperParameterName => $upper, ] ); }
[ "public", "function", "between", "(", "$", "lower", ",", "$", "upper", ")", "{", "$", "lowerParameterName", "=", "$", "this", "->", "generateUniqueId", "(", ")", ";", "$", "upperParameterName", "=", "$", "this", "->", "generateUniqueId", "(", ")", ";", "...
@param mixed $lower @param mixed $upper @throws \LogicException @return AttributeQueryBuilderInterface
[ "@param", "mixed", "$lower", "@param", "mixed", "$upper" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Doctrine/AttributeQueryBuilder.php#L235-L247
VincentChalnot/SidusEAVModelBundle
Doctrine/AttributeQueryBuilder.php
AttributeQueryBuilder.notBetween
public function notBetween($lower, $upper) { $lowerParameterName = $this->generateUniqueId(); $upperParameterName = $this->generateUniqueId(); return $this->rawDQL( "{$this->getColumn()} NOT BETWEEN :{$lowerParameterName} AND :{$upperParameterName}", [ $lowerParameterName => $lower, $upperParameterName => $upper, ] ); }
php
public function notBetween($lower, $upper) { $lowerParameterName = $this->generateUniqueId(); $upperParameterName = $this->generateUniqueId(); return $this->rawDQL( "{$this->getColumn()} NOT BETWEEN :{$lowerParameterName} AND :{$upperParameterName}", [ $lowerParameterName => $lower, $upperParameterName => $upper, ] ); }
[ "public", "function", "notBetween", "(", "$", "lower", ",", "$", "upper", ")", "{", "$", "lowerParameterName", "=", "$", "this", "->", "generateUniqueId", "(", ")", ";", "$", "upperParameterName", "=", "$", "this", "->", "generateUniqueId", "(", ")", ";", ...
@param mixed $lower @param mixed $upper @throws \LogicException @return AttributeQueryBuilderInterface
[ "@param", "mixed", "$lower", "@param", "mixed", "$upper" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Doctrine/AttributeQueryBuilder.php#L257-L269
VincentChalnot/SidusEAVModelBundle
Doctrine/AttributeQueryBuilder.php
AttributeQueryBuilder.rawDQL
public function rawDQL($dql, array $parameters = []) { if (null !== $this->dql) { throw new \LogicException("Condition as already been applied {$this->dql}"); } $this->dql = $dql; $this->parameters = $parameters; return $this; }
php
public function rawDQL($dql, array $parameters = []) { if (null !== $this->dql) { throw new \LogicException("Condition as already been applied {$this->dql}"); } $this->dql = $dql; $this->parameters = $parameters; return $this; }
[ "public", "function", "rawDQL", "(", "$", "dql", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "dql", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"Condition as already been applied {$thi...
@param string $dql @param array $parameters @throws \LogicException @return AttributeQueryBuilderInterface
[ "@param", "string", "$dql", "@param", "array", "$parameters" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Doctrine/AttributeQueryBuilder.php#L299-L309
VincentChalnot/SidusEAVModelBundle
Doctrine/AttributeQueryBuilder.php
AttributeQueryBuilder.join
public function join($alias = null) { if (null === $alias) { $alias = $this->generateUniqueId('join'); } $this->joinRelation = $alias; $this->applyJoin(); $joinedEAVQb = new EAVQueryBuilder($this->eavQueryBuilder->getQueryBuilder(), $alias); $joinedEAVQb->setContext($this->context); return $joinedEAVQb; }
php
public function join($alias = null) { if (null === $alias) { $alias = $this->generateUniqueId('join'); } $this->joinRelation = $alias; $this->applyJoin(); $joinedEAVQb = new EAVQueryBuilder($this->eavQueryBuilder->getQueryBuilder(), $alias); $joinedEAVQb->setContext($this->context); return $joinedEAVQb; }
[ "public", "function", "join", "(", "$", "alias", "=", "null", ")", "{", "if", "(", "null", "===", "$", "alias", ")", "{", "$", "alias", "=", "$", "this", "->", "generateUniqueId", "(", "'join'", ")", ";", "}", "$", "this", "->", "joinRelation", "="...
Use this attribute to join on a related entity. Returns an EAVQueryBuilder by default but can be used for other Doctrine entities too. @param string $alias @throws \Sidus\EAVModelBundle\Exception\MissingFamilyException @throws \LogicException @return EAVQueryBuilderInterface
[ "Use", "this", "attribute", "to", "join", "on", "a", "related", "entity", ".", "Returns", "an", "EAVQueryBuilder", "by", "default", "but", "can", "be", "used", "for", "other", "Doctrine", "entities", "too", "." ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Doctrine/AttributeQueryBuilder.php#L322-L334
VincentChalnot/SidusEAVModelBundle
Doctrine/AttributeQueryBuilder.php
AttributeQueryBuilder.applyJoin
public function applyJoin() { if ($this->skipJoin) { return $this; } $attributeCode = $this->attribute->getCode(); if ($this->joinApplied) { throw new \LogicException("Join for attribute query builder {$attributeCode} already applied"); } $qb = $this->eavQueryBuilder->getQueryBuilder(); // Join based on attributeCode $attributeParameter = $this->generateUniqueId('attribute'); $qb->setParameter($attributeParameter, $attributeCode); $joinDql = "{$this->joinAlias}.attributeCode = :{$attributeParameter}"; if ($this->enforceFamilyCondition) { $family = $this->attribute->getFamily(); if (!$family) { throw new MissingFamilyException("Unable to resolve family for attribute {$attributeCode}"); } $familyParameter = $this->generateUniqueId('family'); $qb->setParameter($familyParameter, $family->getCode()); $joinDql .= " AND {$this->joinAlias}.familyCode = :{$familyParameter}"; } if ($this->context) { /** @var ContextualValueInterface $valueClass */ $valueClass = $this->attribute->getFamily()->getValueClass(); if (!is_a($valueClass, ContextualValueInterface::class, true)) { throw new ContextException('Unable to filter by context on a non-contextual value class'); } foreach ($this->context as $axis => $axisValues) { if (!\in_array($axis, $valueClass::getContextKeys(), true)) { throw new ContextException("Trying to filter on invalid axis '{$axis}'"); } if (!\in_array($axis, $this->attribute->getContextMask(), true)) { continue; } $axisValueParameter = $this->generateUniqueId($axis.'Axis'); $joinDql .= " AND {$this->joinAlias}.{$axis}"; if (is_array($axisValues)) { $joinDql .= " IN (:{$axisValueParameter})"; } else { $joinDql .= " = :{$axisValueParameter}"; } $qb->setParameter($axisValueParameter, $axisValues); } } $qb->leftJoin( $this->eavQueryBuilder->getAlias().'.values', $this->joinAlias, Join::WITH, $joinDql ); if ($this->joinRelation) { $qb->leftJoin( $this->joinAlias.'.'.$this->attribute->getType()->getDatabaseType(), $this->joinRelation ); } $this->joinApplied = true; return $this; }
php
public function applyJoin() { if ($this->skipJoin) { return $this; } $attributeCode = $this->attribute->getCode(); if ($this->joinApplied) { throw new \LogicException("Join for attribute query builder {$attributeCode} already applied"); } $qb = $this->eavQueryBuilder->getQueryBuilder(); // Join based on attributeCode $attributeParameter = $this->generateUniqueId('attribute'); $qb->setParameter($attributeParameter, $attributeCode); $joinDql = "{$this->joinAlias}.attributeCode = :{$attributeParameter}"; if ($this->enforceFamilyCondition) { $family = $this->attribute->getFamily(); if (!$family) { throw new MissingFamilyException("Unable to resolve family for attribute {$attributeCode}"); } $familyParameter = $this->generateUniqueId('family'); $qb->setParameter($familyParameter, $family->getCode()); $joinDql .= " AND {$this->joinAlias}.familyCode = :{$familyParameter}"; } if ($this->context) { /** @var ContextualValueInterface $valueClass */ $valueClass = $this->attribute->getFamily()->getValueClass(); if (!is_a($valueClass, ContextualValueInterface::class, true)) { throw new ContextException('Unable to filter by context on a non-contextual value class'); } foreach ($this->context as $axis => $axisValues) { if (!\in_array($axis, $valueClass::getContextKeys(), true)) { throw new ContextException("Trying to filter on invalid axis '{$axis}'"); } if (!\in_array($axis, $this->attribute->getContextMask(), true)) { continue; } $axisValueParameter = $this->generateUniqueId($axis.'Axis'); $joinDql .= " AND {$this->joinAlias}.{$axis}"; if (is_array($axisValues)) { $joinDql .= " IN (:{$axisValueParameter})"; } else { $joinDql .= " = :{$axisValueParameter}"; } $qb->setParameter($axisValueParameter, $axisValues); } } $qb->leftJoin( $this->eavQueryBuilder->getAlias().'.values', $this->joinAlias, Join::WITH, $joinDql ); if ($this->joinRelation) { $qb->leftJoin( $this->joinAlias.'.'.$this->attribute->getType()->getDatabaseType(), $this->joinRelation ); } $this->joinApplied = true; return $this; }
[ "public", "function", "applyJoin", "(", ")", "{", "if", "(", "$", "this", "->", "skipJoin", ")", "{", "return", "$", "this", ";", "}", "$", "attributeCode", "=", "$", "this", "->", "attribute", "->", "getCode", "(", ")", ";", "if", "(", "$", "this"...
Apply the join condition on the Query Builder @throws \Sidus\EAVModelBundle\Exception\ContextException @throws \LogicException @throws \Sidus\EAVModelBundle\Exception\MissingFamilyException @return AttributeQueryBuilderInterface
[ "Apply", "the", "join", "condition", "on", "the", "Query", "Builder" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Doctrine/AttributeQueryBuilder.php#L353-L420
VincentChalnot/SidusEAVModelBundle
Doctrine/AttributeQueryBuilder.php
AttributeQueryBuilder.simpleDQLStatement
protected function simpleDQLStatement($operator, $parameter) { $parameterName = $this->generateUniqueId(); return $this->rawDQL( "{$this->getColumn()} {$operator} :{$parameterName}", [ $parameterName => $parameter, ] ); }
php
protected function simpleDQLStatement($operator, $parameter) { $parameterName = $this->generateUniqueId(); return $this->rawDQL( "{$this->getColumn()} {$operator} :{$parameterName}", [ $parameterName => $parameter, ] ); }
[ "protected", "function", "simpleDQLStatement", "(", "$", "operator", ",", "$", "parameter", ")", "{", "$", "parameterName", "=", "$", "this", "->", "generateUniqueId", "(", ")", ";", "return", "$", "this", "->", "rawDQL", "(", "\"{$this->getColumn()} {$operator}...
@param string $operator @param mixed $parameter @throws \LogicException @return AttributeQueryBuilderInterface
[ "@param", "string", "$operator", "@param", "mixed", "$parameter" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Doctrine/AttributeQueryBuilder.php#L450-L460
VincentChalnot/SidusEAVModelBundle
Registry/AttributeRegistry.php
AttributeRegistry.parseGlobalConfig
public function parseGlobalConfig(array $globalConfig) { foreach ($globalConfig as $code => $configuration) { $attribute = $this->createAttribute($code, $configuration); $this->addAttribute($attribute); } }
php
public function parseGlobalConfig(array $globalConfig) { foreach ($globalConfig as $code => $configuration) { $attribute = $this->createAttribute($code, $configuration); $this->addAttribute($attribute); } }
[ "public", "function", "parseGlobalConfig", "(", "array", "$", "globalConfig", ")", "{", "foreach", "(", "$", "globalConfig", "as", "$", "code", "=>", "$", "configuration", ")", "{", "$", "attribute", "=", "$", "this", "->", "createAttribute", "(", "$", "co...
@param array $globalConfig @throws \UnexpectedValueException
[ "@param", "array", "$globalConfig" ]
train
https://github.com/VincentChalnot/SidusEAVModelBundle/blob/6a0e184ac7ed2aead48b05e5f97badac7fe8000f/Registry/AttributeRegistry.php#L86-L92