repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
thelia/core | lib/Thelia/TaxEngine/TaxEngine.php | TaxEngine.getDeliveryCountry | public function getDeliveryCountry()
{
if (null === $this->taxCountry) {
/* is there a logged in customer ? */
/** @var Customer $customer */
if (null !== $customer = $this->getSession()->getCustomerUser()) {
if (null !== $this->getSession()->getOrder()
&& null !== $this->getSession()->getOrder()->getChoosenDeliveryAddress()
&& null !== $currentDeliveryAddress = AddressQuery::create()->findPk($this->getSession()->getOrder()->getChoosenDeliveryAddress())) {
$this->taxCountry = $currentDeliveryAddress->getCountry();
$this->taxState = $currentDeliveryAddress->getState();
} else {
$customerDefaultAddress = $customer->getDefaultAddress();
if (isset($customerDefaultAddress)) {
$this->taxCountry = $customerDefaultAddress->getCountry();
$this->taxState = $customerDefaultAddress->getState();
}
}
}
if (null == $this->taxCountry) {
$this->taxCountry = CountryQuery::create()->findOneByByDefault(1);
$this->taxState = null;
}
}
return $this->taxCountry;
} | php | public function getDeliveryCountry()
{
if (null === $this->taxCountry) {
/* is there a logged in customer ? */
/** @var Customer $customer */
if (null !== $customer = $this->getSession()->getCustomerUser()) {
if (null !== $this->getSession()->getOrder()
&& null !== $this->getSession()->getOrder()->getChoosenDeliveryAddress()
&& null !== $currentDeliveryAddress = AddressQuery::create()->findPk($this->getSession()->getOrder()->getChoosenDeliveryAddress())) {
$this->taxCountry = $currentDeliveryAddress->getCountry();
$this->taxState = $currentDeliveryAddress->getState();
} else {
$customerDefaultAddress = $customer->getDefaultAddress();
if (isset($customerDefaultAddress)) {
$this->taxCountry = $customerDefaultAddress->getCountry();
$this->taxState = $customerDefaultAddress->getState();
}
}
}
if (null == $this->taxCountry) {
$this->taxCountry = CountryQuery::create()->findOneByByDefault(1);
$this->taxState = null;
}
}
return $this->taxCountry;
} | [
"public",
"function",
"getDeliveryCountry",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"taxCountry",
")",
"{",
"/* is there a logged in customer ? */",
"/** @var Customer $customer */",
"if",
"(",
"null",
"!==",
"$",
"customer",
"=",
"$",
"this",
... | Find Tax Country Id
First look for a picked delivery address country
Then look at the current customer default address country
Else look at the default website country
@return null|Country | [
"Find",
"Tax",
"Country",
"Id",
"First",
"look",
"for",
"a",
"picked",
"delivery",
"address",
"country",
"Then",
"look",
"at",
"the",
"current",
"customer",
"default",
"address",
"country",
"Else",
"look",
"at",
"the",
"default",
"website",
"country"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/TaxEngine/TaxEngine.php#L118-L145 | train |
thelia/core | lib/Thelia/Controller/Admin/CategoryController.php | CategoryController.setToggleVisibilityAction | public function setToggleVisibilityAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
$event = new CategoryToggleVisibilityEvent($this->getExistingObject());
try {
$this->dispatch(TheliaEvents::CATEGORY_TOGGLE_VISIBILITY, $event);
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
// Ajax response -> no action
return $this->nullResponse();
} | php | public function setToggleVisibilityAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
$event = new CategoryToggleVisibilityEvent($this->getExistingObject());
try {
$this->dispatch(TheliaEvents::CATEGORY_TOGGLE_VISIBILITY, $event);
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
// Ajax response -> no action
return $this->nullResponse();
} | [
"public",
"function",
"setToggleVisibilityAction",
"(",
")",
"{",
"// Check current user authorization",
"if",
"(",
"null",
"!==",
"$",
"response",
"=",
"$",
"this",
"->",
"checkAuth",
"(",
"$",
"this",
"->",
"resourceCode",
",",
"array",
"(",
")",
",",
"Acces... | Online status toggle category | [
"Online",
"status",
"toggle",
"category"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/CategoryController.php#L247-L265 | train |
thelia/core | lib/Thelia/Controller/Admin/CategoryController.php | CategoryController.addRelatedPictureAction | public function addRelatedPictureAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
return $this->redirectToEditionTemplate();
} | php | public function addRelatedPictureAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
return $this->redirectToEditionTemplate();
} | [
"public",
"function",
"addRelatedPictureAction",
"(",
")",
"{",
"// Check current user authorization",
"if",
"(",
"null",
"!==",
"$",
"response",
"=",
"$",
"this",
"->",
"checkAuth",
"(",
"$",
"this",
"->",
"resourceCode",
",",
"array",
"(",
")",
",",
"AccessM... | Add category pictures
@return \Thelia\Core\HttpFoundation\Response | [
"Add",
"category",
"pictures"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/CategoryController.php#L370-L378 | train |
GrahamCampbell/Analyzer | src/DocProcessor.php | DocProcessor.process | public static function process(array $docs)
{
return self::flatmap(function ($doc) {
return self::flatmap(function ($tag) {
return self::flatmap(function ($type) {
return self::processType($type);
}, self::processTag($tag));
}, $doc->getTags());
}, $docs);
} | php | public static function process(array $docs)
{
return self::flatmap(function ($doc) {
return self::flatmap(function ($tag) {
return self::flatmap(function ($type) {
return self::processType($type);
}, self::processTag($tag));
}, $doc->getTags());
}, $docs);
} | [
"public",
"static",
"function",
"process",
"(",
"array",
"$",
"docs",
")",
"{",
"return",
"self",
"::",
"flatmap",
"(",
"function",
"(",
"$",
"doc",
")",
"{",
"return",
"self",
"::",
"flatmap",
"(",
"function",
"(",
"$",
"tag",
")",
"{",
"return",
"s... | Process an array of phpdoc.
Returns FQCN strings for each reference.
@param \phpDocumentor\Reflection\DocBlock[] $docs
@return string[] | [
"Process",
"an",
"array",
"of",
"phpdoc",
"."
] | e918797f052c001362bda65e7364026910608bef | https://github.com/GrahamCampbell/Analyzer/blob/e918797f052c001362bda65e7364026910608bef/src/DocProcessor.php#L39-L48 | train |
GrahamCampbell/Analyzer | src/DocProcessor.php | DocProcessor.processTag | private static function processTag(BaseTag $tag)
{
$types = [];
if (method_exists($tag, 'getType') && is_callable([$tag, 'getType'])) {
if (($type = $tag->getType()) !== null) {
$types[] = $type;
}
}
if (method_exists($tag, 'getArguments') && is_callable([$tag, 'getArguments'])) {
foreach ($tag->getArguments() as $param) {
if (($type = $param['type'] ?? null) !== null) {
$types[] = $type;
}
}
}
return $types;
} | php | private static function processTag(BaseTag $tag)
{
$types = [];
if (method_exists($tag, 'getType') && is_callable([$tag, 'getType'])) {
if (($type = $tag->getType()) !== null) {
$types[] = $type;
}
}
if (method_exists($tag, 'getArguments') && is_callable([$tag, 'getArguments'])) {
foreach ($tag->getArguments() as $param) {
if (($type = $param['type'] ?? null) !== null) {
$types[] = $type;
}
}
}
return $types;
} | [
"private",
"static",
"function",
"processTag",
"(",
"BaseTag",
"$",
"tag",
")",
"{",
"$",
"types",
"=",
"[",
"]",
";",
"if",
"(",
"method_exists",
"(",
"$",
"tag",
",",
"'getType'",
")",
"&&",
"is_callable",
"(",
"[",
"$",
"tag",
",",
"'getType'",
"]... | Process a tag into types.
@param \phpDocumentor\Reflection\DocBlock\Tags\BaseTag $tag
@return \phpDocumentor\Reflection\Type[] | [
"Process",
"a",
"tag",
"into",
"types",
"."
] | e918797f052c001362bda65e7364026910608bef | https://github.com/GrahamCampbell/Analyzer/blob/e918797f052c001362bda65e7364026910608bef/src/DocProcessor.php#L74-L93 | train |
GrahamCampbell/Analyzer | src/DocProcessor.php | DocProcessor.processType | private static function processType(Type $type)
{
// TODO type-resolver v1 compat
// if ($type instanceof AbstractList) {
if ($type instanceof Array_) {
return self::flatmap(function ($t) {
return self::processType($t);
}, [$type->getKeyType(), $type->getValueType()]);
}
if ($type instanceof Compound) {
return self::flatmap(function ($t) {
return self::processType($t);
}, iterator_to_array($type));
}
if ($type instanceof Nullable) {
return self::processType($type->getActualType());
}
if ($type instanceof Object_) {
if (($fq = $type->getFqsen()) !== null) {
return [ltrim((string) $fq, '\\')];
}
}
return [];
} | php | private static function processType(Type $type)
{
// TODO type-resolver v1 compat
// if ($type instanceof AbstractList) {
if ($type instanceof Array_) {
return self::flatmap(function ($t) {
return self::processType($t);
}, [$type->getKeyType(), $type->getValueType()]);
}
if ($type instanceof Compound) {
return self::flatmap(function ($t) {
return self::processType($t);
}, iterator_to_array($type));
}
if ($type instanceof Nullable) {
return self::processType($type->getActualType());
}
if ($type instanceof Object_) {
if (($fq = $type->getFqsen()) !== null) {
return [ltrim((string) $fq, '\\')];
}
}
return [];
} | [
"private",
"static",
"function",
"processType",
"(",
"Type",
"$",
"type",
")",
"{",
"// TODO type-resolver v1 compat",
"// if ($type instanceof AbstractList) {",
"if",
"(",
"$",
"type",
"instanceof",
"Array_",
")",
"{",
"return",
"self",
"::",
"flatmap",
"(",
"funct... | Process a type into FQCN strings.
@param \phpDocumentor\Reflection\Type $type
@return string[] | [
"Process",
"a",
"type",
"into",
"FQCN",
"strings",
"."
] | e918797f052c001362bda65e7364026910608bef | https://github.com/GrahamCampbell/Analyzer/blob/e918797f052c001362bda65e7364026910608bef/src/DocProcessor.php#L102-L129 | train |
thelia/core | lib/Thelia/Core/Template/Element/BaseLoop.php | BaseLoop.initialize | protected function initialize()
{
$class = \get_class($this);
if (null === self::$loopDefinitions) {
self::$loopDefinitions = \array_flip($this->container->getParameter('thelia.parser.loops'));
}
if (isset(self::$loopDefinitions[$class])) {
$this->loopName = self::$loopDefinitions[$class];
}
if (!isset(self::$loopDefinitionsArgs[$class])) {
$this->args = $this->getArgDefinitions()->addArguments($this->getDefaultArgs(), false);
$eventName = $this->getDispatchEventName(TheliaEvents::LOOP_EXTENDS_ARG_DEFINITIONS);
if (null !== $eventName) {
$this->dispatcher->dispatch(
$eventName,
new LoopExtendsArgDefinitionsEvent($this)
);
};
self::$loopDefinitionsArgs[$class] = $this->args;
}
$this->args = self::$loopDefinitionsArgs[$class];
} | php | protected function initialize()
{
$class = \get_class($this);
if (null === self::$loopDefinitions) {
self::$loopDefinitions = \array_flip($this->container->getParameter('thelia.parser.loops'));
}
if (isset(self::$loopDefinitions[$class])) {
$this->loopName = self::$loopDefinitions[$class];
}
if (!isset(self::$loopDefinitionsArgs[$class])) {
$this->args = $this->getArgDefinitions()->addArguments($this->getDefaultArgs(), false);
$eventName = $this->getDispatchEventName(TheliaEvents::LOOP_EXTENDS_ARG_DEFINITIONS);
if (null !== $eventName) {
$this->dispatcher->dispatch(
$eventName,
new LoopExtendsArgDefinitionsEvent($this)
);
};
self::$loopDefinitionsArgs[$class] = $this->args;
}
$this->args = self::$loopDefinitionsArgs[$class];
} | [
"protected",
"function",
"initialize",
"(",
")",
"{",
"$",
"class",
"=",
"\\",
"get_class",
"(",
"$",
"this",
")",
";",
"if",
"(",
"null",
"===",
"self",
"::",
"$",
"loopDefinitions",
")",
"{",
"self",
"::",
"$",
"loopDefinitions",
"=",
"\\",
"array_fl... | Initialize the loop
First it will get the loop name according to the loop class.
Then argument definitions is initialized | [
"Initialize",
"the",
"loop"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Template/Element/BaseLoop.php#L126-L153 | train |
thelia/core | lib/Thelia/Core/Template/Element/BaseLoop.php | BaseLoop.getDefaultArgs | protected function getDefaultArgs()
{
$defaultArgs = [
Argument::createBooleanTypeArgument('backend_context', false),
Argument::createBooleanTypeArgument('force_return', false),
Argument::createAnyTypeArgument('type'),
Argument::createBooleanTypeArgument('no-cache', false),
Argument::createBooleanTypeArgument('return_url', true)
];
if (true === $this->countable) {
$defaultArgs[] = Argument::createIntTypeArgument('offset', 0);
$defaultArgs[] = Argument::createIntTypeArgument('page');
$defaultArgs[] = Argument::createIntTypeArgument('limit', PHP_INT_MAX);
}
if ($this instanceof SearchLoopInterface) {
$defaultArgs[] = Argument::createAnyTypeArgument('search_term');
$defaultArgs[] = new Argument(
'search_in',
new TypeCollection(
new EnumListType($this->getSearchIn())
)
);
$defaultArgs[] = new Argument(
'search_mode',
new TypeCollection(
new EnumType(
[
SearchLoopInterface::MODE_ANY_WORD,
SearchLoopInterface::MODE_SENTENCE,
SearchLoopInterface::MODE_STRICT_SENTENCE,
]
)
),
SearchLoopInterface::MODE_STRICT_SENTENCE
);
}
return $defaultArgs;
} | php | protected function getDefaultArgs()
{
$defaultArgs = [
Argument::createBooleanTypeArgument('backend_context', false),
Argument::createBooleanTypeArgument('force_return', false),
Argument::createAnyTypeArgument('type'),
Argument::createBooleanTypeArgument('no-cache', false),
Argument::createBooleanTypeArgument('return_url', true)
];
if (true === $this->countable) {
$defaultArgs[] = Argument::createIntTypeArgument('offset', 0);
$defaultArgs[] = Argument::createIntTypeArgument('page');
$defaultArgs[] = Argument::createIntTypeArgument('limit', PHP_INT_MAX);
}
if ($this instanceof SearchLoopInterface) {
$defaultArgs[] = Argument::createAnyTypeArgument('search_term');
$defaultArgs[] = new Argument(
'search_in',
new TypeCollection(
new EnumListType($this->getSearchIn())
)
);
$defaultArgs[] = new Argument(
'search_mode',
new TypeCollection(
new EnumType(
[
SearchLoopInterface::MODE_ANY_WORD,
SearchLoopInterface::MODE_SENTENCE,
SearchLoopInterface::MODE_STRICT_SENTENCE,
]
)
),
SearchLoopInterface::MODE_STRICT_SENTENCE
);
}
return $defaultArgs;
} | [
"protected",
"function",
"getDefaultArgs",
"(",
")",
"{",
"$",
"defaultArgs",
"=",
"[",
"Argument",
"::",
"createBooleanTypeArgument",
"(",
"'backend_context'",
",",
"false",
")",
",",
"Argument",
"::",
"createBooleanTypeArgument",
"(",
"'force_return'",
",",
"false... | Define common loop arguments
@return Argument[] | [
"Define",
"common",
"loop",
"arguments"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Template/Element/BaseLoop.php#L160-L200 | train |
thelia/core | lib/Thelia/Core/Template/Element/BaseLoop.php | BaseLoop.initializeArgs | public function initializeArgs(array $nameValuePairs)
{
$faultActor = [];
$faultDetails = [];
if (null !== $eventName = $this->getDispatchEventName(TheliaEvents::LOOP_EXTENDS_INITIALIZE_ARGS)) {
$event = new LoopExtendsInitializeArgsEvent($this, $nameValuePairs);
$this->dispatcher->dispatch($eventName, $event);
$nameValuePairs = $event->getLoopParameters();
}
$loopType = isset($nameValuePairs['type']) ? $nameValuePairs['type'] : "undefined";
$loopName = isset($nameValuePairs['name']) ? $nameValuePairs['name'] : "undefined";
$this->args->rewind();
while (($argument = $this->args->current()) !== false) {
$this->args->next();
$value = isset($nameValuePairs[$argument->name]) ? $nameValuePairs[$argument->name] : null;
/* check if mandatory */
if ($value === null && $argument->mandatory) {
$faultActor[] = $argument->name;
$faultDetails[] = $this->translator->trans(
'"%param" parameter is missing in loop type: %type, name: %name',
[
'%param' => $argument->name,
'%type' => $loopType,
'%name' => $loopName
]
);
} elseif ($value === '') {
if (!$argument->empty) {
/* check if empty */
$faultActor[] = $argument->name;
$faultDetails[] = $this->translator->trans(
'"%param" parameter cannot be empty in loop type: %type, name: %name',
[
'%param' => $argument->name,
'%type' => $loopType,
'%name' => $loopName
]
);
}
} elseif ($value !== null && !$argument->type->isValid($value)) {
/* check type */
$faultActor[] = $argument->name;
$faultDetails[] = $this->translator->trans(
'Invalid value "%value" for "%param" parameter in loop type: %type, name: %name',
[
'%value' => $value,
'%param' => $argument->name,
'%type' => $loopType,
'%name' => $loopName
]
);
} else {
/* set default value */
/* did it as last checking for we consider default value is acceptable no matter type or empty restriction */
if ($value === null) {
$value = $argument->default;
}
$argument->setValue($value);
}
}
if (! empty($faultActor)) {
$complement = sprintf('[%s]', implode(', ', $faultDetails));
throw new \InvalidArgumentException($complement);
}
} | php | public function initializeArgs(array $nameValuePairs)
{
$faultActor = [];
$faultDetails = [];
if (null !== $eventName = $this->getDispatchEventName(TheliaEvents::LOOP_EXTENDS_INITIALIZE_ARGS)) {
$event = new LoopExtendsInitializeArgsEvent($this, $nameValuePairs);
$this->dispatcher->dispatch($eventName, $event);
$nameValuePairs = $event->getLoopParameters();
}
$loopType = isset($nameValuePairs['type']) ? $nameValuePairs['type'] : "undefined";
$loopName = isset($nameValuePairs['name']) ? $nameValuePairs['name'] : "undefined";
$this->args->rewind();
while (($argument = $this->args->current()) !== false) {
$this->args->next();
$value = isset($nameValuePairs[$argument->name]) ? $nameValuePairs[$argument->name] : null;
/* check if mandatory */
if ($value === null && $argument->mandatory) {
$faultActor[] = $argument->name;
$faultDetails[] = $this->translator->trans(
'"%param" parameter is missing in loop type: %type, name: %name',
[
'%param' => $argument->name,
'%type' => $loopType,
'%name' => $loopName
]
);
} elseif ($value === '') {
if (!$argument->empty) {
/* check if empty */
$faultActor[] = $argument->name;
$faultDetails[] = $this->translator->trans(
'"%param" parameter cannot be empty in loop type: %type, name: %name',
[
'%param' => $argument->name,
'%type' => $loopType,
'%name' => $loopName
]
);
}
} elseif ($value !== null && !$argument->type->isValid($value)) {
/* check type */
$faultActor[] = $argument->name;
$faultDetails[] = $this->translator->trans(
'Invalid value "%value" for "%param" parameter in loop type: %type, name: %name',
[
'%value' => $value,
'%param' => $argument->name,
'%type' => $loopType,
'%name' => $loopName
]
);
} else {
/* set default value */
/* did it as last checking for we consider default value is acceptable no matter type or empty restriction */
if ($value === null) {
$value = $argument->default;
}
$argument->setValue($value);
}
}
if (! empty($faultActor)) {
$complement = sprintf('[%s]', implode(', ', $faultDetails));
throw new \InvalidArgumentException($complement);
}
} | [
"public",
"function",
"initializeArgs",
"(",
"array",
"$",
"nameValuePairs",
")",
"{",
"$",
"faultActor",
"=",
"[",
"]",
";",
"$",
"faultDetails",
"=",
"[",
"]",
";",
"if",
"(",
"null",
"!==",
"$",
"eventName",
"=",
"$",
"this",
"->",
"getDispatchEventNa... | Initialize the loop arguments.
@param array $nameValuePairs a array of name => value pairs. The name is the name of the argument.
@throws \InvalidArgumentException if some argument values are missing, or invalid | [
"Initialize",
"the",
"loop",
"arguments",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Template/Element/BaseLoop.php#L232-L304 | train |
thelia/core | lib/Thelia/Core/Template/Element/BaseLoop.php | BaseLoop.getArg | protected function getArg($argumentName)
{
$arg = $this->args->get($argumentName);
if ($arg === null) {
throw new \InvalidArgumentException(
$this->translator->trans('Undefined loop argument "%name"', ['%name' => $argumentName])
);
}
return $arg;
} | php | protected function getArg($argumentName)
{
$arg = $this->args->get($argumentName);
if ($arg === null) {
throw new \InvalidArgumentException(
$this->translator->trans('Undefined loop argument "%name"', ['%name' => $argumentName])
);
}
return $arg;
} | [
"protected",
"function",
"getArg",
"(",
"$",
"argumentName",
")",
"{",
"$",
"arg",
"=",
"$",
"this",
"->",
"args",
"->",
"get",
"(",
"$",
"argumentName",
")",
";",
"if",
"(",
"$",
"arg",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgument... | Return a loop argument
@param string $argumentName the argument name
@return Argument the loop argument.
@throws \InvalidArgumentException if argument is not found in loop argument list | [
"Return",
"a",
"loop",
"argument"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Template/Element/BaseLoop.php#L314-L325 | train |
thelia/core | lib/Thelia/Core/Template/Element/BaseLoop.php | BaseLoop.getDispatchEventName | protected function getDispatchEventName($eventName)
{
$customEventName = TheliaEvents::getLoopExtendsEvent($eventName, $this->loopName);
if (!isset(self::$dispatchCache[$customEventName])) {
self::$dispatchCache[$customEventName] = $this->dispatcher->hasListeners($customEventName);
}
return self::$dispatchCache[$customEventName]
? $customEventName
: null;
} | php | protected function getDispatchEventName($eventName)
{
$customEventName = TheliaEvents::getLoopExtendsEvent($eventName, $this->loopName);
if (!isset(self::$dispatchCache[$customEventName])) {
self::$dispatchCache[$customEventName] = $this->dispatcher->hasListeners($customEventName);
}
return self::$dispatchCache[$customEventName]
? $customEventName
: null;
} | [
"protected",
"function",
"getDispatchEventName",
"(",
"$",
"eventName",
")",
"{",
"$",
"customEventName",
"=",
"TheliaEvents",
"::",
"getLoopExtendsEvent",
"(",
"$",
"eventName",
",",
"$",
"this",
"->",
"loopName",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"se... | Get the event name for the loop depending of the event name and the loop name.
This function also checks if there are services that listen to this event.
If not the function returns null.
@param string $eventName the event name (`TheliaEvents::LOOP_EXTENDS_ARG_DEFINITIONS`,
`TheliaEvents::LOOP_EXTENDS_INITIALIZE_ARGS`, ...)
@return null|string The event name for the loop if listeners exist, otherwise null is returned | [
"Get",
"the",
"event",
"name",
"for",
"the",
"loop",
"depending",
"of",
"the",
"event",
"name",
"and",
"the",
"loop",
"name",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Template/Element/BaseLoop.php#L672-L683 | train |
thelia/core | lib/Thelia/Core/Template/Element/BaseLoop.php | BaseLoop.extendsBuildModelCriteria | protected function extendsBuildModelCriteria(ModelCriteria $search = null)
{
if (null === $search) {
return null;
}
$eventName = $this->getDispatchEventName(TheliaEvents::LOOP_EXTENDS_BUILD_MODEL_CRITERIA);
if (null !== $eventName) {
$this->dispatcher->dispatch(
$eventName,
new LoopExtendsBuildModelCriteriaEvent($this, $search)
);
}
return $search;
} | php | protected function extendsBuildModelCriteria(ModelCriteria $search = null)
{
if (null === $search) {
return null;
}
$eventName = $this->getDispatchEventName(TheliaEvents::LOOP_EXTENDS_BUILD_MODEL_CRITERIA);
if (null !== $eventName) {
$this->dispatcher->dispatch(
$eventName,
new LoopExtendsBuildModelCriteriaEvent($this, $search)
);
}
return $search;
} | [
"protected",
"function",
"extendsBuildModelCriteria",
"(",
"ModelCriteria",
"$",
"search",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"search",
")",
"{",
"return",
"null",
";",
"}",
"$",
"eventName",
"=",
"$",
"this",
"->",
"getDispatchEventName",... | Dispatch an event to extend the BuildModelCriteria
@param ModelCriteria $search
@return ModelCriteria | [
"Dispatch",
"an",
"event",
"to",
"extend",
"the",
"BuildModelCriteria"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Template/Element/BaseLoop.php#L691-L706 | train |
thelia/core | lib/Thelia/Core/Template/Element/BaseLoop.php | BaseLoop.extendsBuildArray | protected function extendsBuildArray(array $search = null)
{
if (null === $search) {
return null;
}
$eventName = $this->getDispatchEventName(TheliaEvents::LOOP_EXTENDS_BUILD_ARRAY);
if (null !== $eventName) {
$event = new LoopExtendsBuildArrayEvent($this, $search);
$this->dispatcher->dispatch($eventName, $event);
$search = $event->getArray();
}
return $search;
} | php | protected function extendsBuildArray(array $search = null)
{
if (null === $search) {
return null;
}
$eventName = $this->getDispatchEventName(TheliaEvents::LOOP_EXTENDS_BUILD_ARRAY);
if (null !== $eventName) {
$event = new LoopExtendsBuildArrayEvent($this, $search);
$this->dispatcher->dispatch($eventName, $event);
$search = $event->getArray();
}
return $search;
} | [
"protected",
"function",
"extendsBuildArray",
"(",
"array",
"$",
"search",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"search",
")",
"{",
"return",
"null",
";",
"}",
"$",
"eventName",
"=",
"$",
"this",
"->",
"getDispatchEventName",
"(",
"Theli... | Dispatch an event to extend the BuildArray
@param array $search
@return array | [
"Dispatch",
"an",
"event",
"to",
"extend",
"the",
"BuildArray"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Template/Element/BaseLoop.php#L714-L730 | train |
thelia/core | lib/Thelia/Core/Template/Element/BaseLoop.php | BaseLoop.extendsParseResults | protected function extendsParseResults(LoopResult $loopResult)
{
$eventName = $this->getDispatchEventName(TheliaEvents::LOOP_EXTENDS_PARSE_RESULTS);
if (null !== $eventName) {
$this->dispatcher->dispatch(
$eventName,
new LoopExtendsParseResultsEvent($this, $loopResult)
);
}
return $loopResult;
} | php | protected function extendsParseResults(LoopResult $loopResult)
{
$eventName = $this->getDispatchEventName(TheliaEvents::LOOP_EXTENDS_PARSE_RESULTS);
if (null !== $eventName) {
$this->dispatcher->dispatch(
$eventName,
new LoopExtendsParseResultsEvent($this, $loopResult)
);
}
return $loopResult;
} | [
"protected",
"function",
"extendsParseResults",
"(",
"LoopResult",
"$",
"loopResult",
")",
"{",
"$",
"eventName",
"=",
"$",
"this",
"->",
"getDispatchEventName",
"(",
"TheliaEvents",
"::",
"LOOP_EXTENDS_PARSE_RESULTS",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"e... | Dispatch an event to extend the ParseResults
@param LoopResult $loopResult
@return LoopResult | [
"Dispatch",
"an",
"event",
"to",
"extend",
"the",
"ParseResults"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Template/Element/BaseLoop.php#L738-L749 | train |
BoldGrid/library | src/Library/Key.php | Key.setNotice | public function setNotice( $forceDisplay = false ) {
if ( $this->notice ) {
return $this->notice;
}
// If we already have transient data saying the API is not available.
if ( 0 === get_site_transient( 'boldgrid_available' ) ) {
return new Notice( 'ConnectionIssue' );
}
// If we don't have a key stored, or this is not a valid response when calling.
if ( ! Configs::get( 'key' ) || ! self::$valid || $forceDisplay ) {
return new Notice( 'keyPrompt', $this );
}
} | php | public function setNotice( $forceDisplay = false ) {
if ( $this->notice ) {
return $this->notice;
}
// If we already have transient data saying the API is not available.
if ( 0 === get_site_transient( 'boldgrid_available' ) ) {
return new Notice( 'ConnectionIssue' );
}
// If we don't have a key stored, or this is not a valid response when calling.
if ( ! Configs::get( 'key' ) || ! self::$valid || $forceDisplay ) {
return new Notice( 'keyPrompt', $this );
}
} | [
"public",
"function",
"setNotice",
"(",
"$",
"forceDisplay",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"notice",
")",
"{",
"return",
"$",
"this",
"->",
"notice",
";",
"}",
"// If we already have transient data saying the API is not available.",
"if",
... | Add the appropriate notice to the WordPress dashboard.
This method will set the connection issue notice or the prompt key
notice to the user's WordPress dashboard.
@since 1.0.0 | [
"Add",
"the",
"appropriate",
"notice",
"to",
"the",
"WordPress",
"dashboard",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Key.php#L160-L174 | train |
BoldGrid/library | src/Library/Key.php | Key.addKey | public function addKey( $key ) {
/*
* @todo The majority of this method has been copied from
* Boldgrid\Library\Library\Notice\KeyPrompt\addKey() because the logic to add a key should
* be in this class and not the KeyPrompt class. that KeyPrompt method needs to be refactored.
*/
// When adding Keys, delete the transient to make sure we get new license info.
delete_site_transient( 'bg_license_data' );
delete_site_transient( 'boldgrid_api_data' );
$data = $this->callCheckVersion( array( 'key' => $key ) );
if ( is_object( $data ) ) {
$this->save( $data, $key );
return true;
} else {
return false;
}
} | php | public function addKey( $key ) {
/*
* @todo The majority of this method has been copied from
* Boldgrid\Library\Library\Notice\KeyPrompt\addKey() because the logic to add a key should
* be in this class and not the KeyPrompt class. that KeyPrompt method needs to be refactored.
*/
// When adding Keys, delete the transient to make sure we get new license info.
delete_site_transient( 'bg_license_data' );
delete_site_transient( 'boldgrid_api_data' );
$data = $this->callCheckVersion( array( 'key' => $key ) );
if ( is_object( $data ) ) {
$this->save( $data, $key );
return true;
} else {
return false;
}
} | [
"public",
"function",
"addKey",
"(",
"$",
"key",
")",
"{",
"/*\n\t\t * @todo The majority of this method has been copied from\n\t\t * Boldgrid\\Library\\Library\\Notice\\KeyPrompt\\addKey() because the logic to add a key should\n\t\t * be in this class and not the KeyPrompt class. that KeyPrompt met... | Add a key.
@since 2.8.0
@param string $key A hashed key.
@return bool True on success, false on failure. | [
"Add",
"a",
"key",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Key.php#L184-L203 | train |
BoldGrid/library | src/Library/Key.php | Key.callCheckVersion | public function callCheckVersion( $args ) {
if ( ! empty( $args['key'] ) ) {
$call = new Api\Call( Configs::get( 'api' ) . '/api/plugin/checkVersion', $args );
// If there's an error set that as the response.
if ( ! $response = $call->getError() ) {
// If the response is successful, then retrieve the response.
$response = $call->getResponse();
}
} else {
$response = 'No Connect Key available.';
}
// Return the API response.
return $response;
} | php | public function callCheckVersion( $args ) {
if ( ! empty( $args['key'] ) ) {
$call = new Api\Call( Configs::get( 'api' ) . '/api/plugin/checkVersion', $args );
// If there's an error set that as the response.
if ( ! $response = $call->getError() ) {
// If the response is successful, then retrieve the response.
$response = $call->getResponse();
}
} else {
$response = 'No Connect Key available.';
}
// Return the API response.
return $response;
} | [
"public",
"function",
"callCheckVersion",
"(",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"args",
"[",
"'key'",
"]",
")",
")",
"{",
"$",
"call",
"=",
"new",
"Api",
"\\",
"Call",
"(",
"Configs",
"::",
"get",
"(",
"'api'",
")",
".",
... | Call the API check-version endpoint for API data.
@since 1.0.0
@param array $args API arguments to pass.
@return mixed $response Object for valid response, or error message as string. | [
"Call",
"the",
"API",
"check",
"-",
"version",
"endpoint",
"for",
"API",
"data",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Key.php#L214-L230 | train |
BoldGrid/library | src/Library/Key.php | Key.verify | public function verify( $key = null ) {
$key = $key ? $key : Configs::get( 'key' );
// Make an API call for API data.
$data = $this->callCheckVersion( array(
'key' => $key,
'channel' => $this->releaseChannel->getPluginChannel(),
'theme_channel' => $this->releaseChannel->getThemeChannel(),
) );
// Let the transient data set it's own validity.
if ( $this->verifyData( $data ) ) {
$data->license_status = true;
}
// Return back the transient data object.
return $data;
} | php | public function verify( $key = null ) {
$key = $key ? $key : Configs::get( 'key' );
// Make an API call for API data.
$data = $this->callCheckVersion( array(
'key' => $key,
'channel' => $this->releaseChannel->getPluginChannel(),
'theme_channel' => $this->releaseChannel->getThemeChannel(),
) );
// Let the transient data set it's own validity.
if ( $this->verifyData( $data ) ) {
$data->license_status = true;
}
// Return back the transient data object.
return $data;
} | [
"public",
"function",
"verify",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"key",
"=",
"$",
"key",
"?",
"$",
"key",
":",
"Configs",
"::",
"get",
"(",
"'key'",
")",
";",
"// Make an API call for API data.",
"$",
"data",
"=",
"$",
"this",
"->",
"call... | Validates the API key and returns details on if it is valid as well as version.
@since 1.0.0
@see \Boldgrid\Library\Library\ReleaseChannel::getPluginChannel()
@see \Boldgrid\Library\Library\ReleaseChannel::getThemeChannel()
@see \Boldgrid\Library\Library\Key::callCheckVersion()
@see \Boldgrid\Library\Library\Key::verifyData()
@return mixed The BoldGrid API Data object or a message string on failure. | [
"Validates",
"the",
"API",
"key",
"and",
"returns",
"details",
"on",
"if",
"it",
"is",
"valid",
"as",
"well",
"as",
"version",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Key.php#L256-L273 | train |
ElfSundae/laravel-bearychat | src/Jobs/SendBearyChat.php | SendBearyChat.client | public function client($client)
{
$this->client = $client instanceof Client ? $client : bearychat($client);
if ($this->message) {
$this->message->setClient($this->client);
}
return $this;
} | php | public function client($client)
{
$this->client = $client instanceof Client ? $client : bearychat($client);
if ($this->message) {
$this->message->setClient($this->client);
}
return $this;
} | [
"public",
"function",
"client",
"(",
"$",
"client",
")",
"{",
"$",
"this",
"->",
"client",
"=",
"$",
"client",
"instanceof",
"Client",
"?",
"$",
"client",
":",
"bearychat",
"(",
"$",
"client",
")",
";",
"if",
"(",
"$",
"this",
"->",
"message",
")",
... | Set the BearyChat client.
@param \ElfSundae\BearyChat\Client|string $client
@return $this | [
"Set",
"the",
"BearyChat",
"client",
"."
] | d4fd4948e6fd24af669e9916717b7446a6cdd7fa | https://github.com/ElfSundae/laravel-bearychat/blob/d4fd4948e6fd24af669e9916717b7446a6cdd7fa/src/Jobs/SendBearyChat.php#L56-L65 | train |
thelia/core | lib/Thelia/Action/Image.php | Image.createImagineInstance | protected function createImagineInstance()
{
$driver = ConfigQuery::read("imagine_graphic_driver", "gd");
switch ($driver) {
case 'imagick':
$image = new ImagickImagine();
break;
case 'gmagick':
$image = new GmagickImagine();
break;
case 'gd':
default:
$image = new Imagine();
}
return $image;
} | php | protected function createImagineInstance()
{
$driver = ConfigQuery::read("imagine_graphic_driver", "gd");
switch ($driver) {
case 'imagick':
$image = new ImagickImagine();
break;
case 'gmagick':
$image = new GmagickImagine();
break;
case 'gd':
default:
$image = new Imagine();
}
return $image;
} | [
"protected",
"function",
"createImagineInstance",
"(",
")",
"{",
"$",
"driver",
"=",
"ConfigQuery",
"::",
"read",
"(",
"\"imagine_graphic_driver\"",
",",
"\"gd\"",
")",
";",
"switch",
"(",
"$",
"driver",
")",
"{",
"case",
"'imagick'",
":",
"$",
"image",
"=",... | Create a new Imagine object using current driver configuration
@return ImagineInterface | [
"Create",
"a",
"new",
"Imagine",
"object",
"using",
"current",
"driver",
"configuration"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Image.php#L393-L412 | train |
NotifyMeHQ/notifyme | src/Adapters/Ballou/BallouFactory.php | BallouFactory.make | public function make(array $config)
{
Arr::requires($config, ['token']);
$client = new Client();
return new BallouGateway($client, $config);
} | php | public function make(array $config)
{
Arr::requires($config, ['token']);
$client = new Client();
return new BallouGateway($client, $config);
} | [
"public",
"function",
"make",
"(",
"array",
"$",
"config",
")",
"{",
"Arr",
"::",
"requires",
"(",
"$",
"config",
",",
"[",
"'token'",
"]",
")",
";",
"$",
"client",
"=",
"new",
"Client",
"(",
")",
";",
"return",
"new",
"BallouGateway",
"(",
"$",
"c... | Create a new ballou gateway instance.
@param string[] $config
@return \NotifyMeHQ\Adapters\Ballou\BallouGateway | [
"Create",
"a",
"new",
"ballou",
"gateway",
"instance",
"."
] | 2af4bdcfe9df6db7ea79e2dce90b106ccb285b06 | https://github.com/NotifyMeHQ/notifyme/blob/2af4bdcfe9df6db7ea79e2dce90b106ccb285b06/src/Adapters/Ballou/BallouFactory.php#L27-L34 | train |
grom358/pharborist | src/ParentNode.php | ParentNode.childrenByInstance | protected function childrenByInstance($class_name) {
$matches = [];
$child = $this->head;
while ($child) {
if ($child instanceof $class_name) {
$matches[] = $child;
}
$child = $child->next;
}
return $matches;
} | php | protected function childrenByInstance($class_name) {
$matches = [];
$child = $this->head;
while ($child) {
if ($child instanceof $class_name) {
$matches[] = $child;
}
$child = $child->next;
}
return $matches;
} | [
"protected",
"function",
"childrenByInstance",
"(",
"$",
"class_name",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"$",
"child",
"=",
"$",
"this",
"->",
"head",
";",
"while",
"(",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"instanceof",
"$",
... | Get children that are instance of class.
@param string $class_name
@return Node[] | [
"Get",
"children",
"that",
"are",
"instance",
"of",
"class",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/ParentNode.php#L55-L65 | train |
grom358/pharborist | src/ParentNode.php | ParentNode.prependChild | protected function prependChild(Node $node) {
if ($this->head === NULL) {
$this->childCount++;
$node->parent = $this;
$node->previous = NULL;
$node->next = NULL;
$this->head = $this->tail = $node;
}
else {
$this->insertBeforeChild($this->head, $node);
$this->head = $node;
}
return $this;
} | php | protected function prependChild(Node $node) {
if ($this->head === NULL) {
$this->childCount++;
$node->parent = $this;
$node->previous = NULL;
$node->next = NULL;
$this->head = $this->tail = $node;
}
else {
$this->insertBeforeChild($this->head, $node);
$this->head = $node;
}
return $this;
} | [
"protected",
"function",
"prependChild",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"head",
"===",
"NULL",
")",
"{",
"$",
"this",
"->",
"childCount",
"++",
";",
"$",
"node",
"->",
"parent",
"=",
"$",
"this",
";",
"$",
"node",... | Prepend a child to node.
@param Node $node
@return $this | [
"Prepend",
"a",
"child",
"to",
"node",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/ParentNode.php#L88-L101 | train |
grom358/pharborist | src/ParentNode.php | ParentNode.appendChild | protected function appendChild(Node $node) {
if ($this->tail === NULL) {
$this->prependChild($node);
}
else {
$this->insertAfterChild($this->tail, $node);
$this->tail = $node;
}
return $this;
} | php | protected function appendChild(Node $node) {
if ($this->tail === NULL) {
$this->prependChild($node);
}
else {
$this->insertAfterChild($this->tail, $node);
$this->tail = $node;
}
return $this;
} | [
"protected",
"function",
"appendChild",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"tail",
"===",
"NULL",
")",
"{",
"$",
"this",
"->",
"prependChild",
"(",
"$",
"node",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"insertAf... | Append a child to node.
@param Node $node
@return $this | [
"Append",
"a",
"child",
"to",
"node",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/ParentNode.php#L128-L137 | train |
grom358/pharborist | src/ParentNode.php | ParentNode.addChild | public function addChild(Node $node, $property_name = NULL) {
$this->appendChild($node);
if ($property_name !== NULL) {
$this->{$property_name} = $node;
}
return $this;
} | php | public function addChild(Node $node, $property_name = NULL) {
$this->appendChild($node);
if ($property_name !== NULL) {
$this->{$property_name} = $node;
}
return $this;
} | [
"public",
"function",
"addChild",
"(",
"Node",
"$",
"node",
",",
"$",
"property_name",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"if",
"(",
"$",
"property_name",
"!==",
"NULL",
")",
"{",
"$",
"this",
"->",
... | Add a child to node.
Internal use only, used by parser when building a node.
@param Node $node
@param string $property_name
@return $this | [
"Add",
"a",
"child",
"to",
"node",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/ParentNode.php#L148-L154 | train |
grom358/pharborist | src/ParentNode.php | ParentNode.mergeNode | public function mergeNode(ParentNode $node) {
$child = $node->head;
while ($child) {
$next = $child->next;
$this->appendChild($child);
$child = $next;
}
foreach ($node->getChildProperties() as $name => $value) {
$this->{$name} = $value;
}
} | php | public function mergeNode(ParentNode $node) {
$child = $node->head;
while ($child) {
$next = $child->next;
$this->appendChild($child);
$child = $next;
}
foreach ($node->getChildProperties() as $name => $value) {
$this->{$name} = $value;
}
} | [
"public",
"function",
"mergeNode",
"(",
"ParentNode",
"$",
"node",
")",
"{",
"$",
"child",
"=",
"$",
"node",
"->",
"head",
";",
"while",
"(",
"$",
"child",
")",
"{",
"$",
"next",
"=",
"$",
"child",
"->",
"next",
";",
"$",
"this",
"->",
"appendChild... | Merge another parent node into this node.
@param ParentNode $node | [
"Merge",
"another",
"parent",
"node",
"into",
"this",
"node",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/ParentNode.php#L173-L183 | train |
grom358/pharborist | src/ParentNode.php | ParentNode.insertBeforeChild | protected function insertBeforeChild(Node $child, Node $node) {
$this->childCount++;
$node->parent = $this;
if ($child->previous === NULL) {
$this->head = $node;
}
else {
$child->previous->next = $node;
}
$node->previous = $child->previous;
$node->next = $child;
$child->previous = $node;
return $this;
} | php | protected function insertBeforeChild(Node $child, Node $node) {
$this->childCount++;
$node->parent = $this;
if ($child->previous === NULL) {
$this->head = $node;
}
else {
$child->previous->next = $node;
}
$node->previous = $child->previous;
$node->next = $child;
$child->previous = $node;
return $this;
} | [
"protected",
"function",
"insertBeforeChild",
"(",
"Node",
"$",
"child",
",",
"Node",
"$",
"node",
")",
"{",
"$",
"this",
"->",
"childCount",
"++",
";",
"$",
"node",
"->",
"parent",
"=",
"$",
"this",
";",
"if",
"(",
"$",
"child",
"->",
"previous",
"=... | Insert a node before a child.
@param Node $child
@param Node $node
@return $this | [
"Insert",
"a",
"node",
"before",
"a",
"child",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/ParentNode.php#L206-L219 | train |
grom358/pharborist | src/ParentNode.php | ParentNode.insertAfterChild | protected function insertAfterChild(Node $child, Node $node) {
$this->childCount++;
$node->parent = $this;
if ($child->next === NULL) {
$this->tail = $node;
}
else {
$child->next->previous = $node;
}
$node->previous = $child;
$node->next = $child->next;
$child->next = $node;
return $this;
} | php | protected function insertAfterChild(Node $child, Node $node) {
$this->childCount++;
$node->parent = $this;
if ($child->next === NULL) {
$this->tail = $node;
}
else {
$child->next->previous = $node;
}
$node->previous = $child;
$node->next = $child->next;
$child->next = $node;
return $this;
} | [
"protected",
"function",
"insertAfterChild",
"(",
"Node",
"$",
"child",
",",
"Node",
"$",
"node",
")",
"{",
"$",
"this",
"->",
"childCount",
"++",
";",
"$",
"node",
"->",
"parent",
"=",
"$",
"this",
";",
"if",
"(",
"$",
"child",
"->",
"next",
"===",
... | Insert a node after a child.
@param Node $child
@param Node $node
@return $this | [
"Insert",
"a",
"node",
"after",
"a",
"child",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/ParentNode.php#L227-L240 | train |
grom358/pharborist | src/ParentNode.php | ParentNode.removeChild | protected function removeChild(Node $child) {
$this->childCount--;
foreach ($this->getChildProperties() as $name => $value) {
if ($child === $value) {
$this->{$name} = NULL;
break;
}
}
if ($child->previous === NULL) {
$this->head = $child->next;
}
else {
$child->previous->next = $child->next;
}
if ($child->next === NULL) {
$this->tail = $child->previous;
}
else {
$child->next->previous = $child->previous;
}
$child->parent = NULL;
$child->previous = NULL;
$child->next = NULL;
return $this;
} | php | protected function removeChild(Node $child) {
$this->childCount--;
foreach ($this->getChildProperties() as $name => $value) {
if ($child === $value) {
$this->{$name} = NULL;
break;
}
}
if ($child->previous === NULL) {
$this->head = $child->next;
}
else {
$child->previous->next = $child->next;
}
if ($child->next === NULL) {
$this->tail = $child->previous;
}
else {
$child->next->previous = $child->previous;
}
$child->parent = NULL;
$child->previous = NULL;
$child->next = NULL;
return $this;
} | [
"protected",
"function",
"removeChild",
"(",
"Node",
"$",
"child",
")",
"{",
"$",
"this",
"->",
"childCount",
"--",
";",
"foreach",
"(",
"$",
"this",
"->",
"getChildProperties",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$... | Remove a child node.
@param Node $child
@return $this | [
"Remove",
"a",
"child",
"node",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/ParentNode.php#L247-L271 | train |
grom358/pharborist | src/ParentNode.php | ParentNode.replaceChild | protected function replaceChild(Node $child, Node $replacement) {
foreach ($this->getChildProperties() as $name => $value) {
if ($child === $value) {
$this->{$name} = $replacement;
break;
}
}
$replacement->parent = $this;
$replacement->previous = $child->previous;
$replacement->next = $child->next;
if ($child->previous === NULL) {
$this->head = $replacement;
}
else {
$child->previous->next = $replacement;
}
if ($child->next === NULL) {
$this->tail = $replacement;
}
else {
$child->next->previous = $replacement;
}
$child->parent = NULL;
$child->previous = NULL;
$child->next = NULL;
return $this;
} | php | protected function replaceChild(Node $child, Node $replacement) {
foreach ($this->getChildProperties() as $name => $value) {
if ($child === $value) {
$this->{$name} = $replacement;
break;
}
}
$replacement->parent = $this;
$replacement->previous = $child->previous;
$replacement->next = $child->next;
if ($child->previous === NULL) {
$this->head = $replacement;
}
else {
$child->previous->next = $replacement;
}
if ($child->next === NULL) {
$this->tail = $replacement;
}
else {
$child->next->previous = $replacement;
}
$child->parent = NULL;
$child->previous = NULL;
$child->next = NULL;
return $this;
} | [
"protected",
"function",
"replaceChild",
"(",
"Node",
"$",
"child",
",",
"Node",
"$",
"replacement",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getChildProperties",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"child",
... | Replace a child node.
@param Node $child
@param Node $replacement
@return $this | [
"Replace",
"a",
"child",
"node",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/ParentNode.php#L279-L305 | train |
grom358/pharborist | src/ParentNode.php | ParentNode.getTree | public function getTree() {
$children = array();
$properties = $this->getChildProperties();
$child = $this->head;
$i = 0;
while ($child) {
$key = array_search($child, $properties, TRUE);
if (!$key) {
$key = $i;
}
if ($child instanceof ParentNode) {
$children[$key] = $child->getTree();
}
else {
/** @var TokenNode $child */
$children[$key] = array($child->getTypeName() => $child->getText());
}
$child = $child->next;
$i++;
}
$class_name = get_class($this);
return array($class_name => $children);
} | php | public function getTree() {
$children = array();
$properties = $this->getChildProperties();
$child = $this->head;
$i = 0;
while ($child) {
$key = array_search($child, $properties, TRUE);
if (!$key) {
$key = $i;
}
if ($child instanceof ParentNode) {
$children[$key] = $child->getTree();
}
else {
/** @var TokenNode $child */
$children[$key] = array($child->getTypeName() => $child->getText());
}
$child = $child->next;
$i++;
}
$class_name = get_class($this);
return array($class_name => $children);
} | [
"public",
"function",
"getTree",
"(",
")",
"{",
"$",
"children",
"=",
"array",
"(",
")",
";",
"$",
"properties",
"=",
"$",
"this",
"->",
"getChildProperties",
"(",
")",
";",
"$",
"child",
"=",
"$",
"this",
"->",
"head",
";",
"$",
"i",
"=",
"0",
"... | Convert tree into array.
Useful for viewing the tree structure. | [
"Convert",
"tree",
"into",
"array",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/ParentNode.php#L503-L525 | train |
aequasi/environment-php | src/Environment.php | Environment.checkTypeAllowed | protected function checkTypeAllowed()
{
if (!in_array($this->type, static::$ALLOWED_TYPES)) {
throw new \Exception(
sprintf(
"`%s` is not a valid environment type. Expected one of: %s",
$this->type,
implode(', ', static::$ALLOWED_TYPES)
)
);
}
} | php | protected function checkTypeAllowed()
{
if (!in_array($this->type, static::$ALLOWED_TYPES)) {
throw new \Exception(
sprintf(
"`%s` is not a valid environment type. Expected one of: %s",
$this->type,
implode(', ', static::$ALLOWED_TYPES)
)
);
}
} | [
"protected",
"function",
"checkTypeAllowed",
"(",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"type",
",",
"static",
"::",
"$",
"ALLOWED_TYPES",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"`%s` is not a valid... | Makes sure the current type is allowed
@throws \Exception | [
"Makes",
"sure",
"the",
"current",
"type",
"is",
"allowed"
] | 551380b33410b0a8e101656eac9093e087add541 | https://github.com/aequasi/environment-php/blob/551380b33410b0a8e101656eac9093e087add541/src/Environment.php#L120-L131 | train |
thelia/core | lib/Thelia/Form/ModuleHookCreationForm.php | ModuleHookCreationForm.verifyTemplates | public function verifyTemplates($value, ExecutionContextInterface $context)
{
$data = $context->getRoot()->getData();
if (!empty($data['templates']) && $data['method'] !== BaseHook::INJECT_TEMPLATE_METHOD_NAME) {
$context->addViolation(
$this->trans(
"If you use automatic insert templates, you should use the method %method%",
[
'%method%' => BaseHook::INJECT_TEMPLATE_METHOD_NAME
]
)
);
}
} | php | public function verifyTemplates($value, ExecutionContextInterface $context)
{
$data = $context->getRoot()->getData();
if (!empty($data['templates']) && $data['method'] !== BaseHook::INJECT_TEMPLATE_METHOD_NAME) {
$context->addViolation(
$this->trans(
"If you use automatic insert templates, you should use the method %method%",
[
'%method%' => BaseHook::INJECT_TEMPLATE_METHOD_NAME
]
)
);
}
} | [
"public",
"function",
"verifyTemplates",
"(",
"$",
"value",
",",
"ExecutionContextInterface",
"$",
"context",
")",
"{",
"$",
"data",
"=",
"$",
"context",
"->",
"getRoot",
"(",
")",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"dat... | Check if method is the right one if we want to use automatic inserted templates .
@param $value
@param ExecutionContextInterface $context
@return bool | [
"Check",
"if",
"method",
"is",
"the",
"right",
"one",
"if",
"we",
"want",
"to",
"use",
"automatic",
"inserted",
"templates",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Form/ModuleHookCreationForm.php#L225-L239 | train |
thelia/core | lib/Thelia/Condition/Operators.php | Operators.getI18n | public static function getI18n(Translator $translator, $operator)
{
$ret = $operator;
switch ($operator) {
case self::INFERIOR:
$ret = $translator->trans(
'Less than',
[]
);
break;
case self::INFERIOR_OR_EQUAL:
$ret = $translator->trans(
'Less than or equals',
[]
);
break;
case self::EQUAL:
$ret = $translator->trans(
'Equal to',
[]
);
break;
case self::SUPERIOR_OR_EQUAL:
$ret = $translator->trans(
'Greater than or equals',
[]
);
break;
case self::SUPERIOR:
$ret = $translator->trans(
'Greater than',
[]
);
break;
case self::DIFFERENT:
$ret = $translator->trans(
'Not equal to',
[]
);
break;
case self::IN:
$ret = $translator->trans(
'In',
[]
);
break;
case self::OUT:
$ret = $translator->trans(
'Not in',
[]
);
break;
default:
}
return $ret;
} | php | public static function getI18n(Translator $translator, $operator)
{
$ret = $operator;
switch ($operator) {
case self::INFERIOR:
$ret = $translator->trans(
'Less than',
[]
);
break;
case self::INFERIOR_OR_EQUAL:
$ret = $translator->trans(
'Less than or equals',
[]
);
break;
case self::EQUAL:
$ret = $translator->trans(
'Equal to',
[]
);
break;
case self::SUPERIOR_OR_EQUAL:
$ret = $translator->trans(
'Greater than or equals',
[]
);
break;
case self::SUPERIOR:
$ret = $translator->trans(
'Greater than',
[]
);
break;
case self::DIFFERENT:
$ret = $translator->trans(
'Not equal to',
[]
);
break;
case self::IN:
$ret = $translator->trans(
'In',
[]
);
break;
case self::OUT:
$ret = $translator->trans(
'Not in',
[]
);
break;
default:
}
return $ret;
} | [
"public",
"static",
"function",
"getI18n",
"(",
"Translator",
"$",
"translator",
",",
"$",
"operator",
")",
"{",
"$",
"ret",
"=",
"$",
"operator",
";",
"switch",
"(",
"$",
"operator",
")",
"{",
"case",
"self",
"::",
"INFERIOR",
":",
"$",
"ret",
"=",
... | Get operator translation
@param Translator $translator Provide necessary value from Thelia
@param string $operator Operator const
@return string | [
"Get",
"operator",
"translation"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/Operators.php#L51-L107 | train |
thelia/core | lib/Thelia/Core/Form/TheliaFormValidator.php | TheliaFormValidator.getErrorMessages | public function getErrorMessages(Form $form)
{
$errors = '';
foreach ($form->getErrors() as $key => $error) {
$errors .= $error->getMessage().', ';
}
/** @var Form $child */
foreach ($form->all() as $child) {
if (!$child->isValid()) {
$fieldName = $child->getConfig()->getOption('label', null);
if (empty($fieldName)) {
$fieldName = $child->getName();
}
$errors .= sprintf("[%s] %s, ", $fieldName, $this->getErrorMessages($child));
}
}
return rtrim($errors, ', ');
} | php | public function getErrorMessages(Form $form)
{
$errors = '';
foreach ($form->getErrors() as $key => $error) {
$errors .= $error->getMessage().', ';
}
/** @var Form $child */
foreach ($form->all() as $child) {
if (!$child->isValid()) {
$fieldName = $child->getConfig()->getOption('label', null);
if (empty($fieldName)) {
$fieldName = $child->getName();
}
$errors .= sprintf("[%s] %s, ", $fieldName, $this->getErrorMessages($child));
}
}
return rtrim($errors, ', ');
} | [
"public",
"function",
"getErrorMessages",
"(",
"Form",
"$",
"form",
")",
"{",
"$",
"errors",
"=",
"''",
";",
"foreach",
"(",
"$",
"form",
"->",
"getErrors",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"error",
")",
"{",
"$",
"errors",
".=",
"$",
"error"... | Get all errors that occurred in a form
@param \Symfony\Component\Form\Form $form
@return string the error string | [
"Get",
"all",
"errors",
"that",
"occurred",
"in",
"a",
"form"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Form/TheliaFormValidator.php#L101-L123 | train |
thelia/core | lib/Thelia/Controller/Admin/AbstractSeoCrudController.php | AbstractSeoCrudController.getUpdateSeoEvent | protected function getUpdateSeoEvent($formData)
{
$updateSeoEvent = new UpdateSeoEvent($formData['id']);
$updateSeoEvent
->setLocale($formData['locale'])
->setMetaTitle($formData['meta_title'])
->setMetaDescription($formData['meta_description'])
->setMetaKeywords($formData['meta_keywords'])
->setUrl($formData['url'])
;
// Create and dispatch the change event
return $updateSeoEvent;
} | php | protected function getUpdateSeoEvent($formData)
{
$updateSeoEvent = new UpdateSeoEvent($formData['id']);
$updateSeoEvent
->setLocale($formData['locale'])
->setMetaTitle($formData['meta_title'])
->setMetaDescription($formData['meta_description'])
->setMetaKeywords($formData['meta_keywords'])
->setUrl($formData['url'])
;
// Create and dispatch the change event
return $updateSeoEvent;
} | [
"protected",
"function",
"getUpdateSeoEvent",
"(",
"$",
"formData",
")",
"{",
"$",
"updateSeoEvent",
"=",
"new",
"UpdateSeoEvent",
"(",
"$",
"formData",
"[",
"'id'",
"]",
")",
";",
"$",
"updateSeoEvent",
"->",
"setLocale",
"(",
"$",
"formData",
"[",
"'locale... | Creates the update SEO event with the provided form data
@param $formData
@return UpdateSeoEvent | [
"Creates",
"the",
"update",
"SEO",
"event",
"with",
"the",
"provided",
"form",
"data"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php#L103-L117 | train |
thelia/core | lib/Thelia/Controller/Admin/AbstractSeoCrudController.php | AbstractSeoCrudController.hydrateSeoForm | protected function hydrateSeoForm($object)
{
// The "SEO" tab form
$locale = $object->getLocale();
$data = array(
'id' => $object->getId(),
'locale' => $locale,
'url' => $object->getRewrittenUrl($locale),
'meta_title' => $object->getMetaTitle(),
'meta_description' => $object->getMetaDescription(),
'meta_keywords' => $object->getMetaKeywords()
);
$seoForm = $this->createForm(AdminForm::SEO, "form", $data);
$this->getParserContext()->addForm($seoForm);
// URL based on the language
$this->getParserContext()->set('url_language', $this->getUrlLanguage($locale));
} | php | protected function hydrateSeoForm($object)
{
// The "SEO" tab form
$locale = $object->getLocale();
$data = array(
'id' => $object->getId(),
'locale' => $locale,
'url' => $object->getRewrittenUrl($locale),
'meta_title' => $object->getMetaTitle(),
'meta_description' => $object->getMetaDescription(),
'meta_keywords' => $object->getMetaKeywords()
);
$seoForm = $this->createForm(AdminForm::SEO, "form", $data);
$this->getParserContext()->addForm($seoForm);
// URL based on the language
$this->getParserContext()->set('url_language', $this->getUrlLanguage($locale));
} | [
"protected",
"function",
"hydrateSeoForm",
"(",
"$",
"object",
")",
"{",
"// The \"SEO\" tab form",
"$",
"locale",
"=",
"$",
"object",
"->",
"getLocale",
"(",
")",
";",
"$",
"data",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"object",
"->",
"getId",
"(",
")",... | Hydrate the SEO form for this object, before passing it to the update template
@param mixed $object | [
"Hydrate",
"the",
"SEO",
"form",
"for",
"this",
"object",
"before",
"passing",
"it",
"to",
"the",
"update",
"template"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php#L124-L142 | train |
thelia/core | lib/Thelia/Controller/Admin/AbstractSeoCrudController.php | AbstractSeoCrudController.processUpdateSeoAction | public function processUpdateSeoAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, $this->getModuleCode(), AccessManager::UPDATE)) {
return $response;
}
// Error (Default: false)
$error_msg = false;
// Create the Form from the request
$updateSeoForm = $this->getUpdateSeoForm($this->getRequest());
// Pass the object id to the request
$this->getRequest()->attributes->set($this->objectName . '_id', $this->getRequest()->get('current_id'));
try {
// Check the form against constraints violations
$form = $this->validateForm($updateSeoForm, "POST");
// Get the form field values
$data = $form->getData();
// Create a new event object with the modified fields
$updateSeoEvent = $this->getUpdateSeoEvent($data);
// Dispatch Update SEO Event
$this->dispatch($this->updateSeoEventIdentifier, $updateSeoEvent);
// Execute additional Action
$response = $this->performAdditionalUpdateSeoAction($updateSeoEvent);
if ($response == null) {
// If we have to stay on the same page, do not redirect to the successUrl,
// just redirect to the edit page again.
if ($this->getRequest()->get('save_mode') == 'stay') {
return $this->redirectToEditionTemplate($this->getRequest());
}
// Redirect to the success URL
return $this->generateSuccessRedirect($updateSeoForm);
} else {
return $response;
}
} catch (FormValidationException $ex) {
// Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
/*} catch (\Exception $ex) {
// Any other error
$error_msg = $ex->getMessage();*/
}
// Load object if exist
if (null !== $object = $this->getExistingObject()) {
// Hydrate the form abd pass it to the parser
$changeForm = $this->hydrateObjectForm($object);
// Pass it to the parser
$this->getParserContext()->addForm($changeForm);
}
if (false !== $error_msg) {
$this->setupFormErrorContext(
$this->getTranslator()->trans("%obj SEO modification", array('%obj' => $this->objectName)),
$error_msg,
$updateSeoForm,
$ex
);
// At this point, the form has errors, and should be redisplayed.
return $this->renderEditionTemplate();
}
} | php | public function processUpdateSeoAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, $this->getModuleCode(), AccessManager::UPDATE)) {
return $response;
}
// Error (Default: false)
$error_msg = false;
// Create the Form from the request
$updateSeoForm = $this->getUpdateSeoForm($this->getRequest());
// Pass the object id to the request
$this->getRequest()->attributes->set($this->objectName . '_id', $this->getRequest()->get('current_id'));
try {
// Check the form against constraints violations
$form = $this->validateForm($updateSeoForm, "POST");
// Get the form field values
$data = $form->getData();
// Create a new event object with the modified fields
$updateSeoEvent = $this->getUpdateSeoEvent($data);
// Dispatch Update SEO Event
$this->dispatch($this->updateSeoEventIdentifier, $updateSeoEvent);
// Execute additional Action
$response = $this->performAdditionalUpdateSeoAction($updateSeoEvent);
if ($response == null) {
// If we have to stay on the same page, do not redirect to the successUrl,
// just redirect to the edit page again.
if ($this->getRequest()->get('save_mode') == 'stay') {
return $this->redirectToEditionTemplate($this->getRequest());
}
// Redirect to the success URL
return $this->generateSuccessRedirect($updateSeoForm);
} else {
return $response;
}
} catch (FormValidationException $ex) {
// Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
/*} catch (\Exception $ex) {
// Any other error
$error_msg = $ex->getMessage();*/
}
// Load object if exist
if (null !== $object = $this->getExistingObject()) {
// Hydrate the form abd pass it to the parser
$changeForm = $this->hydrateObjectForm($object);
// Pass it to the parser
$this->getParserContext()->addForm($changeForm);
}
if (false !== $error_msg) {
$this->setupFormErrorContext(
$this->getTranslator()->trans("%obj SEO modification", array('%obj' => $this->objectName)),
$error_msg,
$updateSeoForm,
$ex
);
// At this point, the form has errors, and should be redisplayed.
return $this->renderEditionTemplate();
}
} | [
"public",
"function",
"processUpdateSeoAction",
"(",
")",
"{",
"// Check current user authorization",
"if",
"(",
"null",
"!==",
"$",
"response",
"=",
"$",
"this",
"->",
"checkAuth",
"(",
"$",
"this",
"->",
"resourceCode",
",",
"$",
"this",
"->",
"getModuleCode",... | Update SEO modification, and either go back to the object list, or stay on the edition page.
@return \Thelia\Core\HttpFoundation\Response the response | [
"Update",
"SEO",
"modification",
"and",
"either",
"go",
"back",
"to",
"the",
"object",
"list",
"or",
"stay",
"on",
"the",
"edition",
"page",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php#L149-L221 | train |
thelia/core | lib/Thelia/Action/Module.php | Module.checkDeactivation | private function checkDeactivation($module)
{
$moduleValidator = new ModuleValidator($module->getAbsoluteBaseDir());
$modules = $moduleValidator->getModulesDependOf();
if (\count($modules) > 0) {
$moduleList = implode(', ', array_column($modules, 'code'));
$message = (\count($modules) == 1)
? Translator::getInstance()->trans(
'%s has dependency to module %s. You have to deactivate this module before.'
)
: Translator::getInstance()->trans(
'%s have dependencies to module %s. You have to deactivate these modules before.'
);
throw new ModuleException(
sprintf($message, $moduleList, $moduleValidator->getModuleDefinition()->getCode())
);
}
return true;
} | php | private function checkDeactivation($module)
{
$moduleValidator = new ModuleValidator($module->getAbsoluteBaseDir());
$modules = $moduleValidator->getModulesDependOf();
if (\count($modules) > 0) {
$moduleList = implode(', ', array_column($modules, 'code'));
$message = (\count($modules) == 1)
? Translator::getInstance()->trans(
'%s has dependency to module %s. You have to deactivate this module before.'
)
: Translator::getInstance()->trans(
'%s have dependencies to module %s. You have to deactivate these modules before.'
);
throw new ModuleException(
sprintf($message, $moduleList, $moduleValidator->getModuleDefinition()->getCode())
);
}
return true;
} | [
"private",
"function",
"checkDeactivation",
"(",
"$",
"module",
")",
"{",
"$",
"moduleValidator",
"=",
"new",
"ModuleValidator",
"(",
"$",
"module",
"->",
"getAbsoluteBaseDir",
"(",
")",
")",
";",
"$",
"modules",
"=",
"$",
"moduleValidator",
"->",
"getModulesD... | Check if module can be deactivated safely because other modules
could have dependencies to this module
@param \Thelia\Model\Module $module
@return bool true if the module can be deactivated, otherwise false | [
"Check",
"if",
"module",
"can",
"be",
"deactivated",
"safely",
"because",
"other",
"modules",
"could",
"have",
"dependencies",
"to",
"this",
"module"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Module.php#L136-L159 | train |
thelia/core | lib/Thelia/Action/Module.php | Module.recursiveActivation | public function recursiveActivation(ModuleToggleActivationEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $module = ModuleQuery::create()->findPk($event->getModuleId())) {
$moduleValidator = new ModuleValidator($module->getAbsoluteBaseDir());
$dependencies = $moduleValidator->getCurrentModuleDependencies();
foreach ($dependencies as $defMod) {
$submodule = ModuleQuery::create()
->findOneByCode($defMod["code"]);
if ($submodule && $submodule->getActivate() != BaseModule::IS_ACTIVATED) {
$subevent = new ModuleToggleActivationEvent($submodule->getId());
$subevent->setRecursive(true);
$dispatcher->dispatch(TheliaEvents::MODULE_TOGGLE_ACTIVATION, $subevent);
}
}
}
} | php | public function recursiveActivation(ModuleToggleActivationEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $module = ModuleQuery::create()->findPk($event->getModuleId())) {
$moduleValidator = new ModuleValidator($module->getAbsoluteBaseDir());
$dependencies = $moduleValidator->getCurrentModuleDependencies();
foreach ($dependencies as $defMod) {
$submodule = ModuleQuery::create()
->findOneByCode($defMod["code"]);
if ($submodule && $submodule->getActivate() != BaseModule::IS_ACTIVATED) {
$subevent = new ModuleToggleActivationEvent($submodule->getId());
$subevent->setRecursive(true);
$dispatcher->dispatch(TheliaEvents::MODULE_TOGGLE_ACTIVATION, $subevent);
}
}
}
} | [
"public",
"function",
"recursiveActivation",
"(",
"ModuleToggleActivationEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"module",
"=",
"ModuleQuery",
"::",
"create",
"(",
... | Get dependencies of the current module and activate it if needed
@param ModuleToggleActivationEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Get",
"dependencies",
"of",
"the",
"current",
"module",
"and",
"activate",
"it",
"if",
"needed"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Module.php#L169-L184 | train |
thelia/core | lib/Thelia/Action/Module.php | Module.pay | public function pay(OrderPaymentEvent $event)
{
$order = $event->getOrder();
/* call pay method */
if (null === $paymentModule = ModuleQuery::create()->findPk($order->getPaymentModuleId())) {
throw new \RuntimeException(
Translator::getInstance()->trans(
"Failed to find a payment Module with ID=%mid for order ID=%oid",
[
"%mid" => $order->getPaymentModuleId(),
"%oid" => $order->getId()
]
)
);
}
$paymentModuleInstance = $paymentModule->getPaymentModuleInstance($this->container);
$response = $paymentModuleInstance->pay($order);
if (null !== $response && $response instanceof Response) {
$event->setResponse($response);
}
} | php | public function pay(OrderPaymentEvent $event)
{
$order = $event->getOrder();
/* call pay method */
if (null === $paymentModule = ModuleQuery::create()->findPk($order->getPaymentModuleId())) {
throw new \RuntimeException(
Translator::getInstance()->trans(
"Failed to find a payment Module with ID=%mid for order ID=%oid",
[
"%mid" => $order->getPaymentModuleId(),
"%oid" => $order->getId()
]
)
);
}
$paymentModuleInstance = $paymentModule->getPaymentModuleInstance($this->container);
$response = $paymentModuleInstance->pay($order);
if (null !== $response && $response instanceof Response) {
$event->setResponse($response);
}
} | [
"public",
"function",
"pay",
"(",
"OrderPaymentEvent",
"$",
"event",
")",
"{",
"$",
"order",
"=",
"$",
"event",
"->",
"getOrder",
"(",
")",
";",
"/* call pay method */",
"if",
"(",
"null",
"===",
"$",
"paymentModule",
"=",
"ModuleQuery",
"::",
"create",
"(... | Call the payment method of the payment module of the given order
@param OrderPaymentEvent $event
@throws \RuntimeException if no payment module can be found. | [
"Call",
"the",
"payment",
"method",
"of",
"the",
"payment",
"module",
"of",
"the",
"given",
"order"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Module.php#L401-L425 | train |
thelia/core | lib/Thelia/Condition/Implementation/MatchForTotalAmount.php | MatchForTotalAmount.isMatching | public function isMatching()
{
$condition1 = $this->conditionValidator->variableOpComparison(
$this->facade->getCartTotalTaxPrice(),
$this->operators[self::CART_TOTAL],
$this->values[self::CART_TOTAL]
);
if ($condition1) {
$condition2 = $this->conditionValidator->variableOpComparison(
$this->facade->getCheckoutCurrency(),
$this->operators[self::CART_CURRENCY],
$this->values[self::CART_CURRENCY]
);
if ($condition2) {
return true;
}
}
return false;
} | php | public function isMatching()
{
$condition1 = $this->conditionValidator->variableOpComparison(
$this->facade->getCartTotalTaxPrice(),
$this->operators[self::CART_TOTAL],
$this->values[self::CART_TOTAL]
);
if ($condition1) {
$condition2 = $this->conditionValidator->variableOpComparison(
$this->facade->getCheckoutCurrency(),
$this->operators[self::CART_CURRENCY],
$this->values[self::CART_CURRENCY]
);
if ($condition2) {
return true;
}
}
return false;
} | [
"public",
"function",
"isMatching",
"(",
")",
"{",
"$",
"condition1",
"=",
"$",
"this",
"->",
"conditionValidator",
"->",
"variableOpComparison",
"(",
"$",
"this",
"->",
"facade",
"->",
"getCartTotalTaxPrice",
"(",
")",
",",
"$",
"this",
"->",
"operators",
"... | Test if Customer meets conditions
@return bool | [
"Test",
"if",
"Customer",
"meets",
"conditions"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php#L93-L114 | train |
grom358/pharborist | src/FileUtil.php | FileUtil.findFiles | public static function findFiles($directory, $extensions = ['php']) {
if (!is_dir($directory)) {
return [];
}
$directory_iterator = new \RecursiveDirectoryIterator($directory);
$iterator = new \RecursiveIteratorIterator($directory_iterator);
$pattern = '/^.+\.(' . implode('|', $extensions) . ')$/i';
$regex = new \RegexIterator($iterator, $pattern, \RecursiveRegexIterator::GET_MATCH);
$files = [];
foreach ($regex as $name => $object) {
$files[] = $name;
}
return $files;
} | php | public static function findFiles($directory, $extensions = ['php']) {
if (!is_dir($directory)) {
return [];
}
$directory_iterator = new \RecursiveDirectoryIterator($directory);
$iterator = new \RecursiveIteratorIterator($directory_iterator);
$pattern = '/^.+\.(' . implode('|', $extensions) . ')$/i';
$regex = new \RegexIterator($iterator, $pattern, \RecursiveRegexIterator::GET_MATCH);
$files = [];
foreach ($regex as $name => $object) {
$files[] = $name;
}
return $files;
} | [
"public",
"static",
"function",
"findFiles",
"(",
"$",
"directory",
",",
"$",
"extensions",
"=",
"[",
"'php'",
"]",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"directory_iterator",
"="... | Recursively find files in a directory with matching extensions.
@param string $directory
Path of directory to search.
@param array $extensions
(Optional) Array of file extensions of files to find.
@return array
List of files found with matching extensions. | [
"Recursively",
"find",
"files",
"in",
"a",
"directory",
"with",
"matching",
"extensions",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/FileUtil.php#L16-L29 | train |
thelia/core | lib/Thelia/Install/CheckDatabaseConnection.php | CheckDatabaseConnection.exec | public function exec()
{
$dsn = "mysql:host=%s;port=%s";
try {
$this->connection = new \PDO(
sprintf($dsn, $this->host, $this->port),
$this->user,
$this->password
);
} catch (\PDOException $e) {
$this->validationMessages = 'Wrong connection information';
$this->isValid = false;
}
return $this->isValid;
} | php | public function exec()
{
$dsn = "mysql:host=%s;port=%s";
try {
$this->connection = new \PDO(
sprintf($dsn, $this->host, $this->port),
$this->user,
$this->password
);
} catch (\PDOException $e) {
$this->validationMessages = 'Wrong connection information';
$this->isValid = false;
}
return $this->isValid;
} | [
"public",
"function",
"exec",
"(",
")",
"{",
"$",
"dsn",
"=",
"\"mysql:host=%s;port=%s\"",
";",
"try",
"{",
"$",
"this",
"->",
"connection",
"=",
"new",
"\\",
"PDO",
"(",
"sprintf",
"(",
"$",
"dsn",
",",
"$",
"this",
"->",
"host",
",",
"$",
"this",
... | Perform database connection check
@return bool | [
"Perform",
"database",
"connection",
"check"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Install/CheckDatabaseConnection.php#L81-L98 | train |
grom358/pharborist | src/DocCommentTrait.php | DocCommentTrait.getIndent | public function getIndent() {
/** @var ParentNode $this */
$whitespace_token = $this->previousToken();
if (empty($whitespace_token) || $whitespace_token->getType() !== T_WHITESPACE) {
return '';
}
$nl = FormatterFactory::getDefaultFormatter()->getConfig('nl');
$lines = explode($nl, $whitespace_token->getText());
$last_line = end($lines);
return $last_line;
} | php | public function getIndent() {
/** @var ParentNode $this */
$whitespace_token = $this->previousToken();
if (empty($whitespace_token) || $whitespace_token->getType() !== T_WHITESPACE) {
return '';
}
$nl = FormatterFactory::getDefaultFormatter()->getConfig('nl');
$lines = explode($nl, $whitespace_token->getText());
$last_line = end($lines);
return $last_line;
} | [
"public",
"function",
"getIndent",
"(",
")",
"{",
"/** @var ParentNode $this */",
"$",
"whitespace_token",
"=",
"$",
"this",
"->",
"previousToken",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"whitespace_token",
")",
"||",
"$",
"whitespace_token",
"->",
"getT... | Get the indent proceeding this node.
@return string | [
"Get",
"the",
"indent",
"proceeding",
"this",
"node",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/DocCommentTrait.php#L15-L25 | train |
thelia/core | lib/Thelia/Model/Coupon.php | Coupon.createOrUpdate | public function createOrUpdate(
$code,
$title,
array $effects,
$type,
$isRemovingPostage,
$shortDescription,
$description,
$isEnabled,
$expirationDate,
$isAvailableOnSpecialOffers,
$isCumulative,
$maxUsage,
$defaultSerializedRule,
$locale,
$freeShippingForCountries,
$freeShippingForMethods,
$perCustomerUsageCount,
$startDate = null
) {
$con = Propel::getWriteConnection(CouponTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$this
->setCode($code)
->setType($type)
->setEffects($effects)
->setIsRemovingPostage($isRemovingPostage)
->setIsEnabled($isEnabled)
->setStartDate($startDate)
->setExpirationDate($expirationDate)
->setIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers)
->setIsCumulative($isCumulative)
->setMaxUsage($maxUsage)
->setPerCustomerUsageCount($perCustomerUsageCount)
->setLocale($locale)
->setTitle($title)
->setShortDescription($shortDescription)
->setDescription($description)
;
// If no rule given, set default rule
if (null === $this->getSerializedConditions()) {
$this->setSerializedConditions($defaultSerializedRule);
}
$this->save();
// Update countries and modules relation for free shipping
CouponCountryQuery::create()->filterByCouponId($this->id)->delete();
CouponModuleQuery::create()->filterByCouponId($this->id)->delete();
foreach ($freeShippingForCountries as $countryId) {
if ($countryId <= 0) {
continue;
}
$couponCountry = new CouponCountry();
$couponCountry
->setCouponId($this->getId())
->setCountryId($countryId)
->save();
;
}
foreach ($freeShippingForMethods as $moduleId) {
if ($moduleId <= 0) {
continue;
}
$couponModule = new CouponModule();
$couponModule
->setCouponId($this->getId())
->setModuleId($moduleId)
->save()
;
}
$con->commit();
} catch (\Exception $ex) {
$con->rollback();
throw $ex;
}
} | php | public function createOrUpdate(
$code,
$title,
array $effects,
$type,
$isRemovingPostage,
$shortDescription,
$description,
$isEnabled,
$expirationDate,
$isAvailableOnSpecialOffers,
$isCumulative,
$maxUsage,
$defaultSerializedRule,
$locale,
$freeShippingForCountries,
$freeShippingForMethods,
$perCustomerUsageCount,
$startDate = null
) {
$con = Propel::getWriteConnection(CouponTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$this
->setCode($code)
->setType($type)
->setEffects($effects)
->setIsRemovingPostage($isRemovingPostage)
->setIsEnabled($isEnabled)
->setStartDate($startDate)
->setExpirationDate($expirationDate)
->setIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers)
->setIsCumulative($isCumulative)
->setMaxUsage($maxUsage)
->setPerCustomerUsageCount($perCustomerUsageCount)
->setLocale($locale)
->setTitle($title)
->setShortDescription($shortDescription)
->setDescription($description)
;
// If no rule given, set default rule
if (null === $this->getSerializedConditions()) {
$this->setSerializedConditions($defaultSerializedRule);
}
$this->save();
// Update countries and modules relation for free shipping
CouponCountryQuery::create()->filterByCouponId($this->id)->delete();
CouponModuleQuery::create()->filterByCouponId($this->id)->delete();
foreach ($freeShippingForCountries as $countryId) {
if ($countryId <= 0) {
continue;
}
$couponCountry = new CouponCountry();
$couponCountry
->setCouponId($this->getId())
->setCountryId($countryId)
->save();
;
}
foreach ($freeShippingForMethods as $moduleId) {
if ($moduleId <= 0) {
continue;
}
$couponModule = new CouponModule();
$couponModule
->setCouponId($this->getId())
->setModuleId($moduleId)
->save()
;
}
$con->commit();
} catch (\Exception $ex) {
$con->rollback();
throw $ex;
}
} | [
"public",
"function",
"createOrUpdate",
"(",
"$",
"code",
",",
"$",
"title",
",",
"array",
"$",
"effects",
",",
"$",
"type",
",",
"$",
"isRemovingPostage",
",",
"$",
"shortDescription",
",",
"$",
"description",
",",
"$",
"isEnabled",
",",
"$",
"expirationD... | Create or Update this Coupon
@param string $code Coupon Code
@param string $title Coupon title
@param array $effects Ready to be serialized in JSON effect params
@param string $type Coupon type
@param bool $isRemovingPostage Is removing Postage
@param string $shortDescription Coupon short description
@param string $description Coupon description
@param boolean $isEnabled Enable/Disable
@param \DateTime $expirationDate Coupon expiration date
@param boolean $isAvailableOnSpecialOffers Is available on special offers
@param boolean $isCumulative Is cumulative
@param int $maxUsage Coupon quantity
@param string $defaultSerializedRule Serialized default rule added if none found
@param string $locale Coupon Language code ISO (ex: fr_FR)
@param array $freeShippingForCountries ID of Countries to which shipping is free
@param array $freeShippingForMethods ID of Shipping modules for which shipping is free
@param bool $perCustomerUsageCount True if usage coiunt is per customer
@param $startDate
@throws \Exception | [
"Create",
"or",
"Update",
"this",
"Coupon"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Coupon.php#L72-L160 | train |
thelia/core | lib/Thelia/Model/Coupon.php | Coupon.createOrUpdateConditions | public function createOrUpdateConditions($serializableConditions, $locale)
{
$this->setSerializedConditions($serializableConditions);
// Set object language (i18n)
if (!\is_null($locale)) {
$this->setLocale($locale);
}
$this->save();
} | php | public function createOrUpdateConditions($serializableConditions, $locale)
{
$this->setSerializedConditions($serializableConditions);
// Set object language (i18n)
if (!\is_null($locale)) {
$this->setLocale($locale);
}
$this->save();
} | [
"public",
"function",
"createOrUpdateConditions",
"(",
"$",
"serializableConditions",
",",
"$",
"locale",
")",
"{",
"$",
"this",
"->",
"setSerializedConditions",
"(",
"$",
"serializableConditions",
")",
";",
"// Set object language (i18n)",
"if",
"(",
"!",
"\\",
"is... | Create or Update this coupon condition
@param string $serializableConditions Serialized conditions ready to be saved
@param string $locale Coupon Language code ISO (ex: fr_FR)
@throws \Exception | [
"Create",
"or",
"Update",
"this",
"coupon",
"condition"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Coupon.php#L170-L180 | train |
thelia/core | lib/Thelia/Model/Coupon.php | Coupon.setAmount | public function setAmount($amount)
{
$effects = $this->unserializeEffects($this->getSerializedEffects());
$effects['amount'] = \floatval($amount);
$this->setEffects($effects);
return $this;
} | php | public function setAmount($amount)
{
$effects = $this->unserializeEffects($this->getSerializedEffects());
$effects['amount'] = \floatval($amount);
$this->setEffects($effects);
return $this;
} | [
"public",
"function",
"setAmount",
"(",
"$",
"amount",
")",
"{",
"$",
"effects",
"=",
"$",
"this",
"->",
"unserializeEffects",
"(",
"$",
"this",
"->",
"getSerializedEffects",
"(",
")",
")",
";",
"$",
"effects",
"[",
"'amount'",
"]",
"=",
"\\",
"floatval"... | Set Coupon amount
@param float $amount Amount deduced from the Cart
@return $this | [
"Set",
"Coupon",
"amount"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Coupon.php#L189-L196 | train |
thelia/core | lib/Thelia/Model/Coupon.php | Coupon.getUsagesLeft | public function getUsagesLeft($customerId = null)
{
$usageLeft = $this->getMaxUsage();
if ($this->getPerCustomerUsageCount()) {
// Get usage left for current customer. If the record is not found,
// it means that the customer has not yes used this coupon.
if (null !== $couponCustomerCount = CouponCustomerCountQuery::create()
->filterByCouponId($this->getId())
->filterByCustomerId($customerId)
->findOne()) {
// The coupon has already been used -> remove this customer's usage count
$usageLeft -= $couponCustomerCount->getCount();
}
}
return $usageLeft;
} | php | public function getUsagesLeft($customerId = null)
{
$usageLeft = $this->getMaxUsage();
if ($this->getPerCustomerUsageCount()) {
// Get usage left for current customer. If the record is not found,
// it means that the customer has not yes used this coupon.
if (null !== $couponCustomerCount = CouponCustomerCountQuery::create()
->filterByCouponId($this->getId())
->filterByCustomerId($customerId)
->findOne()) {
// The coupon has already been used -> remove this customer's usage count
$usageLeft -= $couponCustomerCount->getCount();
}
}
return $usageLeft;
} | [
"public",
"function",
"getUsagesLeft",
"(",
"$",
"customerId",
"=",
"null",
")",
"{",
"$",
"usageLeft",
"=",
"$",
"this",
"->",
"getMaxUsage",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getPerCustomerUsageCount",
"(",
")",
")",
"{",
"// Get usage left f... | Get coupon usage left, either overall, or per customer.
@param int|null $customerId the ID of the ordering customer
@return int the usage left. | [
"Get",
"coupon",
"usage",
"left",
"either",
"overall",
"or",
"per",
"customer",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Coupon.php#L297-L314 | train |
thelia/core | lib/Thelia/Controller/Admin/FileController.php | FileController.processImage | public function processImage(
$fileBeingUploaded,
$parentId,
$parentType,
$objectType,
$validMimeTypes = array(),
$extBlackList = array()
) {
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 2.6. Please use the process method File present in the same class.', E_USER_DEPRECATED);
return $this->processFile($fileBeingUploaded, $parentId, $parentType, $objectType, $validMimeTypes, $extBlackList);
} | php | public function processImage(
$fileBeingUploaded,
$parentId,
$parentType,
$objectType,
$validMimeTypes = array(),
$extBlackList = array()
) {
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 2.6. Please use the process method File present in the same class.', E_USER_DEPRECATED);
return $this->processFile($fileBeingUploaded, $parentId, $parentType, $objectType, $validMimeTypes, $extBlackList);
} | [
"public",
"function",
"processImage",
"(",
"$",
"fileBeingUploaded",
",",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"objectType",
",",
"$",
"validMimeTypes",
"=",
"array",
"(",
")",
",",
"$",
"extBlackList",
"=",
"array",
"(",
")",
")",
"{",
"@"... | Process file uploaded
@param UploadedFile $fileBeingUploaded
@param int $parentId
@param string $parentType
@param string $objectType
@param array $validMimeTypes
@param array $extBlackList
@return ResponseRest
@deprecated since version 2.3, to be removed in 2.6. Please use the process method File present in the same class. | [
"Process",
"file",
"uploaded"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/FileController.php#L119-L130 | train |
thelia/core | lib/Thelia/Controller/Admin/FileController.php | FileController.saveImageAjaxAction | public function saveImageAjaxAction($parentId, $parentType)
{
$config = FileConfiguration::getImageConfig();
return $this->saveFileAjaxAction(
$parentId,
$parentType,
$config['objectType'],
$config['validMimeTypes'],
$config['extBlackList']
);
} | php | public function saveImageAjaxAction($parentId, $parentType)
{
$config = FileConfiguration::getImageConfig();
return $this->saveFileAjaxAction(
$parentId,
$parentType,
$config['objectType'],
$config['validMimeTypes'],
$config['extBlackList']
);
} | [
"public",
"function",
"saveImageAjaxAction",
"(",
"$",
"parentId",
",",
"$",
"parentType",
")",
"{",
"$",
"config",
"=",
"FileConfiguration",
"::",
"getImageConfig",
"(",
")",
";",
"return",
"$",
"this",
"->",
"saveFileAjaxAction",
"(",
"$",
"parentId",
",",
... | Manage how a image collection has to be saved
@param int $parentId Parent id owning images being saved
@param string $parentType Parent Type owning images being saved
@return Response | [
"Manage",
"how",
"a",
"image",
"collection",
"has",
"to",
"be",
"saved"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/FileController.php#L269-L279 | train |
thelia/core | lib/Thelia/Controller/Admin/FileController.php | FileController.saveDocumentAjaxAction | public function saveDocumentAjaxAction($parentId, $parentType)
{
$config = FileConfiguration::getDocumentConfig();
return $this->saveFileAjaxAction(
$parentId,
$parentType,
$config['objectType'],
$config['validMimeTypes'],
$config['extBlackList']
);
} | php | public function saveDocumentAjaxAction($parentId, $parentType)
{
$config = FileConfiguration::getDocumentConfig();
return $this->saveFileAjaxAction(
$parentId,
$parentType,
$config['objectType'],
$config['validMimeTypes'],
$config['extBlackList']
);
} | [
"public",
"function",
"saveDocumentAjaxAction",
"(",
"$",
"parentId",
",",
"$",
"parentType",
")",
"{",
"$",
"config",
"=",
"FileConfiguration",
"::",
"getDocumentConfig",
"(",
")",
";",
"return",
"$",
"this",
"->",
"saveFileAjaxAction",
"(",
"$",
"parentId",
... | Manage how a document collection has to be saved
@param int $parentId Parent id owning documents being saved
@param string $parentType Parent Type owning documents being saved
@return Response | [
"Manage",
"how",
"a",
"document",
"collection",
"has",
"to",
"be",
"saved"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/FileController.php#L289-L299 | train |
thelia/core | lib/Thelia/Controller/Admin/FileController.php | FileController.viewImageAction | public function viewImageAction($imageId, $parentType)
{
if (null !== $response = $this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE)) {
return $response;
}
$fileManager = $this->getFileManager();
$imageModel = $fileManager->getModelInstance('image', $parentType);
$image = $imageModel->getQueryInstance()->findPk($imageId);
$redirectUrl = $image->getRedirectionUrl();
return $this->render('image-edit', array(
'imageId' => $imageId,
'imageType' => $parentType,
'redirectUrl' => $redirectUrl,
'formId' => $imageModel->getUpdateFormId(),
'breadcrumb' => $image->getBreadcrumb(
$this->getRouter($this->getCurrentRouter()),
$this->container,
'images',
$this->getCurrentEditionLocale()
)
));
} | php | public function viewImageAction($imageId, $parentType)
{
if (null !== $response = $this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE)) {
return $response;
}
$fileManager = $this->getFileManager();
$imageModel = $fileManager->getModelInstance('image', $parentType);
$image = $imageModel->getQueryInstance()->findPk($imageId);
$redirectUrl = $image->getRedirectionUrl();
return $this->render('image-edit', array(
'imageId' => $imageId,
'imageType' => $parentType,
'redirectUrl' => $redirectUrl,
'formId' => $imageModel->getUpdateFormId(),
'breadcrumb' => $image->getBreadcrumb(
$this->getRouter($this->getCurrentRouter()),
$this->container,
'images',
$this->getCurrentEditionLocale()
)
));
} | [
"public",
"function",
"viewImageAction",
"(",
"$",
"imageId",
",",
"$",
"parentType",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"response",
"=",
"$",
"this",
"->",
"checkAuth",
"(",
"$",
"this",
"->",
"getAdminResources",
"(",
")",
"->",
"getResource",
"(... | Manage how an image is viewed
@param int $imageId Parent id owning images being saved
@param string $parentType Parent Type owning images being saved
@return Response | [
"Manage",
"how",
"an",
"image",
"is",
"viewed"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/FileController.php#L377-L401 | train |
thelia/core | lib/Thelia/Controller/Admin/FileController.php | FileController.viewDocumentAction | public function viewDocumentAction($documentId, $parentType)
{
if (null !== $response = $this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE)) {
return $response;
}
$fileManager = $this->getFileManager();
$documentModel = $fileManager->getModelInstance('document', $parentType);
$document = $documentModel->getQueryInstance()->findPk($documentId);
$redirectUrl = $document->getRedirectionUrl();
return $this->render('document-edit', array(
'documentId' => $documentId,
'documentType' => $parentType,
'redirectUrl' => $redirectUrl,
'formId' => $documentModel->getUpdateFormId(),
'breadcrumb' => $document->getBreadcrumb(
$this->getRouter($this->getCurrentRouter()),
$this->container,
'documents',
$this->getCurrentEditionLocale()
)
));
} | php | public function viewDocumentAction($documentId, $parentType)
{
if (null !== $response = $this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE)) {
return $response;
}
$fileManager = $this->getFileManager();
$documentModel = $fileManager->getModelInstance('document', $parentType);
$document = $documentModel->getQueryInstance()->findPk($documentId);
$redirectUrl = $document->getRedirectionUrl();
return $this->render('document-edit', array(
'documentId' => $documentId,
'documentType' => $parentType,
'redirectUrl' => $redirectUrl,
'formId' => $documentModel->getUpdateFormId(),
'breadcrumb' => $document->getBreadcrumb(
$this->getRouter($this->getCurrentRouter()),
$this->container,
'documents',
$this->getCurrentEditionLocale()
)
));
} | [
"public",
"function",
"viewDocumentAction",
"(",
"$",
"documentId",
",",
"$",
"parentType",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"response",
"=",
"$",
"this",
"->",
"checkAuth",
"(",
"$",
"this",
"->",
"getAdminResources",
"(",
")",
"->",
"getResource"... | Manage how an document is viewed
@param int $documentId Parent id owning images being saved
@param string $parentType Parent Type owning images being saved
@return Response | [
"Manage",
"how",
"an",
"document",
"is",
"viewed"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/FileController.php#L411-L436 | train |
thelia/core | lib/Thelia/Controller/Admin/FileController.php | FileController.updateImageAction | public function updateImageAction($imageId, $parentType)
{
if (null !== $response = $this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE)) {
return $response;
}
$imageInstance = $this->updateFileAction($imageId, $parentType, 'image', TheliaEvents::IMAGE_UPDATE);
if ($imageInstance instanceof \Symfony\Component\HttpFoundation\Response) {
return $imageInstance;
} else {
return $this->render('image-edit', array(
'imageId' => $imageId,
'imageType' => $parentType,
'redirectUrl' => $imageInstance->getRedirectionUrl(),
'formId' => $imageInstance->getUpdateFormId()
));
}
} | php | public function updateImageAction($imageId, $parentType)
{
if (null !== $response = $this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE)) {
return $response;
}
$imageInstance = $this->updateFileAction($imageId, $parentType, 'image', TheliaEvents::IMAGE_UPDATE);
if ($imageInstance instanceof \Symfony\Component\HttpFoundation\Response) {
return $imageInstance;
} else {
return $this->render('image-edit', array(
'imageId' => $imageId,
'imageType' => $parentType,
'redirectUrl' => $imageInstance->getRedirectionUrl(),
'formId' => $imageInstance->getUpdateFormId()
));
}
} | [
"public",
"function",
"updateImageAction",
"(",
"$",
"imageId",
",",
"$",
"parentType",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"response",
"=",
"$",
"this",
"->",
"checkAuth",
"(",
"$",
"this",
"->",
"getAdminResources",
"(",
")",
"->",
"getResource",
... | Manage how an image is updated
@param int $imageId Parent id owning images being saved
@param string $parentType Parent Type owning images being saved
@return Response | [
"Manage",
"how",
"an",
"image",
"is",
"updated"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/FileController.php#L564-L582 | train |
thelia/core | lib/Thelia/Controller/Admin/FileController.php | FileController.updateDocumentAction | public function updateDocumentAction($documentId, $parentType)
{
if (null !== $response = $this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE)) {
return $response;
}
$documentInstance = $this->updateFileAction($documentId, $parentType, 'document', TheliaEvents::DOCUMENT_UPDATE);
if ($documentInstance instanceof \Symfony\Component\HttpFoundation\Response) {
return $documentInstance;
} else {
return $this->render('document-edit', array(
'documentId' => $documentId,
'documentType' => $parentType,
'redirectUrl' => $documentInstance->getRedirectionUrl(),
'formId' => $documentInstance->getUpdateFormId()
));
}
} | php | public function updateDocumentAction($documentId, $parentType)
{
if (null !== $response = $this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE)) {
return $response;
}
$documentInstance = $this->updateFileAction($documentId, $parentType, 'document', TheliaEvents::DOCUMENT_UPDATE);
if ($documentInstance instanceof \Symfony\Component\HttpFoundation\Response) {
return $documentInstance;
} else {
return $this->render('document-edit', array(
'documentId' => $documentId,
'documentType' => $parentType,
'redirectUrl' => $documentInstance->getRedirectionUrl(),
'formId' => $documentInstance->getUpdateFormId()
));
}
} | [
"public",
"function",
"updateDocumentAction",
"(",
"$",
"documentId",
",",
"$",
"parentType",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"response",
"=",
"$",
"this",
"->",
"checkAuth",
"(",
"$",
"this",
"->",
"getAdminResources",
"(",
")",
"->",
"getResourc... | Manage how an document is updated
@param int $documentId Parent id owning documents being saved
@param string $parentType Parent Type owning documents being saved
@return Response | [
"Manage",
"how",
"an",
"document",
"is",
"updated"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/FileController.php#L592-L610 | train |
thelia/core | lib/Thelia/Controller/Admin/FileController.php | FileController.deleteFileAction | public function deleteFileAction($fileId, $parentType, $objectType, $eventName)
{
$message = null;
$this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE);
$this->checkXmlHttpRequest();
$fileManager = $this->getFileManager();
$modelInstance = $fileManager->getModelInstance($objectType, $parentType);
$model = $modelInstance->getQueryInstance()->findPk($fileId);
if ($model == null) {
return $this->pageNotFound();
}
// Feed event
$fileDeleteEvent = new FileDeleteEvent($model);
// Dispatch Event to the Action
try {
$this->dispatch($eventName, $fileDeleteEvent);
$this->adminLogAppend(
$this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT),
AccessManager::UPDATE,
$this->getTranslator()->trans(
'Deleting %obj% for %id% with parent id %parentId%',
array(
'%obj%' => $objectType,
'%id%' => $fileDeleteEvent->getFileToDelete()->getId(),
'%parentId%' => $fileDeleteEvent->getFileToDelete()->getParentId(),
)
),
$fileDeleteEvent->getFileToDelete()->getId()
);
} catch (\Exception $e) {
$message = $this->getTranslator()->trans(
'Fail to delete %obj% for %id% with parent id %parentId% (Exception : %e%)',
array(
'%obj%' => $objectType,
'%id%' => $fileDeleteEvent->getFileToDelete()->getId(),
'%parentId%' => $fileDeleteEvent->getFileToDelete()->getParentId(),
'%e%' => $e->getMessage()
)
);
$this->adminLogAppend(
$this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT),
AccessManager::UPDATE,
$message,
$fileDeleteEvent->getFileToDelete()->getId()
);
}
if (null === $message) {
$message = $this->getTranslator()->trans(
'%obj%s deleted successfully',
['%obj%' => ucfirst($objectType)],
'image'
);
}
return new Response($message);
} | php | public function deleteFileAction($fileId, $parentType, $objectType, $eventName)
{
$message = null;
$this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE);
$this->checkXmlHttpRequest();
$fileManager = $this->getFileManager();
$modelInstance = $fileManager->getModelInstance($objectType, $parentType);
$model = $modelInstance->getQueryInstance()->findPk($fileId);
if ($model == null) {
return $this->pageNotFound();
}
// Feed event
$fileDeleteEvent = new FileDeleteEvent($model);
// Dispatch Event to the Action
try {
$this->dispatch($eventName, $fileDeleteEvent);
$this->adminLogAppend(
$this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT),
AccessManager::UPDATE,
$this->getTranslator()->trans(
'Deleting %obj% for %id% with parent id %parentId%',
array(
'%obj%' => $objectType,
'%id%' => $fileDeleteEvent->getFileToDelete()->getId(),
'%parentId%' => $fileDeleteEvent->getFileToDelete()->getParentId(),
)
),
$fileDeleteEvent->getFileToDelete()->getId()
);
} catch (\Exception $e) {
$message = $this->getTranslator()->trans(
'Fail to delete %obj% for %id% with parent id %parentId% (Exception : %e%)',
array(
'%obj%' => $objectType,
'%id%' => $fileDeleteEvent->getFileToDelete()->getId(),
'%parentId%' => $fileDeleteEvent->getFileToDelete()->getParentId(),
'%e%' => $e->getMessage()
)
);
$this->adminLogAppend(
$this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT),
AccessManager::UPDATE,
$message,
$fileDeleteEvent->getFileToDelete()->getId()
);
}
if (null === $message) {
$message = $this->getTranslator()->trans(
'%obj%s deleted successfully',
['%obj%' => ucfirst($objectType)],
'image'
);
}
return new Response($message);
} | [
"public",
"function",
"deleteFileAction",
"(",
"$",
"fileId",
",",
"$",
"parentType",
",",
"$",
"objectType",
",",
"$",
"eventName",
")",
"{",
"$",
"message",
"=",
"null",
";",
"$",
"this",
"->",
"checkAuth",
"(",
"$",
"this",
"->",
"getAdminResources",
... | Manage how a file has to be deleted
@param int $fileId Parent id owning file being deleted
@param string $parentType Parent Type owning file being deleted
@param string $objectType the type of the file, image or document
@param string $eventName the event type.
@return Response | [
"Manage",
"how",
"a",
"file",
"has",
"to",
"be",
"deleted"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/FileController.php#L622-L686 | train |
NotifyMeHQ/notifyme | src/Adapters/Slack/SlackGateway.php | SlackGateway.formatMessage | public function formatMessage($string)
{
$string = str_replace('&', '&', $string);
$string = str_replace('<', '<', $string);
$string = str_replace('>', '>', $string);
return $string;
} | php | public function formatMessage($string)
{
$string = str_replace('&', '&', $string);
$string = str_replace('<', '<', $string);
$string = str_replace('>', '>', $string);
return $string;
} | [
"public",
"function",
"formatMessage",
"(",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"'&'",
",",
"'&'",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"str_replace",
"(",
"'<'",
",",
"'<'",
",",
"$",
"string",
")",
"... | Formats a string for Slack.
@param string $string
@return string | [
"Formats",
"a",
"string",
"for",
"Slack",
"."
] | 2af4bdcfe9df6db7ea79e2dce90b106ccb285b06 | https://github.com/NotifyMeHQ/notifyme/blob/2af4bdcfe9df6db7ea79e2dce90b106ccb285b06/src/Adapters/Slack/SlackGateway.php#L73-L80 | train |
thelia/core | lib/Thelia/Action/Config.php | Config.create | public function create(ConfigCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$config = new ConfigModel();
$config->setDispatcher($dispatcher)
->setName($event->getEventName())
->setValue($event->getValue())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setHidden($event->getHidden())
->setSecured($event->getSecured())
->save();
$event->setConfig($config);
} | php | public function create(ConfigCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$config = new ConfigModel();
$config->setDispatcher($dispatcher)
->setName($event->getEventName())
->setValue($event->getValue())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setHidden($event->getHidden())
->setSecured($event->getSecured())
->save();
$event->setConfig($config);
} | [
"public",
"function",
"create",
"(",
"ConfigCreateEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"config",
"=",
"new",
"ConfigModel",
"(",
")",
";",
"$",
"config",
"->",
"setDispatcher",
"(",
"... | Create a new configuration entry
@param \Thelia\Core\Event\Config\ConfigCreateEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Create",
"a",
"new",
"configuration",
"entry"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Config.php#L33-L47 | train |
thelia/core | lib/Thelia/Action/Config.php | Config.setValue | public function setValue(ConfigUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) {
if ($event->getValue() !== $config->getValue()) {
$config->setDispatcher($dispatcher)->setValue($event->getValue())->save();
$event->setConfig($config);
}
}
} | php | public function setValue(ConfigUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) {
if ($event->getValue() !== $config->getValue()) {
$config->setDispatcher($dispatcher)->setValue($event->getValue())->save();
$event->setConfig($config);
}
}
} | [
"public",
"function",
"setValue",
"(",
"ConfigUpdateEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"config",
"=",
"ConfigQuery",
"::",
"create",
"(",
")",
"->",
"findP... | Change a configuration entry value
@param \Thelia\Core\Event\Config\ConfigUpdateEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Change",
"a",
"configuration",
"entry",
"value"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Config.php#L56-L65 | train |
thelia/core | lib/Thelia/Action/Config.php | Config.modify | public function modify(ConfigUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) {
$config->setDispatcher($dispatcher)
->setName($event->getEventName())
->setValue($event->getValue())
->setHidden($event->getHidden())
->setSecured($event->getSecured())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
->setChapo($event->getChapo())
->setPostscriptum($event->getPostscriptum())
->save();
$event->setConfig($config);
}
} | php | public function modify(ConfigUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) {
$config->setDispatcher($dispatcher)
->setName($event->getEventName())
->setValue($event->getValue())
->setHidden($event->getHidden())
->setSecured($event->getSecured())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
->setChapo($event->getChapo())
->setPostscriptum($event->getPostscriptum())
->save();
$event->setConfig($config);
}
} | [
"public",
"function",
"modify",
"(",
"ConfigUpdateEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"config",
"=",
"ConfigQuery",
"::",
"create",
"(",
")",
"->",
"findPk"... | Change a configuration entry
@param \Thelia\Core\Event\Config\ConfigUpdateEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Change",
"a",
"configuration",
"entry"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Config.php#L74-L91 | train |
thelia/core | lib/Thelia/Action/Config.php | Config.delete | public function delete(ConfigDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== ($config = ConfigQuery::create()->findPk($event->getConfigId()))) {
if (!$config->getSecured()) {
$config->setDispatcher($dispatcher)->delete();
$event->setConfig($config);
}
}
} | php | public function delete(ConfigDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== ($config = ConfigQuery::create()->findPk($event->getConfigId()))) {
if (!$config->getSecured()) {
$config->setDispatcher($dispatcher)->delete();
$event->setConfig($config);
}
}
} | [
"public",
"function",
"delete",
"(",
"ConfigDeleteEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"config",
"=",
"ConfigQuery",
"::",
"create",
"(",
")",
"->",
"... | Delete a configuration entry
@param \Thelia\Core\Event\Config\ConfigDeleteEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Delete",
"a",
"configuration",
"entry"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Config.php#L100-L109 | train |
thelia/core | lib/Thelia/Form/StandardDescriptionFieldsTrait.php | StandardDescriptionFieldsTrait.addStandardDescFields | protected function addStandardDescFields($exclude = array())
{
if (! \in_array('locale', $exclude)) {
$this->formBuilder->add(
'locale',
'hidden',
[
'constraints' => [ new NotBlank() ],
'required' => true,
]
);
}
if (! \in_array('title', $exclude)) {
$this->formBuilder->add(
'title',
'text',
[
'constraints' => [ new NotBlank() ],
'required' => true,
'label' => Translator::getInstance()->trans('Title'),
'label_attr' => [
'for' => 'title_field',
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('A descriptive title'),
]
]
);
}
if (! \in_array('chapo', $exclude)) {
$this->formBuilder->add(
'chapo',
'textarea',
[
'constraints' => [ ],
'required' => false,
'label' => Translator::getInstance()->trans('Summary'),
'label_attr' => [
'for' => 'summary_field',
'help' => Translator::getInstance()->trans('A short description, used when a summary or an introduction is required'),
],
'attr' => [
'rows' => 3,
'placeholder' => Translator::getInstance()->trans('Short description text'),
]
]
);
}
if (! \in_array('description', $exclude)) {
$this->formBuilder->add(
'description',
'textarea',
[
'constraints' => [ ],
'required' => false,
'label' => Translator::getInstance()->trans('Detailed description'),
'label_attr' => [
'for' => 'detailed_description_field',
'help' => Translator::getInstance()->trans('The detailed description.'),
],
'attr' => [
'rows' => 10,
]
]
);
}
if (! \in_array('postscriptum', $exclude)) {
$this->formBuilder->add(
'postscriptum',
'textarea',
[
'constraints' => [ ],
'required' => false,
'label' => Translator::getInstance()->trans('Conclusion'),
'label_attr' => [
'for' => 'conclusion_field',
'help' => Translator::getInstance()->trans('A short text, used when an additional or supplemental information is required.'),
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('Short additional text'),
'rows' => 3,
]
]
);
}
} | php | protected function addStandardDescFields($exclude = array())
{
if (! \in_array('locale', $exclude)) {
$this->formBuilder->add(
'locale',
'hidden',
[
'constraints' => [ new NotBlank() ],
'required' => true,
]
);
}
if (! \in_array('title', $exclude)) {
$this->formBuilder->add(
'title',
'text',
[
'constraints' => [ new NotBlank() ],
'required' => true,
'label' => Translator::getInstance()->trans('Title'),
'label_attr' => [
'for' => 'title_field',
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('A descriptive title'),
]
]
);
}
if (! \in_array('chapo', $exclude)) {
$this->formBuilder->add(
'chapo',
'textarea',
[
'constraints' => [ ],
'required' => false,
'label' => Translator::getInstance()->trans('Summary'),
'label_attr' => [
'for' => 'summary_field',
'help' => Translator::getInstance()->trans('A short description, used when a summary or an introduction is required'),
],
'attr' => [
'rows' => 3,
'placeholder' => Translator::getInstance()->trans('Short description text'),
]
]
);
}
if (! \in_array('description', $exclude)) {
$this->formBuilder->add(
'description',
'textarea',
[
'constraints' => [ ],
'required' => false,
'label' => Translator::getInstance()->trans('Detailed description'),
'label_attr' => [
'for' => 'detailed_description_field',
'help' => Translator::getInstance()->trans('The detailed description.'),
],
'attr' => [
'rows' => 10,
]
]
);
}
if (! \in_array('postscriptum', $exclude)) {
$this->formBuilder->add(
'postscriptum',
'textarea',
[
'constraints' => [ ],
'required' => false,
'label' => Translator::getInstance()->trans('Conclusion'),
'label_attr' => [
'for' => 'conclusion_field',
'help' => Translator::getInstance()->trans('A short text, used when an additional or supplemental information is required.'),
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('Short additional text'),
'rows' => 3,
]
]
);
}
} | [
"protected",
"function",
"addStandardDescFields",
"(",
"$",
"exclude",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"'locale'",
",",
"$",
"exclude",
")",
")",
"{",
"$",
"this",
"->",
"formBuilder",
"->",
"add",
"(",
"'locale... | Add standard description fields + locale tot the form
@param array $exclude name of the fields that should not be added to the form | [
"Add",
"standard",
"description",
"fields",
"+",
"locale",
"tot",
"the",
"form"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Form/StandardDescriptionFieldsTrait.php#L30-L119 | train |
thelia/core | lib/Thelia/Core/Serializer/Serializer/XMLSerializer.php | XMLSerializer.setDataNodeName | public function setDataNodeName($dataNodeName)
{
$this->dataNodeName = $dataNodeName;
$this->xmlEncoder->setRootNodeName($this->dataNodeName);
return $this;
} | php | public function setDataNodeName($dataNodeName)
{
$this->dataNodeName = $dataNodeName;
$this->xmlEncoder->setRootNodeName($this->dataNodeName);
return $this;
} | [
"public",
"function",
"setDataNodeName",
"(",
"$",
"dataNodeName",
")",
"{",
"$",
"this",
"->",
"dataNodeName",
"=",
"$",
"dataNodeName",
";",
"$",
"this",
"->",
"xmlEncoder",
"->",
"setRootNodeName",
"(",
"$",
"this",
"->",
"dataNodeName",
")",
";",
"return... | Set data node name
@param string $dataNodeName Root node name
@return $this Return $this, allow chaining | [
"Set",
"data",
"node",
"name"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Serializer/Serializer/XMLSerializer.php#L114-L120 | train |
thelia/core | lib/Thelia/Core/EventListener/RequestListener.php | RequestListener.registerPreviousUrl | public function registerPreviousUrl(PostResponseEvent $event)
{
$request = $event->getRequest();
if (!$request->isXmlHttpRequest() && $event->getResponse()->isSuccessful()) {
$referrer = $request->attributes->get('_previous_url', null);
$catalogViews = ['category', 'product'];
$view = $request->attributes->get('_view', null);
if (null !== $referrer) {
// A previous URL (or the keyword 'dont-save') has been specified.
if ('dont-save' == $referrer) {
// We should not save the current URL as the previous URL
$referrer = null;
}
} else {
// The current URL will become the previous URL
$referrer = $request->getUri();
}
// Set previous URL, if defined
if (null !== $referrer) {
/** @var Session $session */
$session = $request->getSession();
if (ConfigQuery::isMultiDomainActivated()) {
$components = parse_url($referrer);
$lang = LangQuery::create()
->filterByUrl(sprintf("%s://%s", $components["scheme"], $components["host"]), ModelCriteria::LIKE)
->findOne();
if (null !== $lang) {
$session->setReturnToUrl($referrer);
if (\in_array($view, $catalogViews)) {
$session->setReturnToCatalogLastUrl($referrer);
}
}
} else {
if (false !== strpos($referrer, $request->getSchemeAndHttpHost())) {
$session->setReturnToUrl($referrer);
if (\in_array($view, $catalogViews)) {
$session->setReturnToCatalogLastUrl($referrer);
}
}
}
}
}
} | php | public function registerPreviousUrl(PostResponseEvent $event)
{
$request = $event->getRequest();
if (!$request->isXmlHttpRequest() && $event->getResponse()->isSuccessful()) {
$referrer = $request->attributes->get('_previous_url', null);
$catalogViews = ['category', 'product'];
$view = $request->attributes->get('_view', null);
if (null !== $referrer) {
// A previous URL (or the keyword 'dont-save') has been specified.
if ('dont-save' == $referrer) {
// We should not save the current URL as the previous URL
$referrer = null;
}
} else {
// The current URL will become the previous URL
$referrer = $request->getUri();
}
// Set previous URL, if defined
if (null !== $referrer) {
/** @var Session $session */
$session = $request->getSession();
if (ConfigQuery::isMultiDomainActivated()) {
$components = parse_url($referrer);
$lang = LangQuery::create()
->filterByUrl(sprintf("%s://%s", $components["scheme"], $components["host"]), ModelCriteria::LIKE)
->findOne();
if (null !== $lang) {
$session->setReturnToUrl($referrer);
if (\in_array($view, $catalogViews)) {
$session->setReturnToCatalogLastUrl($referrer);
}
}
} else {
if (false !== strpos($referrer, $request->getSchemeAndHttpHost())) {
$session->setReturnToUrl($referrer);
if (\in_array($view, $catalogViews)) {
$session->setReturnToCatalogLastUrl($referrer);
}
}
}
}
}
} | [
"public",
"function",
"registerPreviousUrl",
"(",
"PostResponseEvent",
"$",
"event",
")",
"{",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"if",
"(",
"!",
"$",
"request",
"->",
"isXmlHttpRequest",
"(",
")",
"&&",
"$",
"event",
"... | Save the previous URL in session which is based on the referer header or the request, or
the _previous_url request attribute, if defined.
If the value of _previous_url is "dont-save", the current referrer is not saved.
@param \Symfony\Component\HttpKernel\Event\PostResponseEvent $event | [
"Save",
"the",
"previous",
"URL",
"in",
"session",
"which",
"is",
"based",
"on",
"the",
"referer",
"header",
"or",
"the",
"request",
"or",
"the",
"_previous_url",
"request",
"attribute",
"if",
"defined",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/EventListener/RequestListener.php#L226-L277 | train |
NotifyMeHQ/notifyme | src/Adapters/Webhook/WebhookFactory.php | WebhookFactory.make | public function make(array $config)
{
Arr::requires($config, ['endpoint']);
$client = new Client();
return new WebhookGateway($client, $config);
} | php | public function make(array $config)
{
Arr::requires($config, ['endpoint']);
$client = new Client();
return new WebhookGateway($client, $config);
} | [
"public",
"function",
"make",
"(",
"array",
"$",
"config",
")",
"{",
"Arr",
"::",
"requires",
"(",
"$",
"config",
",",
"[",
"'endpoint'",
"]",
")",
";",
"$",
"client",
"=",
"new",
"Client",
"(",
")",
";",
"return",
"new",
"WebhookGateway",
"(",
"$",
... | Create a new webhook gateway instance.
@param string[] $config
@return \NotifyMeHQ\Adapters\Webhook\WebhookGateway | [
"Create",
"a",
"new",
"webhook",
"gateway",
"instance",
"."
] | 2af4bdcfe9df6db7ea79e2dce90b106ccb285b06 | https://github.com/NotifyMeHQ/notifyme/blob/2af4bdcfe9df6db7ea79e2dce90b106ccb285b06/src/Adapters/Webhook/WebhookFactory.php#L27-L34 | train |
grom358/pharborist | src/Types/TrueNode.php | TrueNode.create | public static function create($boolean = TRUE) {
$is_upper = FormatterFactory::getDefaultFormatter()->getConfig('boolean_null_upper');
$node = new TrueNode();
$node->addChild(NameNode::create($is_upper ? 'TRUE' : 'true'), 'constantName');
return $node;
} | php | public static function create($boolean = TRUE) {
$is_upper = FormatterFactory::getDefaultFormatter()->getConfig('boolean_null_upper');
$node = new TrueNode();
$node->addChild(NameNode::create($is_upper ? 'TRUE' : 'true'), 'constantName');
return $node;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"boolean",
"=",
"TRUE",
")",
"{",
"$",
"is_upper",
"=",
"FormatterFactory",
"::",
"getDefaultFormatter",
"(",
")",
"->",
"getConfig",
"(",
"'boolean_null_upper'",
")",
";",
"$",
"node",
"=",
"new",
"TrueNod... | Create a new TrueNode.
@param boolean $boolean
Parameter is ignored.
@return TrueNode | [
"Create",
"a",
"new",
"TrueNode",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Types/TrueNode.php#L22-L27 | train |
grom358/pharborist | src/Types/NullNode.php | NullNode.create | public static function create($name = 'null') {
$is_upper = FormatterFactory::getDefaultFormatter()->getConfig('boolean_null_upper');
$node = new NullNode();
$node->addChild(NameNode::create($is_upper ? 'NULL' : 'null'), 'constantName');
return $node;
} | php | public static function create($name = 'null') {
$is_upper = FormatterFactory::getDefaultFormatter()->getConfig('boolean_null_upper');
$node = new NullNode();
$node->addChild(NameNode::create($is_upper ? 'NULL' : 'null'), 'constantName');
return $node;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"name",
"=",
"'null'",
")",
"{",
"$",
"is_upper",
"=",
"FormatterFactory",
"::",
"getDefaultFormatter",
"(",
")",
"->",
"getConfig",
"(",
"'boolean_null_upper'",
")",
";",
"$",
"node",
"=",
"new",
"NullNode... | Create a new NullNode.
@param string $name
Parameter is ignored.
@return NullNode | [
"Create",
"a",
"new",
"NullNode",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Types/NullNode.php#L20-L25 | train |
thelia/core | lib/Thelia/Action/Delivery.php | Delivery.getPostage | public function getPostage(DeliveryPostageEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$module = $event->getModule();
// dispatch event to target specific module
$dispatcher->dispatch(
TheliaEvents::getModuleEvent(
TheliaEvents::MODULE_DELIVERY_GET_POSTAGE,
$module->getCode()
),
$event
);
if ($event->isPropagationStopped()) {
return;
}
// call legacy module method
$event->setValidModule($module->isValidDelivery($event->getCountry()));
if ($event->isValidModule()) {
$event->setPostage($module->getPostage($event->getCountry()));
}
} | php | public function getPostage(DeliveryPostageEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$module = $event->getModule();
// dispatch event to target specific module
$dispatcher->dispatch(
TheliaEvents::getModuleEvent(
TheliaEvents::MODULE_DELIVERY_GET_POSTAGE,
$module->getCode()
),
$event
);
if ($event->isPropagationStopped()) {
return;
}
// call legacy module method
$event->setValidModule($module->isValidDelivery($event->getCountry()));
if ($event->isValidModule()) {
$event->setPostage($module->getPostage($event->getCountry()));
}
} | [
"public",
"function",
"getPostage",
"(",
"DeliveryPostageEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"module",
"=",
"$",
"event",
"->",
"getModule",
"(",
")",
";",
"// dispatch event to target spe... | Get postage from module using the classical module functions
@param DeliveryPostageEvent $event | [
"Get",
"postage",
"from",
"module",
"using",
"the",
"classical",
"module",
"functions"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Delivery.php#L33-L55 | train |
nattreid/cms | src/Control/AbstractPresenter.php | AbstractPresenter.addBreadcrumbLink | public function addBreadcrumbLink(string $name, string $link = null, array $arguments = []): Link
{
return $this['breadcrumb']->addLink($name, $link, $arguments);
} | php | public function addBreadcrumbLink(string $name, string $link = null, array $arguments = []): Link
{
return $this['breadcrumb']->addLink($name, $link, $arguments);
} | [
"public",
"function",
"addBreadcrumbLink",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"link",
"=",
"null",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
":",
"Link",
"{",
"return",
"$",
"this",
"[",
"'breadcrumb'",
"]",
"->",
"addLink",
"(",... | Prida link do drobeckove navigace
@param string $name
@param string $link
@param array $arguments
@return Link | [
"Prida",
"link",
"do",
"drobeckove",
"navigace"
] | 28eae564c6a8cdaf01d32ff5a1dffba58232f9c1 | https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/AbstractPresenter.php#L130-L133 | train |
nattreid/cms | src/Control/AbstractPresenter.php | AbstractPresenter.viewMobileMenu | public function viewMobileMenu(bool $view = true): void
{
$this->template->shifted = $view;
$this['dockbar']->setShifted($view);
} | php | public function viewMobileMenu(bool $view = true): void
{
$this->template->shifted = $view;
$this['dockbar']->setShifted($view);
} | [
"public",
"function",
"viewMobileMenu",
"(",
"bool",
"$",
"view",
"=",
"true",
")",
":",
"void",
"{",
"$",
"this",
"->",
"template",
"->",
"shifted",
"=",
"$",
"view",
";",
"$",
"this",
"[",
"'dockbar'",
"]",
"->",
"setShifted",
"(",
"$",
"view",
")"... | Nastavi zobrazeni menu v mobilni verzi
@param bool $view | [
"Nastavi",
"zobrazeni",
"menu",
"v",
"mobilni",
"verzi"
] | 28eae564c6a8cdaf01d32ff5a1dffba58232f9c1 | https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/AbstractPresenter.php#L151-L155 | train |
thelia/core | lib/Thelia/Controller/Admin/AreaController.php | AreaController.addCountry | public function addCountry()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
$areaCountryForm = $this->createForm(AdminForm::AREA_COUNTRY);
$error_msg = null;
try {
$form = $this->validateForm($areaCountryForm);
$event = new AreaAddCountryEvent($form->get('area_id')->getData(), $form->get('country_id')->getData());
$this->dispatch(TheliaEvents::AREA_ADD_COUNTRY, $event);
if (! $this->eventContainsObject($event)) {
throw new \LogicException(
$this->getTranslator()->trans("No %obj was updated.", array('%obj', $this->objectName))
);
}
// Log object modification
if (null !== $changedObject = $this->getObjectFromEvent($event)) {
$this->adminLogAppend(
$this->resourceCode,
AccessManager::UPDATE,
sprintf(
"%s %s (ID %s) modified, new country added",
ucfirst($this->objectName),
$this->getObjectLabel($changedObject),
$this->getObjectId($changedObject)
),
$this->getObjectId($changedObject)
);
}
// Redirect to the success URL
return $this->generateSuccessRedirect($areaCountryForm);
} catch (FormValidationException $ex) {
// Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
} catch (\Exception $ex) {
// Any other error
$error_msg = $ex->getMessage();
}
$this->setupFormErrorContext(
$this->getTranslator()->trans("%obj modification", array('%obj' => $this->objectName)),
$error_msg,
$areaCountryForm
);
// At this point, the form has errors, and should be redisplayed.
return $this->renderEditionTemplate();
} | php | public function addCountry()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
$areaCountryForm = $this->createForm(AdminForm::AREA_COUNTRY);
$error_msg = null;
try {
$form = $this->validateForm($areaCountryForm);
$event = new AreaAddCountryEvent($form->get('area_id')->getData(), $form->get('country_id')->getData());
$this->dispatch(TheliaEvents::AREA_ADD_COUNTRY, $event);
if (! $this->eventContainsObject($event)) {
throw new \LogicException(
$this->getTranslator()->trans("No %obj was updated.", array('%obj', $this->objectName))
);
}
// Log object modification
if (null !== $changedObject = $this->getObjectFromEvent($event)) {
$this->adminLogAppend(
$this->resourceCode,
AccessManager::UPDATE,
sprintf(
"%s %s (ID %s) modified, new country added",
ucfirst($this->objectName),
$this->getObjectLabel($changedObject),
$this->getObjectId($changedObject)
),
$this->getObjectId($changedObject)
);
}
// Redirect to the success URL
return $this->generateSuccessRedirect($areaCountryForm);
} catch (FormValidationException $ex) {
// Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
} catch (\Exception $ex) {
// Any other error
$error_msg = $ex->getMessage();
}
$this->setupFormErrorContext(
$this->getTranslator()->trans("%obj modification", array('%obj' => $this->objectName)),
$error_msg,
$areaCountryForm
);
// At this point, the form has errors, and should be redisplayed.
return $this->renderEditionTemplate();
} | [
"public",
"function",
"addCountry",
"(",
")",
"{",
"// Check current user authorization",
"if",
"(",
"null",
"!==",
"$",
"response",
"=",
"$",
"this",
"->",
"checkAuth",
"(",
"$",
"this",
"->",
"resourceCode",
",",
"array",
"(",
")",
",",
"AccessManager",
":... | add a country to a define area | [
"add",
"a",
"country",
"to",
"a",
"define",
"area"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/AreaController.php#L242-L297 | train |
thelia/core | lib/Thelia/Controller/Admin/AreaController.php | AreaController.removeCountries | public function removeCountries()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
$areaDeleteCountriesForm = $this->createForm(AdminForm::AREA_DELETE_COUNTRY);
try {
$form = $this->validateForm($areaDeleteCountriesForm);
$data = $form->getData();
foreach ($data['country_id'] as $countryId) {
$country = explode('-', $countryId);
$this->removeOneCountryFromArea($data['area_id'], $country[0], $country[1]);
}
// Redirect to the success URL
return $this->generateSuccessRedirect($areaDeleteCountriesForm);
} catch (FormValidationException $ex) {
// Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
} catch (\Exception $ex) {
// Any other error
$error_msg = $ex->getMessage();
}
$this->setupFormErrorContext(
$this->getTranslator()->trans("Failed to delete selected countries"),
$error_msg,
$areaDeleteCountriesForm
);
// At this point, the form has errors, and should be redisplayed.
return $this->renderEditionTemplate();
} | php | public function removeCountries()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
$areaDeleteCountriesForm = $this->createForm(AdminForm::AREA_DELETE_COUNTRY);
try {
$form = $this->validateForm($areaDeleteCountriesForm);
$data = $form->getData();
foreach ($data['country_id'] as $countryId) {
$country = explode('-', $countryId);
$this->removeOneCountryFromArea($data['area_id'], $country[0], $country[1]);
}
// Redirect to the success URL
return $this->generateSuccessRedirect($areaDeleteCountriesForm);
} catch (FormValidationException $ex) {
// Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
} catch (\Exception $ex) {
// Any other error
$error_msg = $ex->getMessage();
}
$this->setupFormErrorContext(
$this->getTranslator()->trans("Failed to delete selected countries"),
$error_msg,
$areaDeleteCountriesForm
);
// At this point, the form has errors, and should be redisplayed.
return $this->renderEditionTemplate();
} | [
"public",
"function",
"removeCountries",
"(",
")",
"{",
"// Check current user authorization",
"if",
"(",
"null",
"!==",
"$",
"response",
"=",
"$",
"this",
"->",
"checkAuth",
"(",
"$",
"this",
"->",
"resourceCode",
",",
"array",
"(",
")",
",",
"AccessManager",... | delete several countries from a shipping zone | [
"delete",
"several",
"countries",
"from",
"a",
"shipping",
"zone"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/AreaController.php#L302-L338 | train |
thelia/core | lib/Thelia/Core/Template/Assets/AsseticAssetManager.php | AsseticAssetManager.getStamp | protected function getStamp($directory)
{
$stamp = '';
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS),
\RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($iterator as $file) {
$stamp .= $file->getMTime();
}
return md5($stamp);
} | php | protected function getStamp($directory)
{
$stamp = '';
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS),
\RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($iterator as $file) {
$stamp .= $file->getMTime();
}
return md5($stamp);
} | [
"protected",
"function",
"getStamp",
"(",
"$",
"directory",
")",
"{",
"$",
"stamp",
"=",
"''",
";",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"$",
"directory",
",",
"\\",
"RecursiveDire... | Create a stamp form the modification time of the content of the given directory and all of its subdirectories
@param string $directory ther directory name
@return string the stamp of this directory | [
"Create",
"a",
"stamp",
"form",
"the",
"modification",
"time",
"of",
"the",
"content",
"of",
"the",
"given",
"directory",
"and",
"all",
"of",
"its",
"subdirectories"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Template/Assets/AsseticAssetManager.php#L47-L61 | train |
thelia/core | lib/Thelia/Core/Template/Assets/AsseticAssetManager.php | AsseticAssetManager.copyAssets | protected function copyAssets(Filesystem $fs, $from_directory, $to_directory)
{
Tlog::getInstance()->addDebug("Copying assets from $from_directory to $to_directory");
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($from_directory, \RecursiveDirectoryIterator::SKIP_DOTS),
\RecursiveIteratorIterator::SELF_FIRST
);
$fs->mkdir($to_directory, 0777);
/** @var \RecursiveDirectoryIterator $iterator */
foreach ($iterator as $item) {
if ($item->isDir()) {
$dest_dir = $to_directory . DS . $iterator->getSubPathName();
if (! is_dir($dest_dir)) {
if ($fs->exists($dest_dir)) {
$fs->remove($dest_dir);
}
$fs->mkdir($dest_dir, 0777);
}
} elseif (! $this->isSourceFile($item)) {
// We don't copy source files
$dest_file = $to_directory . DS . $iterator->getSubPathName();
if ($fs->exists($dest_file)) {
$fs->remove($dest_file);
}
$fs->copy($item, $dest_file);
}
}
} | php | protected function copyAssets(Filesystem $fs, $from_directory, $to_directory)
{
Tlog::getInstance()->addDebug("Copying assets from $from_directory to $to_directory");
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($from_directory, \RecursiveDirectoryIterator::SKIP_DOTS),
\RecursiveIteratorIterator::SELF_FIRST
);
$fs->mkdir($to_directory, 0777);
/** @var \RecursiveDirectoryIterator $iterator */
foreach ($iterator as $item) {
if ($item->isDir()) {
$dest_dir = $to_directory . DS . $iterator->getSubPathName();
if (! is_dir($dest_dir)) {
if ($fs->exists($dest_dir)) {
$fs->remove($dest_dir);
}
$fs->mkdir($dest_dir, 0777);
}
} elseif (! $this->isSourceFile($item)) {
// We don't copy source files
$dest_file = $to_directory . DS . $iterator->getSubPathName();
if ($fs->exists($dest_file)) {
$fs->remove($dest_file);
}
$fs->copy($item, $dest_file);
}
}
} | [
"protected",
"function",
"copyAssets",
"(",
"Filesystem",
"$",
"fs",
",",
"$",
"from_directory",
",",
"$",
"to_directory",
")",
"{",
"Tlog",
"::",
"getInstance",
"(",
")",
"->",
"addDebug",
"(",
"\"Copying assets from $from_directory to $to_directory\"",
")",
";",
... | Recursively copy assets from the source directory to the destination
directory in the web space, omitting source files.
@param Filesystem $fs
@param string $from_directory the source
@param string $to_directory the destination
@throws \RuntimeException if a problem occurs. | [
"Recursively",
"copy",
"assets",
"from",
"the",
"source",
"directory",
"to",
"the",
"destination",
"directory",
"in",
"the",
"web",
"space",
"omitting",
"source",
"files",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Template/Assets/AsseticAssetManager.php#L84-L119 | train |
thelia/core | lib/Thelia/Core/Template/Assets/AsseticAssetManager.php | AsseticAssetManager.prepareAssets | public function prepareAssets($sourceAssetsDirectory, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey)
{
// Compute the absolute path of the output directory
$to_directory = $this->getDestinationDirectory($webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey);
// Get a path to the stamp file
$stamp_file_path = $to_directory . DS . '.source-stamp';
// Get the last stamp of source assets directory
$prev_stamp = @file_get_contents($stamp_file_path);
// Get the current stamp of the source directory
$curr_stamp = $this->getStamp($sourceAssetsDirectory);
if ($prev_stamp !== $curr_stamp) {
$fs = new Filesystem();
$tmp_dir = "$to_directory.tmp";
$fs->remove($tmp_dir);
// Copy the whole source dir in a temp directory
$this->copyAssets($fs, $sourceAssetsDirectory, $tmp_dir);
// Remove existing directory
if ($fs->exists($to_directory)) {
$fs->remove($to_directory);
}
// Put in place the new directory
$fs->rename($tmp_dir, $to_directory);
if (false === @file_put_contents($stamp_file_path, $curr_stamp)) {
throw new \RuntimeException(
"Failed to create asset stamp file $stamp_file_path. Please check that your web server has the proper access rights to do that."
);
}
}
} | php | public function prepareAssets($sourceAssetsDirectory, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey)
{
// Compute the absolute path of the output directory
$to_directory = $this->getDestinationDirectory($webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey);
// Get a path to the stamp file
$stamp_file_path = $to_directory . DS . '.source-stamp';
// Get the last stamp of source assets directory
$prev_stamp = @file_get_contents($stamp_file_path);
// Get the current stamp of the source directory
$curr_stamp = $this->getStamp($sourceAssetsDirectory);
if ($prev_stamp !== $curr_stamp) {
$fs = new Filesystem();
$tmp_dir = "$to_directory.tmp";
$fs->remove($tmp_dir);
// Copy the whole source dir in a temp directory
$this->copyAssets($fs, $sourceAssetsDirectory, $tmp_dir);
// Remove existing directory
if ($fs->exists($to_directory)) {
$fs->remove($to_directory);
}
// Put in place the new directory
$fs->rename($tmp_dir, $to_directory);
if (false === @file_put_contents($stamp_file_path, $curr_stamp)) {
throw new \RuntimeException(
"Failed to create asset stamp file $stamp_file_path. Please check that your web server has the proper access rights to do that."
);
}
}
} | [
"public",
"function",
"prepareAssets",
"(",
"$",
"sourceAssetsDirectory",
",",
"$",
"webAssetsDirectoryBase",
",",
"$",
"webAssetsTemplate",
",",
"$",
"webAssetsKey",
")",
"{",
"// Compute the absolute path of the output directory",
"$",
"to_directory",
"=",
"$",
"this",
... | Prepare an asset directory by checking that no changes occured in
the source directory. If any change is detected, the whole asset directory
is copied in the web space.
@param string $sourceAssetsDirectory the full path to the source assets directory
@param string $webAssetsDirectoryBase the base directory of the web based asset directory
@param $webAssetsTemplate
@param string $webAssetsKey the assets key : module name or 0 for base template
@throws \RuntimeException if something goes wrong. | [
"Prepare",
"an",
"asset",
"directory",
"by",
"checking",
"that",
"no",
"changes",
"occured",
"in",
"the",
"source",
"directory",
".",
"If",
"any",
"change",
"is",
"detected",
"the",
"whole",
"asset",
"directory",
"is",
"copied",
"in",
"the",
"web",
"space",
... | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Template/Assets/AsseticAssetManager.php#L150-L188 | train |
thelia/core | lib/Thelia/Core/Template/Assets/AsseticAssetManager.php | AsseticAssetManager.decodeAsseticFilters | protected function decodeAsseticFilters(FilterManager $filterManager, $filters)
{
if (! empty($filters)) {
$filter_list = \is_array($filters) ? $filters : explode(',', $filters);
foreach ($filter_list as $filter_name) {
$filter_name = trim($filter_name);
foreach ($this->assetFilters as $filterIdentifier => $filterInstance) {
if ($filterIdentifier == $filter_name) {
$filterManager->set($filterIdentifier, $filterInstance);
// No, goto is not evil.
goto filterFound;
}
}
throw new \InvalidArgumentException("Unsupported Assetic filter: '$filter_name'");
break;
filterFound:
}
} else {
$filter_list = array();
}
return $filter_list;
} | php | protected function decodeAsseticFilters(FilterManager $filterManager, $filters)
{
if (! empty($filters)) {
$filter_list = \is_array($filters) ? $filters : explode(',', $filters);
foreach ($filter_list as $filter_name) {
$filter_name = trim($filter_name);
foreach ($this->assetFilters as $filterIdentifier => $filterInstance) {
if ($filterIdentifier == $filter_name) {
$filterManager->set($filterIdentifier, $filterInstance);
// No, goto is not evil.
goto filterFound;
}
}
throw new \InvalidArgumentException("Unsupported Assetic filter: '$filter_name'");
break;
filterFound:
}
} else {
$filter_list = array();
}
return $filter_list;
} | [
"protected",
"function",
"decodeAsseticFilters",
"(",
"FilterManager",
"$",
"filterManager",
",",
"$",
"filters",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"filters",
")",
")",
"{",
"$",
"filter_list",
"=",
"\\",
"is_array",
"(",
"$",
"filters",
")",
... | Decode the filters names, and initialize the Assetic FilterManager
@param FilterManager $filterManager the Assetic filter manager
@param string|array $filters a comma separated list of filter names
@throws \InvalidArgumentException if a wrong filter is passed
@return array an array of filter names | [
"Decode",
"the",
"filters",
"names",
"and",
"initialize",
"the",
"Assetic",
"FilterManager"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Template/Assets/AsseticAssetManager.php#L198-L225 | train |
thelia/core | lib/Thelia/Controller/Admin/SaleController.php | SaleController.toggleActivity | public function toggleActivity()
{
if (null !== $response = $this->checkAuth(AdminResources::SALES, [], AccessManager::UPDATE)) {
return $response;
}
try {
$this->dispatch(
TheliaEvents::SALE_TOGGLE_ACTIVITY,
new SaleToggleActivityEvent(
$this->getExistingObject()
)
);
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
return $this->nullResponse();
} | php | public function toggleActivity()
{
if (null !== $response = $this->checkAuth(AdminResources::SALES, [], AccessManager::UPDATE)) {
return $response;
}
try {
$this->dispatch(
TheliaEvents::SALE_TOGGLE_ACTIVITY,
new SaleToggleActivityEvent(
$this->getExistingObject()
)
);
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
return $this->nullResponse();
} | [
"public",
"function",
"toggleActivity",
"(",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"response",
"=",
"$",
"this",
"->",
"checkAuth",
"(",
"AdminResources",
"::",
"SALES",
",",
"[",
"]",
",",
"AccessManager",
"::",
"UPDATE",
")",
")",
"{",
"return",
"... | Toggle activity status of the sale.
@return Response | [
"Toggle",
"activity",
"status",
"of",
"the",
"sale",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/SaleController.php#L307-L326 | train |
joomla-framework/renderer | src/BladeRenderer.php | BladeRenderer.render | public function render(string $template, array $data = []): string
{
$data = array_merge($this->data, $data);
return $this->getRenderer()->make($template, $data)->render();
} | php | public function render(string $template, array $data = []): string
{
$data = array_merge($this->data, $data);
return $this->getRenderer()->make($template, $data)->render();
} | [
"public",
"function",
"render",
"(",
"string",
"$",
"template",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"data",
")",
";",
"return",
"$",
"this",
... | Render and return compiled data.
@param string $template The template file name
@param array $data The data to pass to the template
@return string Compiled data
@since __DEPLOY_VERSION__ | [
"Render",
"and",
"return",
"compiled",
"data",
"."
] | 8380fa45d4968e068e67b9a210996b030fec6e0f | https://github.com/joomla-framework/renderer/blob/8380fa45d4968e068e67b9a210996b030fec6e0f/src/BladeRenderer.php#L119-L124 | train |
thelia/core | lib/Thelia/Coupon/Type/FreeProduct.php | FreeProduct.getRelatedCartItem | protected function getRelatedCartItem($product)
{
$cartItemIdList = $this->facade->getRequest()->getSession()->get(
$this->getSessionVarName(),
array()
);
if (isset($cartItemIdList[$product->getId()])) {
$cartItemId = $cartItemIdList[$product->getId()];
if ($cartItemId == self::ADD_TO_CART_IN_PROCESS) {
return self::ADD_TO_CART_IN_PROCESS;
} elseif (null !== $cartItem = CartItemQuery::create()->findPk($cartItemId)) {
return $cartItem;
}
} else {
// Maybe the product we're offering is already in the cart ? Search it.
$cartItems = $this->facade->getCart()->getCartItems();
/** @var CartItem $cartItem */
foreach ($cartItems as $cartItem) {
if ($cartItem->getProduct()->getId() == $this->offeredProductId) {
// We found the product. Store its cart item as the free product container.
$this->setRelatedCartItem($product, $cartItem->getId());
return $cartItem;
}
}
}
return false;
} | php | protected function getRelatedCartItem($product)
{
$cartItemIdList = $this->facade->getRequest()->getSession()->get(
$this->getSessionVarName(),
array()
);
if (isset($cartItemIdList[$product->getId()])) {
$cartItemId = $cartItemIdList[$product->getId()];
if ($cartItemId == self::ADD_TO_CART_IN_PROCESS) {
return self::ADD_TO_CART_IN_PROCESS;
} elseif (null !== $cartItem = CartItemQuery::create()->findPk($cartItemId)) {
return $cartItem;
}
} else {
// Maybe the product we're offering is already in the cart ? Search it.
$cartItems = $this->facade->getCart()->getCartItems();
/** @var CartItem $cartItem */
foreach ($cartItems as $cartItem) {
if ($cartItem->getProduct()->getId() == $this->offeredProductId) {
// We found the product. Store its cart item as the free product container.
$this->setRelatedCartItem($product, $cartItem->getId());
return $cartItem;
}
}
}
return false;
} | [
"protected",
"function",
"getRelatedCartItem",
"(",
"$",
"product",
")",
"{",
"$",
"cartItemIdList",
"=",
"$",
"this",
"->",
"facade",
"->",
"getRequest",
"(",
")",
"->",
"getSession",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"getSessionVarName",
"("... | Return the cart item id which contains the free product related to a given product
@param Product $product the product in the cart which triggered the discount
@return bool|int|CartItem the cart item which contains the free product, or false if the product is no longer in the cart, or ADD_TO_CART_IN_PROCESS if the adding process is not finished | [
"Return",
"the",
"cart",
"item",
"id",
"which",
"contains",
"the",
"free",
"product",
"related",
"to",
"a",
"given",
"product"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Coupon/Type/FreeProduct.php#L78-L109 | train |
thelia/core | lib/Thelia/Coupon/Type/FreeProduct.php | FreeProduct.setRelatedCartItem | protected function setRelatedCartItem($product, $cartItemId)
{
$cartItemIdList = $this->facade->getRequest()->getSession()->get(
$this->getSessionVarName(),
array()
);
if (! \is_array($cartItemIdList)) {
$cartItemIdList = array();
}
$cartItemIdList[$product->getId()] = $cartItemId;
$this->facade->getRequest()->getSession()->set(
$this->getSessionVarName(),
$cartItemIdList
);
} | php | protected function setRelatedCartItem($product, $cartItemId)
{
$cartItemIdList = $this->facade->getRequest()->getSession()->get(
$this->getSessionVarName(),
array()
);
if (! \is_array($cartItemIdList)) {
$cartItemIdList = array();
}
$cartItemIdList[$product->getId()] = $cartItemId;
$this->facade->getRequest()->getSession()->set(
$this->getSessionVarName(),
$cartItemIdList
);
} | [
"protected",
"function",
"setRelatedCartItem",
"(",
"$",
"product",
",",
"$",
"cartItemId",
")",
"{",
"$",
"cartItemIdList",
"=",
"$",
"this",
"->",
"facade",
"->",
"getRequest",
"(",
")",
"->",
"getSession",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->"... | Set the cart item id which contains the free product related to a given product
@param Product $product the product in the cart which triggered the discount
@param bool|int $cartItemId the cart item ID which contains the free product, or just true if the free product is not yet added. | [
"Set",
"the",
"cart",
"item",
"id",
"which",
"contains",
"the",
"free",
"product",
"related",
"to",
"a",
"given",
"product"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Coupon/Type/FreeProduct.php#L117-L134 | train |
grom358/pharborist | src/LineCommentBlockNode.php | LineCommentBlockNode.create | public static function create($comment) {
$block_comment = new LineCommentBlockNode();
$comment = trim($comment);
$lines = array_map('rtrim', explode("\n", $comment));
foreach ($lines as $line) {
$comment_node = new CommentNode(T_COMMENT, '// ' . $line . "\n");
$block_comment->addChild($comment_node);
}
return $block_comment;
} | php | public static function create($comment) {
$block_comment = new LineCommentBlockNode();
$comment = trim($comment);
$lines = array_map('rtrim', explode("\n", $comment));
foreach ($lines as $line) {
$comment_node = new CommentNode(T_COMMENT, '// ' . $line . "\n");
$block_comment->addChild($comment_node);
}
return $block_comment;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"comment",
")",
"{",
"$",
"block_comment",
"=",
"new",
"LineCommentBlockNode",
"(",
")",
";",
"$",
"comment",
"=",
"trim",
"(",
"$",
"comment",
")",
";",
"$",
"lines",
"=",
"array_map",
"(",
"'rtrim'",
... | Create line comment block.
@param string $comment
Comment without leading prefix.
@return LineCommentBlockNode | [
"Create",
"line",
"comment",
"block",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/LineCommentBlockNode.php#L23-L32 | train |
grom358/pharborist | src/LineCommentBlockNode.php | LineCommentBlockNode.addIndent | public function addIndent($whitespace) {
$has_indent = $this->children(function (Node $node) {
return !($node instanceof CommentNode);
})->count() > 0;
if ($has_indent) {
$this->children(Filter::isInstanceOf('\Pharborist\WhitespaceNode'))->each(function (WhitespaceNode $ws_node) use ($whitespace) {
$ws_node->setText($ws_node->getText() . $whitespace);
});
}
else {
$this->children()->before(Token::whitespace($whitespace));
}
return $this;
} | php | public function addIndent($whitespace) {
$has_indent = $this->children(function (Node $node) {
return !($node instanceof CommentNode);
})->count() > 0;
if ($has_indent) {
$this->children(Filter::isInstanceOf('\Pharborist\WhitespaceNode'))->each(function (WhitespaceNode $ws_node) use ($whitespace) {
$ws_node->setText($ws_node->getText() . $whitespace);
});
}
else {
$this->children()->before(Token::whitespace($whitespace));
}
return $this;
} | [
"public",
"function",
"addIndent",
"(",
"$",
"whitespace",
")",
"{",
"$",
"has_indent",
"=",
"$",
"this",
"->",
"children",
"(",
"function",
"(",
"Node",
"$",
"node",
")",
"{",
"return",
"!",
"(",
"$",
"node",
"instanceof",
"CommentNode",
")",
";",
"}"... | Add indent to comment.
@param string $whitespace
Additional whitespace to add.
@return $this | [
"Add",
"indent",
"to",
"comment",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/LineCommentBlockNode.php#L90-L103 | train |
Superbalist/php-event-pubsub | src/Events/SimpleEvent.php | SimpleEvent.setAttribute | public function setAttribute($name, $value = null)
{
if (is_array($name)) {
foreach ($name as $k => $v) {
$this->attributes[$k] = $v;
}
} else {
$this->attributes[$name] = $value;
}
} | php | public function setAttribute($name, $value = null)
{
if (is_array($name)) {
foreach ($name as $k => $v) {
$this->attributes[$k] = $v;
}
} else {
$this->attributes[$name] = $value;
}
} | [
"public",
"function",
"setAttribute",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"foreach",
"(",
"$",
"name",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
... | Set an event attribute.
@param string|array $name
@param mixed $value | [
"Set",
"an",
"event",
"attribute",
"."
] | d84b8216137126d314bfaed9ab5efa1a3985e433 | https://github.com/Superbalist/php-event-pubsub/blob/d84b8216137126d314bfaed9ab5efa1a3985e433/src/Events/SimpleEvent.php#L67-L76 | train |
thelia/core | lib/Thelia/Tools/NumberFormat.php | NumberFormat.formatStandardNumber | public function formatStandardNumber($number, $decimals = null)
{
$lang = $this->request->getSession()->getLang();
if ($decimals === null) {
$decimals = $lang->getDecimals();
}
return number_format($number, $decimals, '.', '');
} | php | public function formatStandardNumber($number, $decimals = null)
{
$lang = $this->request->getSession()->getLang();
if ($decimals === null) {
$decimals = $lang->getDecimals();
}
return number_format($number, $decimals, '.', '');
} | [
"public",
"function",
"formatStandardNumber",
"(",
"$",
"number",
",",
"$",
"decimals",
"=",
"null",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"getLang",
"(",
")",
";",
"if",
"(",
"$",
"decimals",
"... | Get a standard number, with '.' as decimal point and no thousands separator
so that this number can be used to perform calculations.
@param float $number the number
@param string $decimals number of decimal figures
@return string | [
"Get",
"a",
"standard",
"number",
"with",
".",
"as",
"decimal",
"point",
"and",
"no",
"thousands",
"separator",
"so",
"that",
"this",
"number",
"can",
"be",
"used",
"to",
"perform",
"calculations",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Tools/NumberFormat.php#L39-L48 | train |
BoldGrid/library | src/Library/Util/Plugin.php | Plugin.getFiltered | public static function getFiltered( $pattern = '' ) {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
if ( empty( $pattern ) ) {
return $plugins;
}
$filtered = array();
foreach ( $plugins as $slug => $data ) {
if ( preg_match( '#' . $pattern . '#', $slug ) ) {
$filtered[ $slug ] = $data;
}
}
return $filtered;
} | php | public static function getFiltered( $pattern = '' ) {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
if ( empty( $pattern ) ) {
return $plugins;
}
$filtered = array();
foreach ( $plugins as $slug => $data ) {
if ( preg_match( '#' . $pattern . '#', $slug ) ) {
$filtered[ $slug ] = $data;
}
}
return $filtered;
} | [
"public",
"static",
"function",
"getFiltered",
"(",
"$",
"pattern",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'get_plugins'",
")",
")",
"{",
"require_once",
"ABSPATH",
".",
"'wp-admin/includes/plugin.php'",
";",
"}",
"$",
"plugins",
"=",
... | Get plugin data filtered by plugin slug pattern.
@since 2.2.1
@param string $pattern A regex pattern used to filter the plugin data array.
@return array | [
"Get",
"plugin",
"data",
"filtered",
"by",
"plugin",
"slug",
"pattern",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Util/Plugin.php#L30-L50 | train |
BoldGrid/library | src/Library/Util/Plugin.php | Plugin.isBoldgridPlugin | public static function isBoldgridPlugin( $plugin ) {
if( empty( $plugin ) ) {
return false;
}
$pluginChecker = new \Boldgrid\Library\Library\Plugin\Checker();
$plugins = \Boldgrid\Library\Library\Util\Plugin::getFiltered( $pluginChecker->getPluginPattern() );
return array_key_exists( $plugin, $plugins );
} | php | public static function isBoldgridPlugin( $plugin ) {
if( empty( $plugin ) ) {
return false;
}
$pluginChecker = new \Boldgrid\Library\Library\Plugin\Checker();
$plugins = \Boldgrid\Library\Library\Util\Plugin::getFiltered( $pluginChecker->getPluginPattern() );
return array_key_exists( $plugin, $plugins );
} | [
"public",
"static",
"function",
"isBoldgridPlugin",
"(",
"$",
"plugin",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"plugin",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"pluginChecker",
"=",
"new",
"\\",
"Boldgrid",
"\\",
"Library",
"\\",
"Library",
... | Determine if a plugin is a BoldGrid plugin.
@since 2.2.1
@param string $plugin Such as post-and-page-builder/post-and-page-builder.php
@return bool | [
"Determine",
"if",
"a",
"plugin",
"is",
"a",
"BoldGrid",
"plugin",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Util/Plugin.php#L60-L70 | train |
melisplatform/melis-cms | src/Controller/LanguageController.php | LanguageController.getTranslationsList | public function getTranslationsList()
{
$data = "";
$melisCmsAuth = $this->getServiceLocator()->get('MelisCoreAuth');
$melisCmsRights = $this->getServiceLocator()->get('MelisCoreRights');
return $data;
} | php | public function getTranslationsList()
{
$data = "";
$melisCmsAuth = $this->getServiceLocator()->get('MelisCoreAuth');
$melisCmsRights = $this->getServiceLocator()->get('MelisCoreRights');
return $data;
} | [
"public",
"function",
"getTranslationsList",
"(",
")",
"{",
"$",
"data",
"=",
"\"\"",
";",
"$",
"melisCmsAuth",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreAuth'",
")",
";",
"$",
"melisCmsRights",
"=",
"$",
"this",
... | get translations
return array | [
"get",
"translations",
"return",
"array"
] | ed470338f4c7653fd93e530013ab934eb7a52b6f | https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/LanguageController.php#L211-L219 | train |
melisplatform/melis-cms | src/Controller/LanguageController.php | LanguageController.getDataTableTranslationsAction | public function getDataTableTranslationsAction()
{
// Get the current language
$container = new Container('meliscms');
$locale = $container['melis-lang-locale'];
$translator = $this->getServiceLocator()->get('translator');
$transData = array(
'sEmptyTable' => $translator->translate('tr_meliscms_dt_sEmptyTable'),
'sInfo' => $translator->translate('tr_meliscms_dt_sInfo'),
'sInfoEmpty' => $translator->translate('tr_meliscms_dt_sInfoEmpty'),
'sInfoFiltered' => $translator->translate('tr_meliscms_dt_sInfoFiltered'),
'sInfoPostFix' => $translator->translate('tr_meliscms_dt_sInfoPostFix'),
'sInfoThousands' => $translator->translate('tr_meliscms_dt_sInfoThousands'),
'sLengthMenu' => $translator->translate('tr_meliscms_dt_sLengthMenu'),
'sLoadingRecords' => $translator->translate('tr_meliscms_dt_sLoadingRecords'),
'sProcessing' => $translator->translate('tr_meliscms_dt_sProcessing'),
'sSearch' => $translator->translate('tr_meliscms_dt_sSearch'),
'sZeroRecords' => $translator->translate('tr_meliscms_dt_sZeroRecords'),
'oPaginate' => array(
'sFirst' => $translator->translate('tr_meliscms_dt_sFirst'),
'sLast' => $translator->translate('tr_meliscms_dt_sLast'),
'sNext' => $translator->translate('tr_meliscms_dt_sNext'),
'sPrevious' => $translator->translate('tr_meliscms_dt_sPrevious'),
),
'oAria' => array(
'sSortAscending' => $translator->translate('tr_meliscms_dt_sSortAscending'),
'sSortDescending' => $translator->translate('tr_meliscms_dt_sSortDescending'),
),
);
return new JsonModel($transData);
} | php | public function getDataTableTranslationsAction()
{
// Get the current language
$container = new Container('meliscms');
$locale = $container['melis-lang-locale'];
$translator = $this->getServiceLocator()->get('translator');
$transData = array(
'sEmptyTable' => $translator->translate('tr_meliscms_dt_sEmptyTable'),
'sInfo' => $translator->translate('tr_meliscms_dt_sInfo'),
'sInfoEmpty' => $translator->translate('tr_meliscms_dt_sInfoEmpty'),
'sInfoFiltered' => $translator->translate('tr_meliscms_dt_sInfoFiltered'),
'sInfoPostFix' => $translator->translate('tr_meliscms_dt_sInfoPostFix'),
'sInfoThousands' => $translator->translate('tr_meliscms_dt_sInfoThousands'),
'sLengthMenu' => $translator->translate('tr_meliscms_dt_sLengthMenu'),
'sLoadingRecords' => $translator->translate('tr_meliscms_dt_sLoadingRecords'),
'sProcessing' => $translator->translate('tr_meliscms_dt_sProcessing'),
'sSearch' => $translator->translate('tr_meliscms_dt_sSearch'),
'sZeroRecords' => $translator->translate('tr_meliscms_dt_sZeroRecords'),
'oPaginate' => array(
'sFirst' => $translator->translate('tr_meliscms_dt_sFirst'),
'sLast' => $translator->translate('tr_meliscms_dt_sLast'),
'sNext' => $translator->translate('tr_meliscms_dt_sNext'),
'sPrevious' => $translator->translate('tr_meliscms_dt_sPrevious'),
),
'oAria' => array(
'sSortAscending' => $translator->translate('tr_meliscms_dt_sSortAscending'),
'sSortDescending' => $translator->translate('tr_meliscms_dt_sSortDescending'),
),
);
return new JsonModel($transData);
} | [
"public",
"function",
"getDataTableTranslationsAction",
"(",
")",
"{",
"// Get the current language",
"$",
"container",
"=",
"new",
"Container",
"(",
"'meliscms'",
")",
";",
"$",
"locale",
"=",
"$",
"container",
"[",
"'melis-lang-locale'",
"]",
";",
"$",
"translat... | Creates translations for table actions in tools
@return \Zend\View\Model\JsonModel | [
"Creates",
"translations",
"for",
"table",
"actions",
"in",
"tools"
] | ed470338f4c7653fd93e530013ab934eb7a52b6f | https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/LanguageController.php#L302-L335 | train |
thelia/core | lib/Thelia/Action/TaxRule.php | TaxRule.getArrayFromJson22Compat | protected function getArrayFromJson22Compat($obj)
{
$obj = $this->getArrayFromJson($obj);
if (isset($obj[0]) && ! \is_array($obj[0])) {
$objEx = [];
foreach ($obj as $item) {
$objEx[] = [$item, 0];
}
return $objEx;
}
return $obj;
} | php | protected function getArrayFromJson22Compat($obj)
{
$obj = $this->getArrayFromJson($obj);
if (isset($obj[0]) && ! \is_array($obj[0])) {
$objEx = [];
foreach ($obj as $item) {
$objEx[] = [$item, 0];
}
return $objEx;
}
return $obj;
} | [
"protected",
"function",
"getArrayFromJson22Compat",
"(",
"$",
"obj",
")",
"{",
"$",
"obj",
"=",
"$",
"this",
"->",
"getArrayFromJson",
"(",
"$",
"obj",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"obj",
"[",
"0",
"]",
")",
"&&",
"!",
"\\",
"is_array",
... | This method ensures compatibility with the 2.2.x country arrays passed throught the TaxRuleEvent
In 2.2.x, the TaxRuleEvent::getXXXCountryList() methods returned an array of country IDs. [ country ID, country ID ...].
From 2.3.0-alpha1, these functions are expected to return an array of arrays, each one containing a country ID and
a state ID. [ [ country ID, state ID], [ country ID, state ID], ...].
This method checks the $obj parameter, and create a 2.3.0-alpha1 compatible return value if $obj is expressed using
the 2.2.x form.
@param array $obj
@return array | [
"This",
"method",
"ensures",
"compatibility",
"with",
"the",
"2",
".",
"2",
".",
"x",
"country",
"arrays",
"passed",
"throught",
"the",
"TaxRuleEvent"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/TaxRule.php#L146-L160 | train |
timitek/getrets-laravel | app/Http/Controllers/ExampleController.php | ExampleController.handleAction | private function handleAction(Request $request, &$data) {
// Keyword Search
if ($this->isAction($request, "searchByKeyword")) {
$preparedKeywords = htmlspecialchars($data["keywords"]);
$data["listings"] = $this->listingController($data)
->setSortBy($data["sortBy"])->setReverseSort($data["reverseSort"])
->searchByKeyword($preparedKeywords);
}
// Advanced Search
else if ($this->isAction($request, "search")) {
$data["listings"] = $this->listingController($data)
->setSortBy($data["sortBy"])->setReverseSort($data["reverseSort"])
->search($data["keywords"], $data["extra"], $data["maxPrice"], $data["minPrice"], $data["beds"], $data["baths"], $data["includeResidential"], $data["includeLand"], $data["includeCommercial"]);
}
// Return Listings by DMQL
else if ($this->isAction($request, "getListingsByDMQL")) {
$results = GetRETS::getRETSListing()
->setSortBy($data["sortBy"])->setReverseSort($data["reverseSort"])
->getListingsByDMQL($data["dmql"], ExampleController::EXAMPLE_SOURCE, "Residential");
if (!empty($results)) {
if ($results->success && !empty($results->data)) {
$data["listings"] = $results->data;
}
}
}
// Return raw DMQL results
else if ($this->isAction($request, "executeDMQL")) {
$data["rawData"] = GetRETS::getRETSListing()->executeDMQL($data["dmql"], ExampleController::EXAMPLE_SOURCE, "Residential");
}
} | php | private function handleAction(Request $request, &$data) {
// Keyword Search
if ($this->isAction($request, "searchByKeyword")) {
$preparedKeywords = htmlspecialchars($data["keywords"]);
$data["listings"] = $this->listingController($data)
->setSortBy($data["sortBy"])->setReverseSort($data["reverseSort"])
->searchByKeyword($preparedKeywords);
}
// Advanced Search
else if ($this->isAction($request, "search")) {
$data["listings"] = $this->listingController($data)
->setSortBy($data["sortBy"])->setReverseSort($data["reverseSort"])
->search($data["keywords"], $data["extra"], $data["maxPrice"], $data["minPrice"], $data["beds"], $data["baths"], $data["includeResidential"], $data["includeLand"], $data["includeCommercial"]);
}
// Return Listings by DMQL
else if ($this->isAction($request, "getListingsByDMQL")) {
$results = GetRETS::getRETSListing()
->setSortBy($data["sortBy"])->setReverseSort($data["reverseSort"])
->getListingsByDMQL($data["dmql"], ExampleController::EXAMPLE_SOURCE, "Residential");
if (!empty($results)) {
if ($results->success && !empty($results->data)) {
$data["listings"] = $results->data;
}
}
}
// Return raw DMQL results
else if ($this->isAction($request, "executeDMQL")) {
$data["rawData"] = GetRETS::getRETSListing()->executeDMQL($data["dmql"], ExampleController::EXAMPLE_SOURCE, "Residential");
}
} | [
"private",
"function",
"handleAction",
"(",
"Request",
"$",
"request",
",",
"&",
"$",
"data",
")",
"{",
"// Keyword Search",
"if",
"(",
"$",
"this",
"->",
"isAction",
"(",
"$",
"request",
",",
"\"searchByKeyword\"",
")",
")",
"{",
"$",
"preparedKeywords",
... | Handles requested action from a form post
@param Request $request
@param type $data | [
"Handles",
"requested",
"action",
"from",
"a",
"form",
"post"
] | 2a9f47971deed1b9127c9ffd24c0a4925057644b | https://github.com/timitek/getrets-laravel/blob/2a9f47971deed1b9127c9ffd24c0a4925057644b/app/Http/Controllers/ExampleController.php#L42-L71 | train |
timitek/getrets-laravel | app/Http/Controllers/ExampleController.php | ExampleController.getPageData | private function getPageData(Request $request) {
$publicDMQL = '(L_UpdateDate=' . date('Y-m-d', (strtotime('-1 day', time()))) . '-' . date('Y-m-d') . ')';
$data = [
"isPublic" => ExampleController::IS_PUBLIC,
"disableCache" => !empty($request->disableCache),
"keywords" => $request->keywords ? : ExampleController::EXAMPLE_ADDRESS,
"extra" => $request->extra,
"maxPrice" => $request->maxPrice,
"minPrice" => $request->minPrice,
"beds" => $request->beds,
"baths" => $request->baths,
"includeResidential" => $request->includeResidential,
"includeLand" => $request->includeLand,
"includeCommercial" => $request->includeCommercial,
"sortBy" => $request->sortBy ? : "rawListPrice",
"reverseSort" => !empty($request->reverseSort),
// Only let the public search the last days worth of modified residential listings (to prevent abusive queries)
"dmql" => (!empty($request->dmql) && !$data["isPublic"]) ? $request->dmql : $publicDMQL,
"listings" => null,
"detail" => null,
"rawData" => null,
"allInput" => $request->all(),
];
if ($request->isMethod('POST')) {
$this->handleAction($request, $data);
}
// Listing Details
if ($request->has("source") && $request->has("type") && $request->has("id")) {
$data["detail"] = $this->listingController($data)->details($request->source, $request->type, $request->id);
}
return $data;
} | php | private function getPageData(Request $request) {
$publicDMQL = '(L_UpdateDate=' . date('Y-m-d', (strtotime('-1 day', time()))) . '-' . date('Y-m-d') . ')';
$data = [
"isPublic" => ExampleController::IS_PUBLIC,
"disableCache" => !empty($request->disableCache),
"keywords" => $request->keywords ? : ExampleController::EXAMPLE_ADDRESS,
"extra" => $request->extra,
"maxPrice" => $request->maxPrice,
"minPrice" => $request->minPrice,
"beds" => $request->beds,
"baths" => $request->baths,
"includeResidential" => $request->includeResidential,
"includeLand" => $request->includeLand,
"includeCommercial" => $request->includeCommercial,
"sortBy" => $request->sortBy ? : "rawListPrice",
"reverseSort" => !empty($request->reverseSort),
// Only let the public search the last days worth of modified residential listings (to prevent abusive queries)
"dmql" => (!empty($request->dmql) && !$data["isPublic"]) ? $request->dmql : $publicDMQL,
"listings" => null,
"detail" => null,
"rawData" => null,
"allInput" => $request->all(),
];
if ($request->isMethod('POST')) {
$this->handleAction($request, $data);
}
// Listing Details
if ($request->has("source") && $request->has("type") && $request->has("id")) {
$data["detail"] = $this->listingController($data)->details($request->source, $request->type, $request->id);
}
return $data;
} | [
"private",
"function",
"getPageData",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"publicDMQL",
"=",
"'(L_UpdateDate='",
".",
"date",
"(",
"'Y-m-d'",
",",
"(",
"strtotime",
"(",
"'-1 day'",
",",
"time",
"(",
")",
")",
")",
")",
".",
"'-'",
".",
"dat... | Returns an array of data to be used in the view
@param Request $request
@return type | [
"Returns",
"an",
"array",
"of",
"data",
"to",
"be",
"used",
"in",
"the",
"view"
] | 2a9f47971deed1b9127c9ffd24c0a4925057644b | https://github.com/timitek/getrets-laravel/blob/2a9f47971deed1b9127c9ffd24c0a4925057644b/app/Http/Controllers/ExampleController.php#L79-L115 | train |
thelia/core | lib/Thelia/Model/Product.php | Product.countSaleElements | public function countSaleElements($con = null)
{
return ProductSaleElementsQuery::create()->filterByProductId($this->id)->count($con);
} | php | public function countSaleElements($con = null)
{
return ProductSaleElementsQuery::create()->filterByProductId($this->id)->count($con);
} | [
"public",
"function",
"countSaleElements",
"(",
"$",
"con",
"=",
"null",
")",
"{",
"return",
"ProductSaleElementsQuery",
"::",
"create",
"(",
")",
"->",
"filterByProductId",
"(",
"$",
"this",
"->",
"id",
")",
"->",
"count",
"(",
"$",
"con",
")",
";",
"}"... | Return PSE count fir this product.
@param ConnectionInterface $con an optional connection object
@return int | [
"Return",
"PSE",
"count",
"fir",
"this",
"product",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Product.php#L76-L79 | train |
thelia/core | lib/Thelia/Model/Product.php | Product.setDefaultCategory | public function setDefaultCategory($defaultCategoryId)
{
// Allow uncategorized products (NULL instead of 0, to bypass delete cascade constraint)
if ($defaultCategoryId <= 0) {
$defaultCategoryId = null;
}
/** @var ProductCategory $productCategory */
$productCategory = ProductCategoryQuery::create()
->filterByProductId($this->getId())
->filterByDefaultCategory(true)
->findOne()
;
if ($productCategory !== null && (int) $productCategory->getCategoryId() === (int) $defaultCategoryId) {
return $this;
}
if ($productCategory !== null) {
$productCategory->delete();
}
// checks if the product is already associated with the category and but not default
if (null !== $productCategory = ProductCategoryQuery::create()->filterByProduct($this)->filterByCategoryId($defaultCategoryId)->findOne()) {
$productCategory->setDefaultCategory(true)->save();
} else {
$position = (new ProductCategory())->setCategoryId($defaultCategoryId)->getNextPosition();
(new ProductCategory())
->setProduct($this)
->setCategoryId($defaultCategoryId)
->setDefaultCategory(true)
->setPosition($position)
->save();
$this->setPosition($position);
}
return $this;
} | php | public function setDefaultCategory($defaultCategoryId)
{
// Allow uncategorized products (NULL instead of 0, to bypass delete cascade constraint)
if ($defaultCategoryId <= 0) {
$defaultCategoryId = null;
}
/** @var ProductCategory $productCategory */
$productCategory = ProductCategoryQuery::create()
->filterByProductId($this->getId())
->filterByDefaultCategory(true)
->findOne()
;
if ($productCategory !== null && (int) $productCategory->getCategoryId() === (int) $defaultCategoryId) {
return $this;
}
if ($productCategory !== null) {
$productCategory->delete();
}
// checks if the product is already associated with the category and but not default
if (null !== $productCategory = ProductCategoryQuery::create()->filterByProduct($this)->filterByCategoryId($defaultCategoryId)->findOne()) {
$productCategory->setDefaultCategory(true)->save();
} else {
$position = (new ProductCategory())->setCategoryId($defaultCategoryId)->getNextPosition();
(new ProductCategory())
->setProduct($this)
->setCategoryId($defaultCategoryId)
->setDefaultCategory(true)
->setPosition($position)
->save();
$this->setPosition($position);
}
return $this;
} | [
"public",
"function",
"setDefaultCategory",
"(",
"$",
"defaultCategoryId",
")",
"{",
"// Allow uncategorized products (NULL instead of 0, to bypass delete cascade constraint)",
"if",
"(",
"$",
"defaultCategoryId",
"<=",
"0",
")",
"{",
"$",
"defaultCategoryId",
"=",
"null",
... | Set default category for this product
@param int $defaultCategoryId the new default category id
@return $this | [
"Set",
"default",
"category",
"for",
"this",
"product"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Product.php#L101-L140 | train |
thelia/core | lib/Thelia/Model/Product.php | Product.create | public function create($defaultCategoryId, $basePrice, $priceCurrencyId, $taxRuleId, $baseWeight, $baseQuantity = 0)
{
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
$con->beginTransaction();
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT, new ProductEvent($this));
try {
// Create the product
$this->save($con);
// Add the default category
$this->setDefaultCategory($defaultCategoryId)->save($con);
$this->setTaxRuleId($taxRuleId);
// Create the default product sale element of this product
$this->createProductSaleElement($con, $baseWeight, $basePrice, $basePrice, $priceCurrencyId, true, false, false, $baseQuantity);
// Store all the stuff !
$con->commit();
$this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT, new ProductEvent($this));
} catch (\Exception $ex) {
$con->rollback();
throw $ex;
}
} | php | public function create($defaultCategoryId, $basePrice, $priceCurrencyId, $taxRuleId, $baseWeight, $baseQuantity = 0)
{
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
$con->beginTransaction();
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT, new ProductEvent($this));
try {
// Create the product
$this->save($con);
// Add the default category
$this->setDefaultCategory($defaultCategoryId)->save($con);
$this->setTaxRuleId($taxRuleId);
// Create the default product sale element of this product
$this->createProductSaleElement($con, $baseWeight, $basePrice, $basePrice, $priceCurrencyId, true, false, false, $baseQuantity);
// Store all the stuff !
$con->commit();
$this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT, new ProductEvent($this));
} catch (\Exception $ex) {
$con->rollback();
throw $ex;
}
} | [
"public",
"function",
"create",
"(",
"$",
"defaultCategoryId",
",",
"$",
"basePrice",
",",
"$",
"priceCurrencyId",
",",
"$",
"taxRuleId",
",",
"$",
"baseWeight",
",",
"$",
"baseQuantity",
"=",
"0",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getWriteConnec... | Create a new product, along with the default category ID
@param int $defaultCategoryId the default category ID of this product
@param float $basePrice the product base price
@param int $priceCurrencyId the price currency Id
@param int $taxRuleId the product tax rule ID
@param float $baseWeight base weight in Kg
@param int $baseQuantity the product quantity (default: 0)
@throws \Exception | [
"Create",
"a",
"new",
"product",
"along",
"with",
"the",
"default",
"category",
"ID"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Product.php#L163-L191 | train |
thelia/core | lib/Thelia/Model/Product.php | Product.createProductSaleElement | public function createProductSaleElement(ConnectionInterface $con, $weight, $basePrice, $salePrice, $currencyId, $isDefault, $isPromo = false, $isNew = false, $quantity = 0, $eanCode = '', $ref = false)
{
// Create an empty product sale element
$saleElements = new ProductSaleElements();
$saleElements
->setProduct($this)
->setRef($ref == false ? $this->getRef() : $ref)
->setPromo($isPromo)
->setNewness($isNew)
->setWeight($weight)
->setIsDefault($isDefault)
->setEanCode($eanCode)
->setQuantity($quantity)
->save($con)
;
// Create an empty product price in the provided currency
$productPrice = new ProductPrice();
$productPrice
->setProductSaleElements($saleElements)
->setPromoPrice($salePrice)
->setPrice($basePrice)
->setCurrencyId($currencyId)
->setFromDefaultCurrency(false)
->save($con)
;
return $saleElements;
} | php | public function createProductSaleElement(ConnectionInterface $con, $weight, $basePrice, $salePrice, $currencyId, $isDefault, $isPromo = false, $isNew = false, $quantity = 0, $eanCode = '', $ref = false)
{
// Create an empty product sale element
$saleElements = new ProductSaleElements();
$saleElements
->setProduct($this)
->setRef($ref == false ? $this->getRef() : $ref)
->setPromo($isPromo)
->setNewness($isNew)
->setWeight($weight)
->setIsDefault($isDefault)
->setEanCode($eanCode)
->setQuantity($quantity)
->save($con)
;
// Create an empty product price in the provided currency
$productPrice = new ProductPrice();
$productPrice
->setProductSaleElements($saleElements)
->setPromoPrice($salePrice)
->setPrice($basePrice)
->setCurrencyId($currencyId)
->setFromDefaultCurrency(false)
->save($con)
;
return $saleElements;
} | [
"public",
"function",
"createProductSaleElement",
"(",
"ConnectionInterface",
"$",
"con",
",",
"$",
"weight",
",",
"$",
"basePrice",
",",
"$",
"salePrice",
",",
"$",
"currencyId",
",",
"$",
"isDefault",
",",
"$",
"isPromo",
"=",
"false",
",",
"$",
"isNew",
... | Create a basic product sale element attached to this product.
@param ConnectionInterface $con
@param float $weight
@param float $basePrice
@param float $salePrice
@param int $currencyId
@param int $isDefault
@param bool $isPromo
@param bool $isNew
@param int $quantity
@param string $eanCode
@param bool $ref
@return ProductSaleElements
@throws PropelException
@throws \Exception | [
"Create",
"a",
"basic",
"product",
"sale",
"element",
"attached",
"to",
"this",
"product",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Product.php#L211-L241 | train |
thelia/core | lib/Thelia/Model/Product.php | Product.addCriteriaToPositionQuery | protected function addCriteriaToPositionQuery($query)
{
// Find products in the same category
$products = ProductCategoryQuery::create()
->filterByCategoryId($this->getDefaultCategoryId())
->filterByDefaultCategory(true)
->select('product_id')
->find();
if ($products != null) {
$query->filterById($products, Criteria::IN);
}
} | php | protected function addCriteriaToPositionQuery($query)
{
// Find products in the same category
$products = ProductCategoryQuery::create()
->filterByCategoryId($this->getDefaultCategoryId())
->filterByDefaultCategory(true)
->select('product_id')
->find();
if ($products != null) {
$query->filterById($products, Criteria::IN);
}
} | [
"protected",
"function",
"addCriteriaToPositionQuery",
"(",
"$",
"query",
")",
"{",
"// Find products in the same category",
"$",
"products",
"=",
"ProductCategoryQuery",
"::",
"create",
"(",
")",
"->",
"filterByCategoryId",
"(",
"$",
"this",
"->",
"getDefaultCategoryId... | Calculate next position relative to our default category
@param ProductQuery $query
@deprecated since 2.3, and will be removed in 2.4 | [
"Calculate",
"next",
"position",
"relative",
"to",
"our",
"default",
"category"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Product.php#L249-L261 | train |
melisplatform/melis-cms | src/Service/MelisCmsPageGetterService.php | MelisCmsPageGetterService.getPageContent | public function getPageContent($pageId)
{
// Retrieve cache version if front mode to avoid multiple calls
$melisEngineCacheSystem = $this->getServiceLocator()->get('MelisEngineCacheSystem');
$pageContent = $melisEngineCacheSystem->getCacheByKey($this->cachekey.$pageId, $this->cacheConfig, true);
return $pageContent;
} | php | public function getPageContent($pageId)
{
// Retrieve cache version if front mode to avoid multiple calls
$melisEngineCacheSystem = $this->getServiceLocator()->get('MelisEngineCacheSystem');
$pageContent = $melisEngineCacheSystem->getCacheByKey($this->cachekey.$pageId, $this->cacheConfig, true);
return $pageContent;
} | [
"public",
"function",
"getPageContent",
"(",
"$",
"pageId",
")",
"{",
"// Retrieve cache version if front mode to avoid multiple calls",
"$",
"melisEngineCacheSystem",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisEngineCacheSystem'",
")"... | This method will retieve Page content from cache file
@return Strin||null | [
"This",
"method",
"will",
"retieve",
"Page",
"content",
"from",
"cache",
"file"
] | ed470338f4c7653fd93e530013ab934eb7a52b6f | https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Service/MelisCmsPageGetterService.php#L17-L24 | train |
BoldGrid/library | src/Library/Key/Validate.php | Validate.setHash | public function setHash( $key = null ) {
$key = $key ? $this->sanitizeKey( $key ) : $this->getKey();
return $this->hash = $this->hashKey( $key );
} | php | public function setHash( $key = null ) {
$key = $key ? $this->sanitizeKey( $key ) : $this->getKey();
return $this->hash = $this->hashKey( $key );
} | [
"public",
"function",
"setHash",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"key",
"=",
"$",
"key",
"?",
"$",
"this",
"->",
"sanitizeKey",
"(",
"$",
"key",
")",
":",
"$",
"this",
"->",
"getKey",
"(",
")",
";",
"return",
"$",
"this",
"->",
"ha... | Sets the hash class property.
@since 1.0.0
@param string $key API key to get hash of.
@return object | [
"Sets",
"the",
"hash",
"class",
"property",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Key/Validate.php#L89-L92 | train |
BoldGrid/library | src/Library/Key/Validate.php | Validate.sanitizeKey | public function sanitizeKey( $key ) {
$key = trim( strtolower( preg_replace( '/-/', '', $key ) ) );
$key = implode( '-', str_split( $key, 8 ) );
return sanitize_key( $key );
} | php | public function sanitizeKey( $key ) {
$key = trim( strtolower( preg_replace( '/-/', '', $key ) ) );
$key = implode( '-', str_split( $key, 8 ) );
return sanitize_key( $key );
} | [
"public",
"function",
"sanitizeKey",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"trim",
"(",
"strtolower",
"(",
"preg_replace",
"(",
"'/-/'",
",",
"''",
",",
"$",
"key",
")",
")",
")",
";",
"$",
"key",
"=",
"implode",
"(",
"'-'",
",",
"str_split",... | Sanitizes the key input for loose validation of format.
@since 1.0.0
@param [type] $key [description]
@return string $key Sanitized key. | [
"Sanitizes",
"the",
"key",
"input",
"for",
"loose",
"validation",
"of",
"format",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Key/Validate.php#L103-L107 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.