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
NotifyMeHQ/notifyme
src/Adapters/Gitter/GitterFactory.php
GitterFactory.make
public function make(array $config) { Arr::requires($config, ['token']); $client = new Client(); return new GitterGateway($client, $config); }
php
public function make(array $config) { Arr::requires($config, ['token']); $client = new Client(); return new GitterGateway($client, $config); }
[ "public", "function", "make", "(", "array", "$", "config", ")", "{", "Arr", "::", "requires", "(", "$", "config", ",", "[", "'token'", "]", ")", ";", "$", "client", "=", "new", "Client", "(", ")", ";", "return", "new", "GitterGateway", "(", "$", "c...
Create a new gitter gateway instance. @param string[] $config @return \NotifyMeHQ\Adapters\Gitter\GitterGateway
[ "Create", "a", "new", "gitter", "gateway", "instance", "." ]
2af4bdcfe9df6db7ea79e2dce90b106ccb285b06
https://github.com/NotifyMeHQ/notifyme/blob/2af4bdcfe9df6db7ea79e2dce90b106ccb285b06/src/Adapters/Gitter/GitterFactory.php#L27-L34
train
thelia/core
lib/Thelia/Model/Sale.php
Sale.getPriceOffsets
public function getPriceOffsets() { $currencyOffsets = SaleOffsetCurrencyQuery::create()->filterBySaleId($this->getId())->find(); $offsetList = []; /** @var SaleOffsetCurrency $currencyOffset */ foreach ($currencyOffsets as $currencyOffset) { $offsetList[$currencyOffset->getCurrencyId()] = $currencyOffset->getPriceOffsetValue(); } return $offsetList; }
php
public function getPriceOffsets() { $currencyOffsets = SaleOffsetCurrencyQuery::create()->filterBySaleId($this->getId())->find(); $offsetList = []; /** @var SaleOffsetCurrency $currencyOffset */ foreach ($currencyOffsets as $currencyOffset) { $offsetList[$currencyOffset->getCurrencyId()] = $currencyOffset->getPriceOffsetValue(); } return $offsetList; }
[ "public", "function", "getPriceOffsets", "(", ")", "{", "$", "currencyOffsets", "=", "SaleOffsetCurrencyQuery", "::", "create", "(", ")", "->", "filterBySaleId", "(", "$", "this", "->", "getId", "(", ")", ")", "->", "find", "(", ")", ";", "$", "offsetList"...
Get the price offsets for each of the currencies. @return array an array of (currency ID => offset value)
[ "Get", "the", "price", "offsets", "for", "each", "of", "the", "currencies", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Sale.php#L42-L54
train
thelia/core
lib/Thelia/Model/Sale.php
Sale.getSaleProductList
public function getSaleProductList() { $saleProducts = SaleProductQuery::create()->filterBySaleId($this->getId())->groupByProductId()->find(); return $saleProducts; }
php
public function getSaleProductList() { $saleProducts = SaleProductQuery::create()->filterBySaleId($this->getId())->groupByProductId()->find(); return $saleProducts; }
[ "public", "function", "getSaleProductList", "(", ")", "{", "$", "saleProducts", "=", "SaleProductQuery", "::", "create", "(", ")", "->", "filterBySaleId", "(", "$", "this", "->", "getId", "(", ")", ")", "->", "groupByProductId", "(", ")", "->", "find", "("...
Return the products included in this sale. @return array an array of Products
[ "Return", "the", "products", "included", "in", "this", "sale", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Sale.php#L61-L66
train
thelia/core
lib/Thelia/Model/Sale.php
Sale.getSaleProductsAttributeList
public function getSaleProductsAttributeList() { $saleProducts = SaleProductQuery::create()->filterBySaleId($this->getId())->orderByProductId()->find(); $selectedAttributes = []; $currentProduct = false; /** @var SaleProduct $saleProduct */ foreach ($saleProducts as $saleProduct) { if ($currentProduct != $saleProduct->getProductId()) { $currentProduct = $saleProduct->getProductId(); $selectedAttributes[$currentProduct] = []; } $selectedAttributes[$currentProduct][] = $saleProduct->getAttributeAvId(); } return $selectedAttributes; }
php
public function getSaleProductsAttributeList() { $saleProducts = SaleProductQuery::create()->filterBySaleId($this->getId())->orderByProductId()->find(); $selectedAttributes = []; $currentProduct = false; /** @var SaleProduct $saleProduct */ foreach ($saleProducts as $saleProduct) { if ($currentProduct != $saleProduct->getProductId()) { $currentProduct = $saleProduct->getProductId(); $selectedAttributes[$currentProduct] = []; } $selectedAttributes[$currentProduct][] = $saleProduct->getAttributeAvId(); } return $selectedAttributes; }
[ "public", "function", "getSaleProductsAttributeList", "(", ")", "{", "$", "saleProducts", "=", "SaleProductQuery", "::", "create", "(", ")", "->", "filterBySaleId", "(", "$", "this", "->", "getId", "(", ")", ")", "->", "orderByProductId", "(", ")", "->", "fi...
Return the selected attributes values for each of the selected products. @return array an array of (product ID => array of attribute availability ID)
[ "Return", "the", "selected", "attributes", "values", "for", "each", "of", "the", "selected", "products", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Sale.php#L73-L93
train
thelia/core
lib/Thelia/Controller/Front/DefaultController.php
DefaultController.noAction
public function noAction(Request $request) { $view = null; if (! $view = $request->query->get('view')) { if ($request->request->has('view')) { $view = $request->request->get('view'); } } if (null !== $view) { $request->attributes->set('_view', $view); } if (null === $view && null === $request->attributes->get("_view")) { $request->attributes->set("_view", "index"); } if (ConfigQuery::isRewritingEnable()) { if ($request->attributes->get('_rewritten', false) === false) { /* Does the query GET parameters match a rewritten URL ? */ $rewrittenUrl = URL::getInstance()->retrieveCurrent($request); if ($rewrittenUrl->rewrittenUrl !== null) { /* 301 redirection to rewritten URL */ throw new RedirectException($rewrittenUrl->rewrittenUrl, 301); } } } }
php
public function noAction(Request $request) { $view = null; if (! $view = $request->query->get('view')) { if ($request->request->has('view')) { $view = $request->request->get('view'); } } if (null !== $view) { $request->attributes->set('_view', $view); } if (null === $view && null === $request->attributes->get("_view")) { $request->attributes->set("_view", "index"); } if (ConfigQuery::isRewritingEnable()) { if ($request->attributes->get('_rewritten', false) === false) { /* Does the query GET parameters match a rewritten URL ? */ $rewrittenUrl = URL::getInstance()->retrieveCurrent($request); if ($rewrittenUrl->rewrittenUrl !== null) { /* 301 redirection to rewritten URL */ throw new RedirectException($rewrittenUrl->rewrittenUrl, 301); } } } }
[ "public", "function", "noAction", "(", "Request", "$", "request", ")", "{", "$", "view", "=", "null", ";", "if", "(", "!", "$", "view", "=", "$", "request", "->", "query", "->", "get", "(", "'view'", ")", ")", "{", "if", "(", "$", "request", "->"...
This is the default Thelia behaviour if no action is defined. If the request contains a 'view' parameter, this view will be displayed. If the request contains a '_view' attribute (set in the route definition, for example), this view will be displayed. Otherwise, we will use the "index" view. Additionaly, if the URL rewriting is enabled, the method will check if a redirect to the pâge rewritten URL should be done. @param \Thelia\Core\HttpFoundation\Request $request @throw RedirectException if a redirection to the rewritted URL shoud be done.
[ "This", "is", "the", "default", "Thelia", "behaviour", "if", "no", "action", "is", "defined", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Front/DefaultController.php#L42-L70
train
thelia/core
lib/Thelia/Condition/ConditionEvaluator.php
ConditionEvaluator.isMatching
public function isMatching(ConditionCollection $conditions) { $isMatching = true; /** @var ConditionInterface $condition */ foreach ($conditions as $condition) { if (!$condition->isMatching()) { return false; } } return $isMatching; }
php
public function isMatching(ConditionCollection $conditions) { $isMatching = true; /** @var ConditionInterface $condition */ foreach ($conditions as $condition) { if (!$condition->isMatching()) { return false; } } return $isMatching; }
[ "public", "function", "isMatching", "(", "ConditionCollection", "$", "conditions", ")", "{", "$", "isMatching", "=", "true", ";", "/** @var ConditionInterface $condition */", "foreach", "(", "$", "conditions", "as", "$", "condition", ")", "{", "if", "(", "!", "$...
Check if an Event matches SerializableCondition @param ConditionCollection $conditions Conditions to check against the Event @return bool
[ "Check", "if", "an", "Event", "matches", "SerializableCondition" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/ConditionEvaluator.php#L33-L44
train
thelia/core
lib/Thelia/Condition/ConditionEvaluator.php
ConditionEvaluator.variableOpComparison
public function variableOpComparison($v1, $o, $v2) { switch ($o) { case Operators::DIFFERENT: // != return ($v1 != $v2); case Operators::SUPERIOR: // > return ($v1 > $v2); case Operators::SUPERIOR_OR_EQUAL: // >= return ($v1 >= $v2); case Operators::INFERIOR: // < return ($v1 < $v2); case Operators::INFERIOR_OR_EQUAL: // <= return ($v1 <= $v2); case Operators::EQUAL: // == return ($v1 == $v2); case Operators::IN: // in return (\in_array($v1, $v2)); case Operators::OUT: // not in return (!\in_array($v1, $v2)); default: throw new \Exception('Unrecognized operator ' . $o); } }
php
public function variableOpComparison($v1, $o, $v2) { switch ($o) { case Operators::DIFFERENT: // != return ($v1 != $v2); case Operators::SUPERIOR: // > return ($v1 > $v2); case Operators::SUPERIOR_OR_EQUAL: // >= return ($v1 >= $v2); case Operators::INFERIOR: // < return ($v1 < $v2); case Operators::INFERIOR_OR_EQUAL: // <= return ($v1 <= $v2); case Operators::EQUAL: // == return ($v1 == $v2); case Operators::IN: // in return (\in_array($v1, $v2)); case Operators::OUT: // not in return (!\in_array($v1, $v2)); default: throw new \Exception('Unrecognized operator ' . $o); } }
[ "public", "function", "variableOpComparison", "(", "$", "v1", ",", "$", "o", ",", "$", "v2", ")", "{", "switch", "(", "$", "o", ")", "{", "case", "Operators", "::", "DIFFERENT", ":", "// !=", "return", "(", "$", "v1", "!=", "$", "v2", ")", ";", "...
Do variable comparison @param mixed $v1 Variable 1 @param string $o Operator ex : Operators::DIFFERENT @param mixed $v2 Variable 2 @throws \Exception @return bool
[ "Do", "variable", "comparison" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/ConditionEvaluator.php#L56-L94
train
thelia/core
lib/Thelia/Core/Event/Hook/BaseHookRenderEvent.php
BaseHookRenderEvent.getArgument
public function getArgument($key, $default = null) { return array_key_exists($key, $this->arguments) ? $this->arguments[$key] : $default; }
php
public function getArgument($key, $default = null) { return array_key_exists($key, $this->arguments) ? $this->arguments[$key] : $default; }
[ "public", "function", "getArgument", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "return", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "arguments", ")", "?", "$", "this", "->", "arguments", "[", "$", "key", "]", ":",...
Get an argument @param string $key @param string|null $default @return mixed|null the value of the argument or `$default` if it not exists
[ "Get", "an", "argument" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Event/Hook/BaseHookRenderEvent.php#L117-L120
train
thelia/core
lib/Thelia/Core/Event/Hook/BaseHookRenderEvent.php
BaseHookRenderEvent.getTemplateVar
public function getTemplateVar($templateVariableName) { if (! isset($this->templateVars[$templateVariableName])) { throw new \InvalidArgumentException(sprintf("Template variable '%s' is not defined.", $templateVariableName)); } return $this->templateVars[$templateVariableName]; }
php
public function getTemplateVar($templateVariableName) { if (! isset($this->templateVars[$templateVariableName])) { throw new \InvalidArgumentException(sprintf("Template variable '%s' is not defined.", $templateVariableName)); } return $this->templateVars[$templateVariableName]; }
[ "public", "function", "getTemplateVar", "(", "$", "templateVariableName", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "templateVars", "[", "$", "templateVariableName", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", ...
Return a template variable value. An exception is thorwn if the variable is not defined. @param string $templateVariableName the variable name @return mixed the variable value @throws \InvalidArgumentException if the variable is not defined
[ "Return", "a", "template", "variable", "value", ".", "An", "exception", "is", "thorwn", "if", "the", "variable", "is", "not", "defined", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Event/Hook/BaseHookRenderEvent.php#L142-L149
train
MetaModels/attribute_tags
src/FilterRule/FilterRuleTags.php
FilterRuleTags.sanitizeValue
public function sanitizeValue() { $strColNameId = $this->objAttribute->get('tag_id') ?: 'id'; $strColNameAlias = $this->objAttribute->get('tag_alias'); $arrValues = \is_array($this->value) ? $this->value : \explode(',', $this->value); if (!$this->isMetaModel()) { if ($strColNameAlias) { $builder = $this->connection->createQueryBuilder() ->select($strColNameId) ->from($this->objAttribute->get('tag_table')); foreach ($arrValues as $index => $value) { $builder ->orWhere($strColNameAlias . ' LIKE :value_' . $index) ->setParameter('value_' . $index, $value); } $arrValues = $builder->execute()->fetchAll(\PDO::FETCH_COLUMN); } else { $arrValues = \array_map('intval', $arrValues); } } else { if ($strColNameAlias == 'id') { $values = $arrValues; } else { $values = []; foreach ($arrValues as $value) { $values[] = \array_values( $this->getTagMetaModel()->getAttribute($strColNameAlias)->searchFor($value) ); } } $arrValues = $this->flatten($values); } return $arrValues; }
php
public function sanitizeValue() { $strColNameId = $this->objAttribute->get('tag_id') ?: 'id'; $strColNameAlias = $this->objAttribute->get('tag_alias'); $arrValues = \is_array($this->value) ? $this->value : \explode(',', $this->value); if (!$this->isMetaModel()) { if ($strColNameAlias) { $builder = $this->connection->createQueryBuilder() ->select($strColNameId) ->from($this->objAttribute->get('tag_table')); foreach ($arrValues as $index => $value) { $builder ->orWhere($strColNameAlias . ' LIKE :value_' . $index) ->setParameter('value_' . $index, $value); } $arrValues = $builder->execute()->fetchAll(\PDO::FETCH_COLUMN); } else { $arrValues = \array_map('intval', $arrValues); } } else { if ($strColNameAlias == 'id') { $values = $arrValues; } else { $values = []; foreach ($arrValues as $value) { $values[] = \array_values( $this->getTagMetaModel()->getAttribute($strColNameAlias)->searchFor($value) ); } } $arrValues = $this->flatten($values); } return $arrValues; }
[ "public", "function", "sanitizeValue", "(", ")", "{", "$", "strColNameId", "=", "$", "this", "->", "objAttribute", "->", "get", "(", "'tag_id'", ")", "?", ":", "'id'", ";", "$", "strColNameAlias", "=", "$", "this", "->", "objAttribute", "->", "get", "(",...
Ensure the value is either a proper id or array od ids - converts aliases to ids. @return array
[ "Ensure", "the", "value", "is", "either", "a", "proper", "id", "or", "array", "od", "ids", "-", "converts", "aliases", "to", "ids", "." ]
d09c2cd18b299a48532caa0de8c70b7944282a8e
https://github.com/MetaModels/attribute_tags/blob/d09c2cd18b299a48532caa0de8c70b7944282a8e/src/FilterRule/FilterRuleTags.php#L123-L159
train
NotifyMeHQ/notifyme
src/Factory/NotifyMeFactory.php
NotifyMeFactory.make
public function make(array $config) { if (!isset($config['driver'])) { throw new InvalidArgumentException('A driver must be specified.'); } return $this->factory($config['driver'])->make($config); }
php
public function make(array $config) { if (!isset($config['driver'])) { throw new InvalidArgumentException('A driver must be specified.'); } return $this->factory($config['driver'])->make($config); }
[ "public", "function", "make", "(", "array", "$", "config", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'driver'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'A driver must be specified.'", ")", ";", "}", "return"...
Create a new gateway instance. @param string[] $config @throws \InvalidArgumentException @return \NotifyMeHQ\Contracts\GatewayInterface
[ "Create", "a", "new", "gateway", "instance", "." ]
2af4bdcfe9df6db7ea79e2dce90b106ccb285b06
https://github.com/NotifyMeHQ/notifyme/blob/2af4bdcfe9df6db7ea79e2dce90b106ccb285b06/src/Factory/NotifyMeFactory.php#L35-L42
train
NotifyMeHQ/notifyme
src/Factory/NotifyMeFactory.php
NotifyMeFactory.factory
public function factory($name) { if (isset($this->factories[$name])) { return $this->factories[$name]; } if (class_exists($class = $this->inflect($name))) { return $this->factories[$name] = new $class(); } throw new InvalidArgumentException("Unsupported factory [$name]."); }
php
public function factory($name) { if (isset($this->factories[$name])) { return $this->factories[$name]; } if (class_exists($class = $this->inflect($name))) { return $this->factories[$name] = new $class(); } throw new InvalidArgumentException("Unsupported factory [$name]."); }
[ "public", "function", "factory", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "factories", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "factories", "[", "$", "name", "]", ";", "}", "if", "(", "c...
Get a factory instance by name. @param string $name @return \NotifyMeHQ\Contracts\FactoryInterface
[ "Get", "a", "factory", "instance", "by", "name", "." ]
2af4bdcfe9df6db7ea79e2dce90b106ccb285b06
https://github.com/NotifyMeHQ/notifyme/blob/2af4bdcfe9df6db7ea79e2dce90b106ccb285b06/src/Factory/NotifyMeFactory.php#L51-L62
train
thelia/core
lib/Thelia/Model/Category.php
Category.getRoot
public function getRoot($categoryId) { $category = CategoryQuery::create()->findPk($categoryId); if (0 !== $category->getParent()) { $parentCategory = CategoryQuery::create()->findPk($category->getParent()); if (null !== $parentCategory) { $categoryId = $this->getRoot($parentCategory->getId()); } } return $categoryId; }
php
public function getRoot($categoryId) { $category = CategoryQuery::create()->findPk($categoryId); if (0 !== $category->getParent()) { $parentCategory = CategoryQuery::create()->findPk($category->getParent()); if (null !== $parentCategory) { $categoryId = $this->getRoot($parentCategory->getId()); } } return $categoryId; }
[ "public", "function", "getRoot", "(", "$", "categoryId", ")", "{", "$", "category", "=", "CategoryQuery", "::", "create", "(", ")", "->", "findPk", "(", "$", "categoryId", ")", ";", "if", "(", "0", "!==", "$", "category", "->", "getParent", "(", ")", ...
Get the root category @param int $categoryId @return mixed
[ "Get", "the", "root", "category" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Category.php#L89-L102
train
nattreid/cms
src/Factories/LoaderFactory.php
LoaderFactory.addRemoteFile
public function addRemoteFile(string $file, string $locale = null): self { $collection = $this->getCollection($this->getType($file), $locale); $collection->addRemoteFile($file); return $this; }
php
public function addRemoteFile(string $file, string $locale = null): self { $collection = $this->getCollection($this->getType($file), $locale); $collection->addRemoteFile($file); return $this; }
[ "public", "function", "addRemoteFile", "(", "string", "$", "file", ",", "string", "$", "locale", "=", "null", ")", ":", "self", "{", "$", "collection", "=", "$", "this", "->", "getCollection", "(", "$", "this", "->", "getType", "(", "$", "file", ")", ...
Prida remote soubor @param string $file @param string $locale @return self
[ "Prida", "remote", "soubor" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Factories/LoaderFactory.php#L83-L88
train
nattreid/cms
src/Factories/LoaderFactory.php
LoaderFactory.createCssLoader
public function createCssLoader(): CssLoader { $compiler = Compiler::createCssCompiler($this->files[self::CSS][null], $this->wwwDir . '/' . $this->outputDir); foreach ($this->filters[self::CSS] as $filter) { $compiler->addFileFilter($filter); } return new CssLoader($compiler, $this->httpRequest->getUrl()->basePath . $this->outputDir); }
php
public function createCssLoader(): CssLoader { $compiler = Compiler::createCssCompiler($this->files[self::CSS][null], $this->wwwDir . '/' . $this->outputDir); foreach ($this->filters[self::CSS] as $filter) { $compiler->addFileFilter($filter); } return new CssLoader($compiler, $this->httpRequest->getUrl()->basePath . $this->outputDir); }
[ "public", "function", "createCssLoader", "(", ")", ":", "CssLoader", "{", "$", "compiler", "=", "Compiler", "::", "createCssCompiler", "(", "$", "this", "->", "files", "[", "self", "::", "CSS", "]", "[", "null", "]", ",", "$", "this", "->", "wwwDir", "...
Vytvori komponentu css @return CssLoader @throws \WebLoader\InvalidArgumentException
[ "Vytvori", "komponentu", "css" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Factories/LoaderFactory.php#L95-L102
train
nattreid/cms
src/Factories/LoaderFactory.php
LoaderFactory.createJavaScriptLoader
public function createJavaScriptLoader(string $locale = null): JavaScriptLoader { $compilers[] = $this->createJSCompiler($this->files[self::JS][null]); if ($locale !== null && isset($this->files[self::JS][$locale])) { $compilers[] = $this->createJSCompiler($this->files[self::JS][$locale]); } return new JavaScriptLoader($this->httpRequest->getUrl()->basePath . $this->outputDir, ...$compilers); }
php
public function createJavaScriptLoader(string $locale = null): JavaScriptLoader { $compilers[] = $this->createJSCompiler($this->files[self::JS][null]); if ($locale !== null && isset($this->files[self::JS][$locale])) { $compilers[] = $this->createJSCompiler($this->files[self::JS][$locale]); } return new JavaScriptLoader($this->httpRequest->getUrl()->basePath . $this->outputDir, ...$compilers); }
[ "public", "function", "createJavaScriptLoader", "(", "string", "$", "locale", "=", "null", ")", ":", "JavaScriptLoader", "{", "$", "compilers", "[", "]", "=", "$", "this", "->", "createJSCompiler", "(", "$", "this", "->", "files", "[", "self", "::", "JS", ...
Vytvori komponentu js @param string $locale @return JavaScriptLoader @throws \WebLoader\InvalidArgumentException
[ "Vytvori", "komponentu", "js" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Factories/LoaderFactory.php#L110-L118
train
nattreid/cms
src/Factories/LoaderFactory.php
LoaderFactory.getCollection
private function getCollection(string $type, string $locale = null): FileCollection { if (!isset($this->files[$type][$locale])) { $this->files[$type][$locale] = new FileCollection($this->root); } return $this->files[$type][$locale]; }
php
private function getCollection(string $type, string $locale = null): FileCollection { if (!isset($this->files[$type][$locale])) { $this->files[$type][$locale] = new FileCollection($this->root); } return $this->files[$type][$locale]; }
[ "private", "function", "getCollection", "(", "string", "$", "type", ",", "string", "$", "locale", "=", "null", ")", ":", "FileCollection", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "files", "[", "$", "type", "]", "[", "$", "locale", "]", ...
Vrati kolekci souboru @param string $type @param string $locale @return FileCollection
[ "Vrati", "kolekci", "souboru" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Factories/LoaderFactory.php#L151-L157
train
nattreid/cms
src/Factories/LoaderFactory.php
LoaderFactory.getType
private function getType(string $file): string { $css = '/\.(css|less)$/'; $js = '/\.js$/'; if (preg_match($css, $file)) { return self::CSS; } elseif (preg_match($js, $file)) { return self::JS; } throw new InvalidArgumentException("Unknown assets file '$file'"); }
php
private function getType(string $file): string { $css = '/\.(css|less)$/'; $js = '/\.js$/'; if (preg_match($css, $file)) { return self::CSS; } elseif (preg_match($js, $file)) { return self::JS; } throw new InvalidArgumentException("Unknown assets file '$file'"); }
[ "private", "function", "getType", "(", "string", "$", "file", ")", ":", "string", "{", "$", "css", "=", "'/\\.(css|less)$/'", ";", "$", "js", "=", "'/\\.js$/'", ";", "if", "(", "preg_match", "(", "$", "css", ",", "$", "file", ")", ")", "{", "return",...
Vrati typ souboru @param string $file @return string
[ "Vrati", "typ", "souboru" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Factories/LoaderFactory.php#L164-L175
train
thelia/core
lib/Thelia/Core/Template/Loop/Product.php
Product.getDefaultCategoryId
protected function getDefaultCategoryId($product) { $defaultCategoryId = null; if ((bool) $product->getVirtualColumn('is_default_category')) { $defaultCategoryId = $product->getVirtualColumn('default_category_id'); } else { $defaultCategoryId = $product->getDefaultCategoryId(); } return $defaultCategoryId; }
php
protected function getDefaultCategoryId($product) { $defaultCategoryId = null; if ((bool) $product->getVirtualColumn('is_default_category')) { $defaultCategoryId = $product->getVirtualColumn('default_category_id'); } else { $defaultCategoryId = $product->getDefaultCategoryId(); } return $defaultCategoryId; }
[ "protected", "function", "getDefaultCategoryId", "(", "$", "product", ")", "{", "$", "defaultCategoryId", "=", "null", ";", "if", "(", "(", "bool", ")", "$", "product", "->", "getVirtualColumn", "(", "'is_default_category'", ")", ")", "{", "$", "defaultCategor...
Get the default category id for a product @param \Thelia\Model\Product $product @return null|int @throws \Propel\Runtime\Exception\PropelException
[ "Get", "the", "default", "category", "id", "for", "a", "product" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Template/Loop/Product.php#L1207-L1216
train
nattreid/cms
src/Control/presenters/ProfilePresenter.php
ProfilePresenter.createComponentPasswordForm
protected function createComponentPasswordForm(): Form { $form = $this->formFactory->create(); $form->setAjaxRequest(); $form->addPassword('oldPassword', 'cms.user.oldPassword') ->setRequired(); $form->addPassword('password', 'cms.user.newPassword') ->setRequired() ->addRule(Form::MIN_LENGTH, null, $this->minPasswordLength); $form->addPassword('passwordVerify', 'cms.user.passwordVerify') ->setRequired() ->addRule(Form::EQUAL, null, $form['password']); $form->addProtection(); $form->addSubmit('save', 'form.save'); $form->onSuccess[] = [$this, 'passwordFormSucceeded']; return $form; }
php
protected function createComponentPasswordForm(): Form { $form = $this->formFactory->create(); $form->setAjaxRequest(); $form->addPassword('oldPassword', 'cms.user.oldPassword') ->setRequired(); $form->addPassword('password', 'cms.user.newPassword') ->setRequired() ->addRule(Form::MIN_LENGTH, null, $this->minPasswordLength); $form->addPassword('passwordVerify', 'cms.user.passwordVerify') ->setRequired() ->addRule(Form::EQUAL, null, $form['password']); $form->addProtection(); $form->addSubmit('save', 'form.save'); $form->onSuccess[] = [$this, 'passwordFormSucceeded']; return $form; }
[ "protected", "function", "createComponentPasswordForm", "(", ")", ":", "Form", "{", "$", "form", "=", "$", "this", "->", "formFactory", "->", "create", "(", ")", ";", "$", "form", "->", "setAjaxRequest", "(", ")", ";", "$", "form", "->", "addPassword", "...
Formular zmeny hesla @return Form
[ "Formular", "zmeny", "hesla" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/ProfilePresenter.php#L152-L174
train
thelia/core
lib/Thelia/Action/ProductSaleElement.php
ProductSaleElement.create
public function create(ProductSaleElementCreateEvent $event) { $con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); $con->beginTransaction(); try { // Check if we have a PSE without combination, this is the "default" PSE. Attach the combination to this PSE $salesElement = ProductSaleElementsQuery::create() ->filterByProductId($event->getProduct()->getId()) ->joinAttributeCombination(null, Criteria::LEFT_JOIN) ->add(AttributeCombinationTableMap::COL_PRODUCT_SALE_ELEMENTS_ID, null, Criteria::ISNULL) ->findOne($con); if ($salesElement == null) { // Create a new default product sale element $salesElement = $event->getProduct()->createProductSaleElement($con, 0, 0, 0, $event->getCurrencyId(), false); } else { // This (new) one is the default $salesElement->setIsDefault(true)->save($con); } // Attach combination, if defined. $combinationAttributes = $event->getAttributeAvList(); if (\count($combinationAttributes) > 0) { foreach ($combinationAttributes as $attributeAvId) { $attributeAv = AttributeAvQuery::create()->findPk($attributeAvId); if ($attributeAv !== null) { $attributeCombination = new AttributeCombination(); $attributeCombination ->setAttributeAvId($attributeAvId) ->setAttribute($attributeAv->getAttribute()) ->setProductSaleElements($salesElement) ->save($con); } } } $event->setProductSaleElement($salesElement); // Store all the stuff ! $con->commit(); } catch (\Exception $ex) { $con->rollback(); throw $ex; } }
php
public function create(ProductSaleElementCreateEvent $event) { $con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); $con->beginTransaction(); try { // Check if we have a PSE without combination, this is the "default" PSE. Attach the combination to this PSE $salesElement = ProductSaleElementsQuery::create() ->filterByProductId($event->getProduct()->getId()) ->joinAttributeCombination(null, Criteria::LEFT_JOIN) ->add(AttributeCombinationTableMap::COL_PRODUCT_SALE_ELEMENTS_ID, null, Criteria::ISNULL) ->findOne($con); if ($salesElement == null) { // Create a new default product sale element $salesElement = $event->getProduct()->createProductSaleElement($con, 0, 0, 0, $event->getCurrencyId(), false); } else { // This (new) one is the default $salesElement->setIsDefault(true)->save($con); } // Attach combination, if defined. $combinationAttributes = $event->getAttributeAvList(); if (\count($combinationAttributes) > 0) { foreach ($combinationAttributes as $attributeAvId) { $attributeAv = AttributeAvQuery::create()->findPk($attributeAvId); if ($attributeAv !== null) { $attributeCombination = new AttributeCombination(); $attributeCombination ->setAttributeAvId($attributeAvId) ->setAttribute($attributeAv->getAttribute()) ->setProductSaleElements($salesElement) ->save($con); } } } $event->setProductSaleElement($salesElement); // Store all the stuff ! $con->commit(); } catch (\Exception $ex) { $con->rollback(); throw $ex; } }
[ "public", "function", "create", "(", "ProductSaleElementCreateEvent", "$", "event", ")", "{", "$", "con", "=", "Propel", "::", "getWriteConnection", "(", "ProductSaleElementsTableMap", "::", "DATABASE_NAME", ")", ";", "$", "con", "->", "beginTransaction", "(", ")"...
Create a new product sale element, with or without combination @param ProductSaleElementCreateEvent $event @throws \Exception
[ "Create", "a", "new", "product", "sale", "element", "with", "or", "without", "combination" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/ProductSaleElement.php#L60-L110
train
thelia/core
lib/Thelia/Action/ProductSaleElement.php
ProductSaleElement.update
public function update(ProductSaleElementUpdateEvent $event) { $salesElement = ProductSaleElementsQuery::create()->findPk($event->getProductSaleElementId()); $con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); $con->beginTransaction(); try { // Update the product's tax rule $event->getProduct()->setTaxRuleId($event->getTaxRuleId())->save($con); // If product sale element is not defined, create it. if ($salesElement == null) { $salesElement = new ProductSaleElements(); $salesElement->setProduct($event->getProduct()); } $defaultStatus = $event->getIsDefault(); // If this PSE will become the default one, be sure to have *only one* default for this product if ($defaultStatus) { ProductSaleElementsQuery::create() ->filterByProduct($event->getProduct()) ->filterByIsDefault(true) ->filterById($event->getProductSaleElementId(), Criteria::NOT_EQUAL) ->update(['IsDefault' => false], $con) ; } else { // We will not allow the default PSE to become non default if no other default PSE exists for this product. if ($salesElement->getIsDefault() && ProductSaleElementsQuery::create() ->filterByProduct($event->getProduct()) ->filterByIsDefault(true) ->filterById($salesElement->getId(), Criteria::NOT_EQUAL) ->count() === 0) { // Prevent setting the only default PSE to non-default $defaultStatus = true; } } // Update sale element $salesElement ->setRef($event->getReference()) ->setQuantity($event->getQuantity()) ->setPromo($event->getOnsale()) ->setNewness($event->getIsnew()) ->setWeight($event->getWeight()) ->setIsDefault($defaultStatus) ->setEanCode($event->getEanCode()) ->save() ; // Update/create price for current currency $productPrice = ProductPriceQuery::create() ->filterByCurrencyId($event->getCurrencyId()) ->filterByProductSaleElementsId($salesElement->getId()) ->findOne($con); // If price is not defined, create it. if ($productPrice == null) { $productPrice = new ProductPrice(); $productPrice ->setProductSaleElements($salesElement) ->setCurrencyId($event->getCurrencyId()) ; } // Check if we have to store the price $productPrice->setFromDefaultCurrency($event->getFromDefaultCurrency()); if ($event->getFromDefaultCurrency() == 0) { // Store the price $productPrice ->setPromoPrice($event->getSalePrice()) ->setPrice($event->getPrice()) ; } else { // Do not store the price. $productPrice ->setPromoPrice(0) ->setPrice(0) ; } $productPrice->save($con); // Store all the stuff ! $con->commit(); } catch (\Exception $ex) { $con->rollback(); throw $ex; } }
php
public function update(ProductSaleElementUpdateEvent $event) { $salesElement = ProductSaleElementsQuery::create()->findPk($event->getProductSaleElementId()); $con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); $con->beginTransaction(); try { // Update the product's tax rule $event->getProduct()->setTaxRuleId($event->getTaxRuleId())->save($con); // If product sale element is not defined, create it. if ($salesElement == null) { $salesElement = new ProductSaleElements(); $salesElement->setProduct($event->getProduct()); } $defaultStatus = $event->getIsDefault(); // If this PSE will become the default one, be sure to have *only one* default for this product if ($defaultStatus) { ProductSaleElementsQuery::create() ->filterByProduct($event->getProduct()) ->filterByIsDefault(true) ->filterById($event->getProductSaleElementId(), Criteria::NOT_EQUAL) ->update(['IsDefault' => false], $con) ; } else { // We will not allow the default PSE to become non default if no other default PSE exists for this product. if ($salesElement->getIsDefault() && ProductSaleElementsQuery::create() ->filterByProduct($event->getProduct()) ->filterByIsDefault(true) ->filterById($salesElement->getId(), Criteria::NOT_EQUAL) ->count() === 0) { // Prevent setting the only default PSE to non-default $defaultStatus = true; } } // Update sale element $salesElement ->setRef($event->getReference()) ->setQuantity($event->getQuantity()) ->setPromo($event->getOnsale()) ->setNewness($event->getIsnew()) ->setWeight($event->getWeight()) ->setIsDefault($defaultStatus) ->setEanCode($event->getEanCode()) ->save() ; // Update/create price for current currency $productPrice = ProductPriceQuery::create() ->filterByCurrencyId($event->getCurrencyId()) ->filterByProductSaleElementsId($salesElement->getId()) ->findOne($con); // If price is not defined, create it. if ($productPrice == null) { $productPrice = new ProductPrice(); $productPrice ->setProductSaleElements($salesElement) ->setCurrencyId($event->getCurrencyId()) ; } // Check if we have to store the price $productPrice->setFromDefaultCurrency($event->getFromDefaultCurrency()); if ($event->getFromDefaultCurrency() == 0) { // Store the price $productPrice ->setPromoPrice($event->getSalePrice()) ->setPrice($event->getPrice()) ; } else { // Do not store the price. $productPrice ->setPromoPrice(0) ->setPrice(0) ; } $productPrice->save($con); // Store all the stuff ! $con->commit(); } catch (\Exception $ex) { $con->rollback(); throw $ex; } }
[ "public", "function", "update", "(", "ProductSaleElementUpdateEvent", "$", "event", ")", "{", "$", "salesElement", "=", "ProductSaleElementsQuery", "::", "create", "(", ")", "->", "findPk", "(", "$", "event", "->", "getProductSaleElementId", "(", ")", ")", ";", ...
Update an existing product sale element @param ProductSaleElementUpdateEvent $event @throws \Exception
[ "Update", "an", "existing", "product", "sale", "element" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/ProductSaleElement.php#L118-L213
train
thelia/core
lib/Thelia/Action/ProductSaleElement.php
ProductSaleElement.delete
public function delete(ProductSaleElementDeleteEvent $event) { if (null !== $pse = ProductSaleElementsQuery::create()->findPk($event->getProductSaleElementId())) { $product = $pse->getProduct(); $con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); $con->beginTransaction(); try { // If we are deleting the last PSE of the product, don(t delete it, but insteaf // transform it into a PSE detached for any attribute combination, so that product // prices, weight, stock and attributes will not be lost. if ($product->countSaleElements($con) === 1) { $pse ->setIsDefault(true) ->save($con); // Delete the related attribute combination. AttributeCombinationQuery::create() ->filterByProductSaleElementsId($pse->getId()) ->delete($con); } else { // Delete the PSE $pse->delete($con); // If we deleted the default PSE, make the last created one the default if ($pse->getIsDefault()) { $newDefaultPse = ProductSaleElementsQuery::create() ->filterByProductId($product->getId()) ->filterById($pse->getId(), Criteria::NOT_EQUAL) ->orderByCreatedAt(Criteria::DESC) ->findOne($con) ; if (null !== $newDefaultPse) { $newDefaultPse->setIsDefault(true)->save($con); } } } // Store all the stuff ! $con->commit(); } catch (\Exception $ex) { $con->rollback(); throw $ex; } } }
php
public function delete(ProductSaleElementDeleteEvent $event) { if (null !== $pse = ProductSaleElementsQuery::create()->findPk($event->getProductSaleElementId())) { $product = $pse->getProduct(); $con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); $con->beginTransaction(); try { // If we are deleting the last PSE of the product, don(t delete it, but insteaf // transform it into a PSE detached for any attribute combination, so that product // prices, weight, stock and attributes will not be lost. if ($product->countSaleElements($con) === 1) { $pse ->setIsDefault(true) ->save($con); // Delete the related attribute combination. AttributeCombinationQuery::create() ->filterByProductSaleElementsId($pse->getId()) ->delete($con); } else { // Delete the PSE $pse->delete($con); // If we deleted the default PSE, make the last created one the default if ($pse->getIsDefault()) { $newDefaultPse = ProductSaleElementsQuery::create() ->filterByProductId($product->getId()) ->filterById($pse->getId(), Criteria::NOT_EQUAL) ->orderByCreatedAt(Criteria::DESC) ->findOne($con) ; if (null !== $newDefaultPse) { $newDefaultPse->setIsDefault(true)->save($con); } } } // Store all the stuff ! $con->commit(); } catch (\Exception $ex) { $con->rollback(); throw $ex; } } }
[ "public", "function", "delete", "(", "ProductSaleElementDeleteEvent", "$", "event", ")", "{", "if", "(", "null", "!==", "$", "pse", "=", "ProductSaleElementsQuery", "::", "create", "(", ")", "->", "findPk", "(", "$", "event", "->", "getProductSaleElementId", "...
Delete a product sale element @param ProductSaleElementDeleteEvent $event @throws \Exception
[ "Delete", "a", "product", "sale", "element" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/ProductSaleElement.php#L221-L267
train
thelia/core
lib/Thelia/Action/ProductSaleElement.php
ProductSaleElement.generateCombinations
public function generateCombinations(ProductCombinationGenerationEvent $event) { $con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); $con->beginTransaction(); try { // Delete all product's productSaleElement ProductSaleElementsQuery::create()->filterByProductId($event->product->getId())->delete(); $isDefault = true; // Create all combinations foreach ($event->getCombinations() as $combinationAttributesAvIds) { // Create the PSE $saleElement = $event->getProduct()->createProductSaleElement( $con, $event->getWeight(), $event->getPrice(), $event->getSalePrice(), $event->getCurrencyId(), $isDefault, $event->getOnsale(), $event->getIsnew(), $event->getQuantity(), $event->getEanCode(), $event->getReference() ); $isDefault = false; $this->createCombination($con, $saleElement, $combinationAttributesAvIds); } // Store all the stuff ! $con->commit(); } catch (\Exception $ex) { $con->rollback(); throw $ex; } }
php
public function generateCombinations(ProductCombinationGenerationEvent $event) { $con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); $con->beginTransaction(); try { // Delete all product's productSaleElement ProductSaleElementsQuery::create()->filterByProductId($event->product->getId())->delete(); $isDefault = true; // Create all combinations foreach ($event->getCombinations() as $combinationAttributesAvIds) { // Create the PSE $saleElement = $event->getProduct()->createProductSaleElement( $con, $event->getWeight(), $event->getPrice(), $event->getSalePrice(), $event->getCurrencyId(), $isDefault, $event->getOnsale(), $event->getIsnew(), $event->getQuantity(), $event->getEanCode(), $event->getReference() ); $isDefault = false; $this->createCombination($con, $saleElement, $combinationAttributesAvIds); } // Store all the stuff ! $con->commit(); } catch (\Exception $ex) { $con->rollback(); throw $ex; } }
[ "public", "function", "generateCombinations", "(", "ProductCombinationGenerationEvent", "$", "event", ")", "{", "$", "con", "=", "Propel", "::", "getWriteConnection", "(", "ProductSaleElementsTableMap", "::", "DATABASE_NAME", ")", ";", "$", "con", "->", "beginTransact...
Generate combinations. All existing combinations for the product are deleted. @param ProductCombinationGenerationEvent $event @throws \Exception
[ "Generate", "combinations", ".", "All", "existing", "combinations", "for", "the", "product", "are", "deleted", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/ProductSaleElement.php#L275-L316
train
thelia/core
lib/Thelia/Action/ProductSaleElement.php
ProductSaleElement.createCombination
protected function createCombination(ConnectionInterface $con, ProductSaleElements $salesElement, $combinationAttributes) { foreach ($combinationAttributes as $attributeAvId) { $attributeAv = AttributeAvQuery::create()->findPk($attributeAvId); if ($attributeAv !== null) { $attributeCombination = new AttributeCombination(); $attributeCombination ->setAttributeAvId($attributeAvId) ->setAttribute($attributeAv->getAttribute()) ->setProductSaleElements($salesElement) ->save($con); } } }
php
protected function createCombination(ConnectionInterface $con, ProductSaleElements $salesElement, $combinationAttributes) { foreach ($combinationAttributes as $attributeAvId) { $attributeAv = AttributeAvQuery::create()->findPk($attributeAvId); if ($attributeAv !== null) { $attributeCombination = new AttributeCombination(); $attributeCombination ->setAttributeAvId($attributeAvId) ->setAttribute($attributeAv->getAttribute()) ->setProductSaleElements($salesElement) ->save($con); } } }
[ "protected", "function", "createCombination", "(", "ConnectionInterface", "$", "con", ",", "ProductSaleElements", "$", "salesElement", ",", "$", "combinationAttributes", ")", "{", "foreach", "(", "$", "combinationAttributes", "as", "$", "attributeAvId", ")", "{", "$...
Create a combination for a given product sale element @param ConnectionInterface $con the Propel connection @param ProductSaleElements $salesElement the product sale element @param array $combinationAttributes an array oif attributes av IDs @throws \Propel\Runtime\Exception\PropelException
[ "Create", "a", "combination", "for", "a", "given", "product", "sale", "element" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/ProductSaleElement.php#L326-L341
train
thelia/core
lib/Thelia/Action/ProductSaleElement.php
ProductSaleElement.clonePSE
public function clonePSE(ProductCloneEvent $event) { $clonedProduct = $event->getClonedProduct(); // Get original product's PSEs $originalProductPSEs = ProductSaleElementsQuery::create() ->orderByIsDefault(Criteria::DESC) ->findByProductId($event->getOriginalProduct()->getId()); /** * Handle PSEs * * @var int $key * @var ProductSaleElements $originalProductPSE */ foreach ($originalProductPSEs as $key => $originalProductPSE) { $currencyId = ProductPriceQuery::create() ->filterByProductSaleElementsId($originalProductPSE->getId()) ->select('CURRENCY_ID') ->findOne(); // The default PSE, created at the same time as the clone product, is overwritten $clonedProductPSEId = $this->createClonePSE($event, $originalProductPSE, $currencyId); $this->updateClonePSE($event, $clonedProductPSEId, $originalProductPSE, $key); // PSE associated images $originalProductPSEImages = ProductSaleElementsProductImageQuery::create() ->findByProductSaleElementsId($originalProductPSE->getId()); if (null !== $originalProductPSEImages) { $this->clonePSEAssociatedFiles($clonedProduct->getId(), $clonedProductPSEId, $originalProductPSEImages, $type = 'image'); } // PSE associated documents $originalProductPSEDocuments = ProductSaleElementsProductDocumentQuery::create() ->findByProductSaleElementsId($originalProductPSE->getId()); if (null !== $originalProductPSEDocuments) { $this->clonePSEAssociatedFiles($clonedProduct->getId(), $clonedProductPSEId, $originalProductPSEDocuments, $type = 'document'); } } }
php
public function clonePSE(ProductCloneEvent $event) { $clonedProduct = $event->getClonedProduct(); // Get original product's PSEs $originalProductPSEs = ProductSaleElementsQuery::create() ->orderByIsDefault(Criteria::DESC) ->findByProductId($event->getOriginalProduct()->getId()); /** * Handle PSEs * * @var int $key * @var ProductSaleElements $originalProductPSE */ foreach ($originalProductPSEs as $key => $originalProductPSE) { $currencyId = ProductPriceQuery::create() ->filterByProductSaleElementsId($originalProductPSE->getId()) ->select('CURRENCY_ID') ->findOne(); // The default PSE, created at the same time as the clone product, is overwritten $clonedProductPSEId = $this->createClonePSE($event, $originalProductPSE, $currencyId); $this->updateClonePSE($event, $clonedProductPSEId, $originalProductPSE, $key); // PSE associated images $originalProductPSEImages = ProductSaleElementsProductImageQuery::create() ->findByProductSaleElementsId($originalProductPSE->getId()); if (null !== $originalProductPSEImages) { $this->clonePSEAssociatedFiles($clonedProduct->getId(), $clonedProductPSEId, $originalProductPSEImages, $type = 'image'); } // PSE associated documents $originalProductPSEDocuments = ProductSaleElementsProductDocumentQuery::create() ->findByProductSaleElementsId($originalProductPSE->getId()); if (null !== $originalProductPSEDocuments) { $this->clonePSEAssociatedFiles($clonedProduct->getId(), $clonedProductPSEId, $originalProductPSEDocuments, $type = 'document'); } } }
[ "public", "function", "clonePSE", "(", "ProductCloneEvent", "$", "event", ")", "{", "$", "clonedProduct", "=", "$", "event", "->", "getClonedProduct", "(", ")", ";", "// Get original product's PSEs", "$", "originalProductPSEs", "=", "ProductSaleElementsQuery", "::", ...
Clone product's PSEs and associated datas @param ProductCloneEvent $event @throws \Propel\Runtime\Exception\PropelException
[ "Clone", "product", "s", "PSEs", "and", "associated", "datas" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/ProductSaleElement.php#L353-L395
train
thelia/core
lib/Thelia/Model/Customer.php
Customer.getCustomerLang
public function getCustomerLang() { $lang = $this->getLangModel(); if ($lang === null) { $lang = (new LangQuery) ->filterByByDefault(1) ->findOne() ; } return $lang; }
php
public function getCustomerLang() { $lang = $this->getLangModel(); if ($lang === null) { $lang = (new LangQuery) ->filterByByDefault(1) ->findOne() ; } return $lang; }
[ "public", "function", "getCustomerLang", "(", ")", "{", "$", "lang", "=", "$", "this", "->", "getLangModel", "(", ")", ";", "if", "(", "$", "lang", "===", "null", ")", "{", "$", "lang", "=", "(", "new", "LangQuery", ")", "->", "filterByByDefault", "(...
Return the customer lang, or the default one if none is defined. @return \Thelia\Model\Lang Lang model
[ "Return", "the", "customer", "lang", "or", "the", "default", "one", "if", "none", "is", "defined", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Customer.php#L161-L173
train
thelia/core
lib/Thelia/Model/Customer.php
Customer.setPassword
public function setPassword($password) { if ($this->isNew() && ($password === null || trim($password) == "")) { throw new InvalidArgumentException("customer password is mandatory on creation"); } if ($password !== null && trim($password) != "") { $this->setAlgo("PASSWORD_BCRYPT"); parent::setPassword(password_hash($password, PASSWORD_BCRYPT)); } return $this; }
php
public function setPassword($password) { if ($this->isNew() && ($password === null || trim($password) == "")) { throw new InvalidArgumentException("customer password is mandatory on creation"); } if ($password !== null && trim($password) != "") { $this->setAlgo("PASSWORD_BCRYPT"); parent::setPassword(password_hash($password, PASSWORD_BCRYPT)); } return $this; }
[ "public", "function", "setPassword", "(", "$", "password", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "(", "$", "password", "===", "null", "||", "trim", "(", "$", "password", ")", "==", "\"\"", ")", ")", "{", "throw", "new", ...
create hash for plain password and set it in Customer object @param string $password plain password before hashing @throws Exception\InvalidArgumentException @return $this|Customer
[ "create", "hash", "for", "plain", "password", "and", "set", "it", "in", "Customer", "object" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Customer.php#L249-L262
train
BoldGrid/library
src/Library/Plugin/Plugin.php
Plugin.getDownloadUrl
public function getDownloadUrl() { $url = Configs::get( 'api' ) . '/v1/plugins/' . $this->slug . '/download'; $url = add_query_arg( 'key', Configs::get( 'key' ), $url ); return $url; }
php
public function getDownloadUrl() { $url = Configs::get( 'api' ) . '/v1/plugins/' . $this->slug . '/download'; $url = add_query_arg( 'key', Configs::get( 'key' ), $url ); return $url; }
[ "public", "function", "getDownloadUrl", "(", ")", "{", "$", "url", "=", "Configs", "::", "get", "(", "'api'", ")", ".", "'/v1/plugins/'", ".", "$", "this", "->", "slug", ".", "'/download'", ";", "$", "url", "=", "add_query_arg", "(", "'key'", ",", "Con...
Return the download url for a plugin. @since 2.7.7 @return string
[ "Return", "the", "download", "url", "for", "a", "plugin", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Plugin/Plugin.php#L50-L56
train
nattreid/cms
src/Control/presenters/DatabasePresenter.php
DatabasePresenter.createComponentUploadForm
protected function createComponentUploadForm(): Form { $form = $this->formFactory->create(); $form->addUpload('sql', 'cms.database.file') ->setRequired(); $form->addSubmit('upload', 'cms.database.upload'); $form->onSuccess[] = [$this, 'uploadFormSucceeded']; return $form; }
php
protected function createComponentUploadForm(): Form { $form = $this->formFactory->create(); $form->addUpload('sql', 'cms.database.file') ->setRequired(); $form->addSubmit('upload', 'cms.database.upload'); $form->onSuccess[] = [$this, 'uploadFormSucceeded']; return $form; }
[ "protected", "function", "createComponentUploadForm", "(", ")", ":", "Form", "{", "$", "form", "=", "$", "this", "->", "formFactory", "->", "create", "(", ")", ";", "$", "form", "->", "addUpload", "(", "'sql'", ",", "'cms.database.file'", ")", "->", "setRe...
Formular nahrani databaze @return Form
[ "Formular", "nahrani", "databaze" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/DatabasePresenter.php#L33-L45
train
mglaman/platform-docker
src/PlatformServiceConfig.php
PlatformServiceConfig.getSolrType
public static function getSolrType() { $relationships = PlatformAppConfig::get('relationships'); if (!isset($relationships['solr'])) { return FALSE; } list($solr_key, ) = explode(':', $relationships['solr']); $solr_config = self::get($solr_key); if (!isset($solr_config['type'])) { return FALSE; } return $solr_config['type']; }
php
public static function getSolrType() { $relationships = PlatformAppConfig::get('relationships'); if (!isset($relationships['solr'])) { return FALSE; } list($solr_key, ) = explode(':', $relationships['solr']); $solr_config = self::get($solr_key); if (!isset($solr_config['type'])) { return FALSE; } return $solr_config['type']; }
[ "public", "static", "function", "getSolrType", "(", ")", "{", "$", "relationships", "=", "PlatformAppConfig", "::", "get", "(", "'relationships'", ")", ";", "if", "(", "!", "isset", "(", "$", "relationships", "[", "'solr'", "]", ")", ")", "{", "return", ...
Gets the solr type. @return string|FALSE FALSE if solr is not used.
[ "Gets", "the", "solr", "type", "." ]
217be131f70454a0f2c62a7ae0553c432731bfdf
https://github.com/mglaman/platform-docker/blob/217be131f70454a0f2c62a7ae0553c432731bfdf/src/PlatformServiceConfig.php#L26-L37
train
mglaman/platform-docker
src/PlatformServiceConfig.php
PlatformServiceConfig.getSolrMajorVersion
public static function getSolrMajorVersion() { $type = static::getSolrType(); $version = FALSE; if ($type) { list(, $version) = explode(":", $type); if (preg_match('/^(\d)\./', $version, $matches)) { $version = $matches[1]; } else { $version = '4'; } // Platform support 3,4 and 6 atm. We only support 4 and 6. if ($version === '3') { $version = '4'; } } return $version; }
php
public static function getSolrMajorVersion() { $type = static::getSolrType(); $version = FALSE; if ($type) { list(, $version) = explode(":", $type); if (preg_match('/^(\d)\./', $version, $matches)) { $version = $matches[1]; } else { $version = '4'; } // Platform support 3,4 and 6 atm. We only support 4 and 6. if ($version === '3') { $version = '4'; } } return $version; }
[ "public", "static", "function", "getSolrMajorVersion", "(", ")", "{", "$", "type", "=", "static", "::", "getSolrType", "(", ")", ";", "$", "version", "=", "FALSE", ";", "if", "(", "$", "type", ")", "{", "list", "(", ",", "$", "version", ")", "=", "...
Gets the solr major version @return string|FALSE
[ "Gets", "the", "solr", "major", "version" ]
217be131f70454a0f2c62a7ae0553c432731bfdf
https://github.com/mglaman/platform-docker/blob/217be131f70454a0f2c62a7ae0553c432731bfdf/src/PlatformServiceConfig.php#L44-L61
train
thelia/core
lib/Thelia/Core/Archiver/ArchiverManager.php
ArchiverManager.getArchivers
public function getArchivers($isAvailable = null) { if ($isAvailable === null) { return $this->archivers; } $filteredArchivers = []; /** @var \Thelia\Core\Archiver\ArchiverInterface $archiver */ foreach ($this->archivers as $archiver) { if ($archiver->isAvailable() === (bool) $isAvailable) { $filteredArchivers[] = $archiver; } } return $filteredArchivers; }
php
public function getArchivers($isAvailable = null) { if ($isAvailable === null) { return $this->archivers; } $filteredArchivers = []; /** @var \Thelia\Core\Archiver\ArchiverInterface $archiver */ foreach ($this->archivers as $archiver) { if ($archiver->isAvailable() === (bool) $isAvailable) { $filteredArchivers[] = $archiver; } } return $filteredArchivers; }
[ "public", "function", "getArchivers", "(", "$", "isAvailable", "=", "null", ")", "{", "if", "(", "$", "isAvailable", "===", "null", ")", "{", "return", "$", "this", "->", "archivers", ";", "}", "$", "filteredArchivers", "=", "[", "]", ";", "/** @var \\Th...
Get all archivers or only those match availability @param null|boolean $isAvailable Filter archivers by availability @return array All, or filtered by availability, archivers
[ "Get", "all", "archivers", "or", "only", "those", "match", "availability" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Archiver/ArchiverManager.php#L47-L63
train
thelia/core
lib/Thelia/Core/Archiver/ArchiverManager.php
ArchiverManager.get
public function get($archiverId, $isAvailable = null) { $this->has($archiverId, true); if ($isAvailable === null) { return $this->archivers[$archiverId]; } if ($this->archivers[$archiverId]->isAvailable() === (bool) $isAvailable) { return $this->archivers[$archiverId]; } return null; }
php
public function get($archiverId, $isAvailable = null) { $this->has($archiverId, true); if ($isAvailable === null) { return $this->archivers[$archiverId]; } if ($this->archivers[$archiverId]->isAvailable() === (bool) $isAvailable) { return $this->archivers[$archiverId]; } return null; }
[ "public", "function", "get", "(", "$", "archiverId", ",", "$", "isAvailable", "=", "null", ")", "{", "$", "this", "->", "has", "(", "$", "archiverId", ",", "true", ")", ";", "if", "(", "$", "isAvailable", "===", "null", ")", "{", "return", "$", "th...
Get an archiver @param string $archiverId An archiver identifier @param null|boolean $isAvailable Filter archiver by availability @return null|\Thelia\Core\Archiver\ArchiverInterface Return an archiver or null depends on availability
[ "Get", "an", "archiver" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Archiver/ArchiverManager.php#L101-L114
train
thelia/core
lib/Thelia/Model/Message.php
Message.getMessageBody
protected function getMessageBody($parser, $message, $layout, $template, $compressOutput = true) { $body = false; // Try to get the body from template file, if a file is defined if (! empty($template)) { try { $body = $parser->render($template, [], $compressOutput); } catch (ResourceNotFoundException $ex) { Tlog::getInstance()->addError("Failed to get mail message template body $template"); } } // We did not get it ? Use the message entered in the back-office if ($body === false) { $body = $parser->renderString($message, [], $compressOutput); } // Do we have a layout ? if (! empty($layout)) { // Populate the message body variable $parser->assign('message_body', $body); // Render the layout file $body = $parser->render($layout, [], $compressOutput); } return $body; }
php
protected function getMessageBody($parser, $message, $layout, $template, $compressOutput = true) { $body = false; // Try to get the body from template file, if a file is defined if (! empty($template)) { try { $body = $parser->render($template, [], $compressOutput); } catch (ResourceNotFoundException $ex) { Tlog::getInstance()->addError("Failed to get mail message template body $template"); } } // We did not get it ? Use the message entered in the back-office if ($body === false) { $body = $parser->renderString($message, [], $compressOutput); } // Do we have a layout ? if (! empty($layout)) { // Populate the message body variable $parser->assign('message_body', $body); // Render the layout file $body = $parser->render($layout, [], $compressOutput); } return $body; }
[ "protected", "function", "getMessageBody", "(", "$", "parser", ",", "$", "message", ",", "$", "layout", ",", "$", "template", ",", "$", "compressOutput", "=", "true", ")", "{", "$", "body", "=", "false", ";", "// Try to get the body from template file, if a file...
Calculate the message body, given the HTML entered in the back-office, the message layout, and the message template @param ParserInterface $parser @param $message @param $layout @param $template @return bool
[ "Calculate", "the", "message", "body", "given", "the", "HTML", "entered", "in", "the", "back", "-", "office", "the", "message", "layout", "and", "the", "message", "template" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Message.php#L92-L120
train
thelia/core
lib/Thelia/Model/Message.php
Message.getHtmlMessageBody
public function getHtmlMessageBody(ParserInterface $parser) { return $this->getMessageBody( $parser, $this->getHtmlMessage(), $this->getHtmlLayoutFileName(), $this->getHtmlTemplateFileName() ); }
php
public function getHtmlMessageBody(ParserInterface $parser) { return $this->getMessageBody( $parser, $this->getHtmlMessage(), $this->getHtmlLayoutFileName(), $this->getHtmlTemplateFileName() ); }
[ "public", "function", "getHtmlMessageBody", "(", "ParserInterface", "$", "parser", ")", "{", "return", "$", "this", "->", "getMessageBody", "(", "$", "parser", ",", "$", "this", "->", "getHtmlMessage", "(", ")", ",", "$", "this", "->", "getHtmlLayoutFileName",...
Get the HTML message body
[ "Get", "the", "HTML", "message", "body" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Message.php#L125-L133
train
thelia/core
lib/Thelia/Model/Message.php
Message.getTextMessageBody
public function getTextMessageBody(ParserInterface $parser) { $message = $this->getMessageBody( $parser, $this->getTextMessage(), $this->getTextLayoutFileName(), $this->getTextTemplateFileName(), true // Do not compress the output, and keep empty lines. ); // Replaced all <br> by newlines. return preg_replace("/<br>/i", "\n", $message); }
php
public function getTextMessageBody(ParserInterface $parser) { $message = $this->getMessageBody( $parser, $this->getTextMessage(), $this->getTextLayoutFileName(), $this->getTextTemplateFileName(), true // Do not compress the output, and keep empty lines. ); // Replaced all <br> by newlines. return preg_replace("/<br>/i", "\n", $message); }
[ "public", "function", "getTextMessageBody", "(", "ParserInterface", "$", "parser", ")", "{", "$", "message", "=", "$", "this", "->", "getMessageBody", "(", "$", "parser", ",", "$", "this", "->", "getTextMessage", "(", ")", ",", "$", "this", "->", "getTextL...
Get the TEXT message body
[ "Get", "the", "TEXT", "message", "body" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Message.php#L138-L150
train
thelia/core
lib/Thelia/Model/Message.php
Message.buildMessage
public function buildMessage(ParserInterface $parser, \Swift_Message $messageInstance, $useFallbackTemplate = true) { // Set mail template, and save the current template $parser->pushTemplateDefinition( $parser->getTemplateHelper()->getActiveMailTemplate(), $useFallbackTemplate ); $subject = $parser->renderString($this->getSubject()); $htmlMessage = $this->getHtmlMessageBody($parser); $textMessage = $this->getTextMessageBody($parser); $messageInstance->setSubject($subject); // If we do not have an HTML message if (empty($htmlMessage)) { // Message body is the text message $messageInstance->setBody($textMessage, 'text/plain'); } else { // The main body is the HTML messahe $messageInstance->setBody($htmlMessage, 'text/html'); // Use the text as a message part, if we have one. if (! empty($textMessage)) { $messageInstance->addPart($textMessage, 'text/plain'); } } // Restore previous template $parser->popTemplateDefinition(); return $messageInstance; }
php
public function buildMessage(ParserInterface $parser, \Swift_Message $messageInstance, $useFallbackTemplate = true) { // Set mail template, and save the current template $parser->pushTemplateDefinition( $parser->getTemplateHelper()->getActiveMailTemplate(), $useFallbackTemplate ); $subject = $parser->renderString($this->getSubject()); $htmlMessage = $this->getHtmlMessageBody($parser); $textMessage = $this->getTextMessageBody($parser); $messageInstance->setSubject($subject); // If we do not have an HTML message if (empty($htmlMessage)) { // Message body is the text message $messageInstance->setBody($textMessage, 'text/plain'); } else { // The main body is the HTML messahe $messageInstance->setBody($htmlMessage, 'text/html'); // Use the text as a message part, if we have one. if (! empty($textMessage)) { $messageInstance->addPart($textMessage, 'text/plain'); } } // Restore previous template $parser->popTemplateDefinition(); return $messageInstance; }
[ "public", "function", "buildMessage", "(", "ParserInterface", "$", "parser", ",", "\\", "Swift_Message", "$", "messageInstance", ",", "$", "useFallbackTemplate", "=", "true", ")", "{", "// Set mail template, and save the current template", "$", "parser", "->", "pushTemp...
Add a subject and a body (TEXT, HTML or both, depending on the message configuration. @param ParserInterface $parser @param \Swift_Message $messageInstance @param bool $useFallbackTemplate When we send mail from a module and don't use the `default` email template, if the file (html/txt) is not found in the template then the template file located in the module under `templates/email/default/' directory is used if `$useFallbackTemplate` is set to `true`. @return \Swift_Message @throws \SmartyException
[ "Add", "a", "subject", "and", "a", "body", "(", "TEXT", "HTML", "or", "both", "depending", "on", "the", "message", "configuration", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Message.php#L166-L198
train
melisplatform/melis-cms
src/Controller/PlatformController.php
PlatformController.renderPlatformModalContentAction
public function renderPlatformModalContentAction() { $pids_id = $this->params()->fromQuery('id'); // Get Cms Platform ID form from App Tool $melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig'); $genericPlatformForm = $melisMelisCoreConfig->getFormMergedAndOrdered('meliscms/tools/meliscms_platform_tool/forms/meliscms_tool_platform_generic_form', 'meliscms_tool_platform_generic_form'); // Factoring Calendar event and pass to view $factory = new \Zend\Form\Factory(); $formElements = $this->serviceLocator->get('FormElementManager'); $factory->setFormElementManager($formElements); $propertyForm = $factory->createForm($genericPlatformForm); $view = new ViewModel(); $melisEngineTablePlatformIds = $this->getServiceLocator()->get('MelisEngineTablePlatformIds'); $availablePlatform = $melisEngineTablePlatformIds->getAvailablePlatforms()->toArray(); // Check if Cms Platform Id is Set if (!empty($pids_id)) { // Get Platform ID Details $platformIdsData = $melisEngineTablePlatformIds->getEntryById($pids_id); $platformIdsData = $platformIdsData->current(); $platformTable = $this->getServiceLocator()->get('MelisCoreTablePlatform'); $platformData = $platformTable->getEntryById($pids_id); $platformData = $platformData->current(); // Assign Platform name to Element Name of the Form from the App Tool $platformIdsData->pids_name_input = $platformData->plf_name; // Removing Select input $propertyForm->remove('pids_name_select'); // Binding datas to the Form $propertyForm->bind($platformIdsData); // Set variable to View $view->pids_id = $pids_id; $view->tabTitle = 'tr_meliscms_tool_platform_ids_btn_edit'; } else { // Removing Id input and Platform input $propertyForm->remove('pids_id'); $propertyForm->remove('pids_name_input'); // Set variable to View $view->tabTitle = 'tr_meliscms_tool_platform_ids_btn_add'; } $view->setVariable('meliscms_tool_platform_generic_form', $propertyForm); $view->setVariable('available_platform', $availablePlatform); $view->melisKey = $this->params()->fromRoute('melisKey', ''); return $view; }
php
public function renderPlatformModalContentAction() { $pids_id = $this->params()->fromQuery('id'); // Get Cms Platform ID form from App Tool $melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig'); $genericPlatformForm = $melisMelisCoreConfig->getFormMergedAndOrdered('meliscms/tools/meliscms_platform_tool/forms/meliscms_tool_platform_generic_form', 'meliscms_tool_platform_generic_form'); // Factoring Calendar event and pass to view $factory = new \Zend\Form\Factory(); $formElements = $this->serviceLocator->get('FormElementManager'); $factory->setFormElementManager($formElements); $propertyForm = $factory->createForm($genericPlatformForm); $view = new ViewModel(); $melisEngineTablePlatformIds = $this->getServiceLocator()->get('MelisEngineTablePlatformIds'); $availablePlatform = $melisEngineTablePlatformIds->getAvailablePlatforms()->toArray(); // Check if Cms Platform Id is Set if (!empty($pids_id)) { // Get Platform ID Details $platformIdsData = $melisEngineTablePlatformIds->getEntryById($pids_id); $platformIdsData = $platformIdsData->current(); $platformTable = $this->getServiceLocator()->get('MelisCoreTablePlatform'); $platformData = $platformTable->getEntryById($pids_id); $platformData = $platformData->current(); // Assign Platform name to Element Name of the Form from the App Tool $platformIdsData->pids_name_input = $platformData->plf_name; // Removing Select input $propertyForm->remove('pids_name_select'); // Binding datas to the Form $propertyForm->bind($platformIdsData); // Set variable to View $view->pids_id = $pids_id; $view->tabTitle = 'tr_meliscms_tool_platform_ids_btn_edit'; } else { // Removing Id input and Platform input $propertyForm->remove('pids_id'); $propertyForm->remove('pids_name_input'); // Set variable to View $view->tabTitle = 'tr_meliscms_tool_platform_ids_btn_add'; } $view->setVariable('meliscms_tool_platform_generic_form', $propertyForm); $view->setVariable('available_platform', $availablePlatform); $view->melisKey = $this->params()->fromRoute('melisKey', ''); return $view; }
[ "public", "function", "renderPlatformModalContentAction", "(", ")", "{", "$", "pids_id", "=", "$", "this", "->", "params", "(", ")", "->", "fromQuery", "(", "'id'", ")", ";", "// Get Cms Platform ID form from App Tool", "$", "melisMelisCoreConfig", "=", "$", "thi...
Render Platform Content Modal @return ViewModel
[ "Render", "Platform", "Content", "Modal" ]
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/PlatformController.php#L143-L194
train
melisplatform/melis-cms
src/Controller/PlatformController.php
PlatformController.getPlatformList
public function getPlatformList() { $success = 0; $data = array(); if($this->getRequest()->isPost()){ $success = 0; $platform = $this->getServiceLocator()->get("Melisplatform"); $data = $platform->getPlatformList(); } return $data; }
php
public function getPlatformList() { $success = 0; $data = array(); if($this->getRequest()->isPost()){ $success = 0; $platform = $this->getServiceLocator()->get("Melisplatform"); $data = $platform->getPlatformList(); } return $data; }
[ "public", "function", "getPlatformList", "(", ")", "{", "$", "success", "=", "0", ";", "$", "data", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "getRequest", "(", ")", "->", "isPost", "(", ")", ")", "{", "$", "success", "=", "0", ...
Return list of platform return array
[ "Return", "list", "of", "platform" ]
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/PlatformController.php#L201-L214
train
thelia/core
lib/Thelia/Handler/ExportHandler.php
ExportHandler.getExport
public function getExport($exportId, $dispatchException = false) { $export = (new ExportQuery)->findPk($exportId); if ($export === null && $dispatchException) { throw new \ErrorException( Translator::getInstance()->trans( 'There is no id "%id" in the exports', [ '%id' => $exportId ] ) ); } return $export; }
php
public function getExport($exportId, $dispatchException = false) { $export = (new ExportQuery)->findPk($exportId); if ($export === null && $dispatchException) { throw new \ErrorException( Translator::getInstance()->trans( 'There is no id "%id" in the exports', [ '%id' => $exportId ] ) ); } return $export; }
[ "public", "function", "getExport", "(", "$", "exportId", ",", "$", "dispatchException", "=", "false", ")", "{", "$", "export", "=", "(", "new", "ExportQuery", ")", "->", "findPk", "(", "$", "exportId", ")", ";", "if", "(", "$", "export", "===", "null",...
Get export model based on given identifier @param integer $exportId An export identifier @param boolean $dispatchException Dispatch exception if model doesn't exist @throws \ErrorException @return null|\Thelia\Model\Export
[ "Get", "export", "model", "based", "on", "given", "identifier" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Handler/ExportHandler.php#L65-L81
train
thelia/core
lib/Thelia/Handler/ExportHandler.php
ExportHandler.getExportByRef
public function getExportByRef($exportRef, $dispatchException = false) { $export = (new ExportQuery)->findOneByRef($exportRef); if ($export === null && $dispatchException) { throw new \ErrorException( Translator::getInstance()->trans( 'There is no ref "%ref" in the exports', [ '%ref' => $exportRef ] ) ); } return $export; }
php
public function getExportByRef($exportRef, $dispatchException = false) { $export = (new ExportQuery)->findOneByRef($exportRef); if ($export === null && $dispatchException) { throw new \ErrorException( Translator::getInstance()->trans( 'There is no ref "%ref" in the exports', [ '%ref' => $exportRef ] ) ); } return $export; }
[ "public", "function", "getExportByRef", "(", "$", "exportRef", ",", "$", "dispatchException", "=", "false", ")", "{", "$", "export", "=", "(", "new", "ExportQuery", ")", "->", "findOneByRef", "(", "$", "exportRef", ")", ";", "if", "(", "$", "export", "==...
Get export model based on given reference @param string $exportRef An export reference @param boolean $dispatchException Dispatch exception if model doesn't exist @throws \ErrorException @return null|\Thelia\Model\Export
[ "Get", "export", "model", "based", "on", "given", "reference" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Handler/ExportHandler.php#L93-L109
train
thelia/core
lib/Thelia/Handler/ExportHandler.php
ExportHandler.getCategory
public function getCategory($exportCategoryId, $dispatchException = false) { $category = (new ExportCategoryQuery)->findPk($exportCategoryId); if ($category === null && $dispatchException) { throw new \ErrorException( Translator::getInstance()->trans( 'There is no id "%id" in the export categories', [ '%id' => $exportCategoryId ] ) ); } return $category; }
php
public function getCategory($exportCategoryId, $dispatchException = false) { $category = (new ExportCategoryQuery)->findPk($exportCategoryId); if ($category === null && $dispatchException) { throw new \ErrorException( Translator::getInstance()->trans( 'There is no id "%id" in the export categories', [ '%id' => $exportCategoryId ] ) ); } return $category; }
[ "public", "function", "getCategory", "(", "$", "exportCategoryId", ",", "$", "dispatchException", "=", "false", ")", "{", "$", "category", "=", "(", "new", "ExportCategoryQuery", ")", "->", "findPk", "(", "$", "exportCategoryId", ")", ";", "if", "(", "$", ...
Get export category model based on given identifier @param integer $exportCategoryId An export category identifier @param boolean $dispatchException Dispatch exception if model doesn't exist @throws \ErrorException @return null|\Thelia\Model\ExportCategory
[ "Get", "export", "category", "model", "based", "on", "given", "identifier" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Handler/ExportHandler.php#L121-L137
train
thelia/core
lib/Thelia/Handler/ExportHandler.php
ExportHandler.processExportImages
protected function processExportImages(AbstractExport $export, ArchiverInterface $archiver) { foreach ($export->getImagesPaths() as $imagePath) { $archiver->add($imagePath); } }
php
protected function processExportImages(AbstractExport $export, ArchiverInterface $archiver) { foreach ($export->getImagesPaths() as $imagePath) { $archiver->add($imagePath); } }
[ "protected", "function", "processExportImages", "(", "AbstractExport", "$", "export", ",", "ArchiverInterface", "$", "archiver", ")", "{", "foreach", "(", "$", "export", "->", "getImagesPaths", "(", ")", "as", "$", "imagePath", ")", "{", "$", "archiver", "->",...
Add images to archive @param \Thelia\ImportExport\Export\AbstractExport $export An export instance @param \Thelia\Core\Archiver\ArchiverInterface $archiver
[ "Add", "images", "to", "archive" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Handler/ExportHandler.php#L283-L288
train
thelia/core
lib/Thelia/Handler/ExportHandler.php
ExportHandler.processExportDocuments
protected function processExportDocuments(AbstractExport $export, ArchiverInterface $archiver) { foreach ($export->getDocumentsPaths() as $documentPath) { $archiver->add($documentPath); } }
php
protected function processExportDocuments(AbstractExport $export, ArchiverInterface $archiver) { foreach ($export->getDocumentsPaths() as $documentPath) { $archiver->add($documentPath); } }
[ "protected", "function", "processExportDocuments", "(", "AbstractExport", "$", "export", ",", "ArchiverInterface", "$", "archiver", ")", "{", "foreach", "(", "$", "export", "->", "getDocumentsPaths", "(", ")", "as", "$", "documentPath", ")", "{", "$", "archiver"...
Add documents to archive @param \Thelia\ImportExport\Export\AbstractExport $export An export instance @param \Thelia\Core\Archiver\ArchiverInterface $archiver
[ "Add", "documents", "to", "archive" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Handler/ExportHandler.php#L296-L301
train
thelia/core
lib/Thelia/Core/Template/Element/BaseI18nLoop.php
BaseI18nLoop.configureI18nProcessing
protected function configureI18nProcessing( ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID', $forceReturn = false ) { /* manage translations */ $this->locale = ModelCriteriaTools::getI18n( $this->getBackendContext(), $this->getLang(), $search, $this->getCurrentRequest()->getSession()->getLang()->getLocale(), $columns, $foreignTable, $foreignKey, $this->getForceReturn() ); }
php
protected function configureI18nProcessing( ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID', $forceReturn = false ) { /* manage translations */ $this->locale = ModelCriteriaTools::getI18n( $this->getBackendContext(), $this->getLang(), $search, $this->getCurrentRequest()->getSession()->getLang()->getLocale(), $columns, $foreignTable, $foreignKey, $this->getForceReturn() ); }
[ "protected", "function", "configureI18nProcessing", "(", "ModelCriteria", "$", "search", ",", "$", "columns", "=", "array", "(", "'TITLE'", ",", "'CHAPO'", ",", "'DESCRIPTION'", ",", "'POSTSCRIPTUM'", ")", ",", "$", "foreignTable", "=", "null", ",", "$", "fore...
Setup ModelCriteria for proper i18n processing @param ModelCriteria $search the Propel Criteria to configure @param array $columns the i18n columns @param string $foreignTable the specified table (default to criteria table) @param string $foreignKey the foreign key in this table (default to criteria table) @param bool $forceReturn @return mixed the locale
[ "Setup", "ModelCriteria", "for", "proper", "i18n", "processing" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Template/Element/BaseI18nLoop.php#L58-L77
train
grom358/pharborist
src/Types/ArrayNode.php
ArrayNode.isMultidimensional
public function isMultidimensional() { foreach ($this->elements->getItems() as $element) { if ($element instanceof ArrayPairNode) { if ($element->getValue() instanceof ArrayNode) { return TRUE; } } elseif ($element instanceof ArrayNode) { return TRUE; } } return FALSE; }
php
public function isMultidimensional() { foreach ($this->elements->getItems() as $element) { if ($element instanceof ArrayPairNode) { if ($element->getValue() instanceof ArrayNode) { return TRUE; } } elseif ($element instanceof ArrayNode) { return TRUE; } } return FALSE; }
[ "public", "function", "isMultidimensional", "(", ")", "{", "foreach", "(", "$", "this", "->", "elements", "->", "getItems", "(", ")", "as", "$", "element", ")", "{", "if", "(", "$", "element", "instanceof", "ArrayPairNode", ")", "{", "if", "(", "$", "e...
Tests if the array contains another array. @return boolean
[ "Tests", "if", "the", "array", "contains", "another", "array", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Types/ArrayNode.php#L43-L55
train
grom358/pharborist
src/Types/ArrayNode.php
ArrayNode.toValue
public function toValue() { $ret = array(); foreach ($this->elements->getItems() as $element) { if ($element instanceof ArrayNode) { $ref[] = $element->toValue(); } elseif ($element instanceof ArrayPairNode) { $key = $element->getKey(); $value = $element->getValue(); $value_convertable = $value instanceof ScalarNode || $value instanceof ArrayNode; if (!($key instanceof ScalarNode && $value_convertable)) { throw new \BadMethodCallException('Can only convert scalar arrays.'); } $ret[$key->toValue()] = $value->toValue(); } elseif ($element instanceof ScalarNode || $element instanceof ArrayNode) { /** @var ScalarNode|ArrayNode $element */ $ret[] = $element->toValue(); } else { throw new \BadMethodCallException('Can only convert scalar arrays.'); } } return $ret; }
php
public function toValue() { $ret = array(); foreach ($this->elements->getItems() as $element) { if ($element instanceof ArrayNode) { $ref[] = $element->toValue(); } elseif ($element instanceof ArrayPairNode) { $key = $element->getKey(); $value = $element->getValue(); $value_convertable = $value instanceof ScalarNode || $value instanceof ArrayNode; if (!($key instanceof ScalarNode && $value_convertable)) { throw new \BadMethodCallException('Can only convert scalar arrays.'); } $ret[$key->toValue()] = $value->toValue(); } elseif ($element instanceof ScalarNode || $element instanceof ArrayNode) { /** @var ScalarNode|ArrayNode $element */ $ret[] = $element->toValue(); } else { throw new \BadMethodCallException('Can only convert scalar arrays.'); } } return $ret; }
[ "public", "function", "toValue", "(", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "elements", "->", "getItems", "(", ")", "as", "$", "element", ")", "{", "if", "(", "$", "element", "instanceof", "ArrayNode", ...
Convert to PHP array. @return array Array of scalars. @throws \BadMethodCallException Thrown if array contains non scalar elements.
[ "Convert", "to", "PHP", "array", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Types/ArrayNode.php#L66-L90
train
grom358/pharborist
src/Types/ArrayNode.php
ArrayNode.hasKey
public function hasKey($key, $recursive = TRUE) { if (!($key instanceof ExpressionNode) && !is_scalar($key)) { throw new \InvalidArgumentException(); } $keys = $this->getKeys($recursive); if (is_scalar($key)) { return $keys ->filter(Filter::isInstanceOf('\Pharborist\Types\ScalarNode')) ->is(function(ScalarNode $node) use ($key) { return $node->toValue() === $key; }); } else { return $keys ->is(function(ExpressionNode $expr) use ($key) { return $expr->getText() === $key->getText(); }); } }
php
public function hasKey($key, $recursive = TRUE) { if (!($key instanceof ExpressionNode) && !is_scalar($key)) { throw new \InvalidArgumentException(); } $keys = $this->getKeys($recursive); if (is_scalar($key)) { return $keys ->filter(Filter::isInstanceOf('\Pharborist\Types\ScalarNode')) ->is(function(ScalarNode $node) use ($key) { return $node->toValue() === $key; }); } else { return $keys ->is(function(ExpressionNode $expr) use ($key) { return $expr->getText() === $key->getText(); }); } }
[ "public", "function", "hasKey", "(", "$", "key", ",", "$", "recursive", "=", "TRUE", ")", "{", "if", "(", "!", "(", "$", "key", "instanceof", "ExpressionNode", ")", "&&", "!", "is_scalar", "(", "$", "key", ")", ")", "{", "throw", "new", "\\", "Inva...
Returns if the array has a specific key. @param mixed $key Either a scalar value ('foo') or an ExpressionNode representing the key. If $key is an ExpressionNode, the key's string representation is compared with the string representations of the array keys. Otherwise, the actual value is compared. @param boolean $recursive Whether or not to check every level of the array. @return boolean @throws \InvalidArgumentException
[ "Returns", "if", "the", "array", "has", "a", "specific", "key", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Types/ArrayNode.php#L107-L126
train
grom358/pharborist
src/Types/ArrayNode.php
ArrayNode.getKeys
public function getKeys($recursive = TRUE) { $keys = new NodeCollection(); $index = 0; foreach ($this->elements->getItems() as $element) { if ($element instanceof ArrayPairNode) { $keys->add($element->getKey()); $value = $element->getValue(); } else { $keys->add(Token::integer($index++)); $value = $element; } if ($recursive && $value instanceof ArrayNode) { $keys->add($value->getKeys($recursive)); } } return $keys; }
php
public function getKeys($recursive = TRUE) { $keys = new NodeCollection(); $index = 0; foreach ($this->elements->getItems() as $element) { if ($element instanceof ArrayPairNode) { $keys->add($element->getKey()); $value = $element->getValue(); } else { $keys->add(Token::integer($index++)); $value = $element; } if ($recursive && $value instanceof ArrayNode) { $keys->add($value->getKeys($recursive)); } } return $keys; }
[ "public", "function", "getKeys", "(", "$", "recursive", "=", "TRUE", ")", "{", "$", "keys", "=", "new", "NodeCollection", "(", ")", ";", "$", "index", "=", "0", ";", "foreach", "(", "$", "this", "->", "elements", "->", "getItems", "(", ")", "as", "...
Get the keys of the array. @param boolean $recursive (optional) TRUE to get keys of array elements that are also arrays. @return NodeCollection
[ "Get", "the", "keys", "of", "the", "array", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Types/ArrayNode.php#L136-L154
train
grom358/pharborist
src/Types/ArrayNode.php
ArrayNode.getValues
public function getValues($recursive = TRUE) { $values = new NodeCollection(); foreach ($this->elements->getItems() as $element) { if ($element instanceof ArrayPairNode) { $value = $element->getValue(); if ($recursive && $value instanceof ArrayNode) { $values->add($value->getValues($recursive)); } else { $values->add($value); } } else { $values->add($element); } } return $values; }
php
public function getValues($recursive = TRUE) { $values = new NodeCollection(); foreach ($this->elements->getItems() as $element) { if ($element instanceof ArrayPairNode) { $value = $element->getValue(); if ($recursive && $value instanceof ArrayNode) { $values->add($value->getValues($recursive)); } else { $values->add($value); } } else { $values->add($element); } } return $values; }
[ "public", "function", "getValues", "(", "$", "recursive", "=", "TRUE", ")", "{", "$", "values", "=", "new", "NodeCollection", "(", ")", ";", "foreach", "(", "$", "this", "->", "elements", "->", "getItems", "(", ")", "as", "$", "element", ")", "{", "i...
Get the values of the array. @param boolean $recursive (optional) TRUE to get values of array elements that are also arrays. @return NodeCollection
[ "Get", "the", "values", "of", "the", "array", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Types/ArrayNode.php#L164-L181
train
thelia/core
lib/Thelia/Controller/Admin/ExportController.php
ExportController.configureAction
public function configureAction($id) { /** @var \Thelia\Handler\Exporthandler $exportHandler */ $exportHandler = $this->container->get('thelia.export.handler'); $export = $exportHandler->getExport($id); if ($export === null) { return $this->pageNotFound(); } // Render standard view or ajax one $templateName = 'export-page'; if ($this->getRequest()->isXmlHttpRequest()) { $templateName = 'ajax/export-modal'; } return $this->render( $templateName, [ 'exportId' => $id, 'hasImages' => $export->hasImages(), 'hasDocuments' => $export->hasDocuments(), 'useRange' => $export->useRangeDate() ] ); }
php
public function configureAction($id) { /** @var \Thelia\Handler\Exporthandler $exportHandler */ $exportHandler = $this->container->get('thelia.export.handler'); $export = $exportHandler->getExport($id); if ($export === null) { return $this->pageNotFound(); } // Render standard view or ajax one $templateName = 'export-page'; if ($this->getRequest()->isXmlHttpRequest()) { $templateName = 'ajax/export-modal'; } return $this->render( $templateName, [ 'exportId' => $id, 'hasImages' => $export->hasImages(), 'hasDocuments' => $export->hasDocuments(), 'useRange' => $export->useRangeDate() ] ); }
[ "public", "function", "configureAction", "(", "$", "id", ")", "{", "/** @var \\Thelia\\Handler\\Exporthandler $exportHandler */", "$", "exportHandler", "=", "$", "this", "->", "container", "->", "get", "(", "'thelia.export.handler'", ")", ";", "$", "export", "=", "$...
Display export configuration view @param integer $id An export identifier @return \Thelia\Core\HttpFoundation\Response
[ "Display", "export", "configuration", "view" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/ExportController.php#L134-L159
train
thelia/core
lib/Thelia/Controller/Admin/ExportController.php
ExportController.exportAction
public function exportAction($id) { /** @var \Thelia\Handler\Exporthandler $exportHandler */ $exportHandler = $this->container->get('thelia.export.handler'); $export = $exportHandler->getExport($id); if ($export === null) { return $this->pageNotFound(); } $form = $this->createForm(AdminForm::EXPORT); try { $validatedForm = $this->validateForm($form); set_time_limit(0); $lang = (new LangQuery)->findPk($validatedForm->get('language')->getData()); /** @var \Thelia\Core\Serializer\SerializerManager $serializerManager */ $serializerManager = $this->container->get(RegisterSerializerPass::MANAGER_SERVICE_ID); $serializer = $serializerManager->get($validatedForm->get('serializer')->getData()); $archiver = null; if ($validatedForm->get('do_compress')->getData()) { /** @var \Thelia\Core\Archiver\ArchiverManager $archiverManager */ $archiverManager = $this->container->get(RegisterArchiverPass::MANAGER_SERVICE_ID); $archiver = $archiverManager->get($validatedForm->get('archiver')->getData()); } $rangeDate = null; if ($validatedForm->get('range_date_start')->getData() && $validatedForm->get('range_date_end')->getData() ) { $rangeDate = [ 'start' => $validatedForm->get('range_date_start')->getData(), 'end' =>$validatedForm->get('range_date_end')->getData() ]; } $exportEvent = $exportHandler->export( $export, $serializer, $archiver, $lang, $validatedForm->get('images')->getData(), $validatedForm->get('documents')->getData(), $rangeDate ); $contentType = $exportEvent->getSerializer()->getMimeType(); $fileExt = $exportEvent->getSerializer()->getExtension(); if ($exportEvent->getArchiver() !== null) { $contentType = $exportEvent->getArchiver()->getMimeType(); $fileExt = $exportEvent->getArchiver()->getExtension(); } $header = [ 'Content-Type' => $contentType, 'Content-Disposition' => sprintf( '%s; filename="%s.%s"', ResponseHeaderBag::DISPOSITION_ATTACHMENT, $exportEvent->getExport()->getFileName(), $fileExt ) ]; return new BinaryFileResponse($exportEvent->getFilePath(), 200, $header, false); } catch (FormValidationException $e) { $form->setErrorMessage($this->createStandardFormValidationErrorMessage($e)); } catch (\Exception $e) { $this->getParserContext()->setGeneralError($e->getMessage()); } $this->getParserContext() ->addForm($form) ; return $this->configureAction($id); }
php
public function exportAction($id) { /** @var \Thelia\Handler\Exporthandler $exportHandler */ $exportHandler = $this->container->get('thelia.export.handler'); $export = $exportHandler->getExport($id); if ($export === null) { return $this->pageNotFound(); } $form = $this->createForm(AdminForm::EXPORT); try { $validatedForm = $this->validateForm($form); set_time_limit(0); $lang = (new LangQuery)->findPk($validatedForm->get('language')->getData()); /** @var \Thelia\Core\Serializer\SerializerManager $serializerManager */ $serializerManager = $this->container->get(RegisterSerializerPass::MANAGER_SERVICE_ID); $serializer = $serializerManager->get($validatedForm->get('serializer')->getData()); $archiver = null; if ($validatedForm->get('do_compress')->getData()) { /** @var \Thelia\Core\Archiver\ArchiverManager $archiverManager */ $archiverManager = $this->container->get(RegisterArchiverPass::MANAGER_SERVICE_ID); $archiver = $archiverManager->get($validatedForm->get('archiver')->getData()); } $rangeDate = null; if ($validatedForm->get('range_date_start')->getData() && $validatedForm->get('range_date_end')->getData() ) { $rangeDate = [ 'start' => $validatedForm->get('range_date_start')->getData(), 'end' =>$validatedForm->get('range_date_end')->getData() ]; } $exportEvent = $exportHandler->export( $export, $serializer, $archiver, $lang, $validatedForm->get('images')->getData(), $validatedForm->get('documents')->getData(), $rangeDate ); $contentType = $exportEvent->getSerializer()->getMimeType(); $fileExt = $exportEvent->getSerializer()->getExtension(); if ($exportEvent->getArchiver() !== null) { $contentType = $exportEvent->getArchiver()->getMimeType(); $fileExt = $exportEvent->getArchiver()->getExtension(); } $header = [ 'Content-Type' => $contentType, 'Content-Disposition' => sprintf( '%s; filename="%s.%s"', ResponseHeaderBag::DISPOSITION_ATTACHMENT, $exportEvent->getExport()->getFileName(), $fileExt ) ]; return new BinaryFileResponse($exportEvent->getFilePath(), 200, $header, false); } catch (FormValidationException $e) { $form->setErrorMessage($this->createStandardFormValidationErrorMessage($e)); } catch (\Exception $e) { $this->getParserContext()->setGeneralError($e->getMessage()); } $this->getParserContext() ->addForm($form) ; return $this->configureAction($id); }
[ "public", "function", "exportAction", "(", "$", "id", ")", "{", "/** @var \\Thelia\\Handler\\Exporthandler $exportHandler */", "$", "exportHandler", "=", "$", "this", "->", "container", "->", "get", "(", "'thelia.export.handler'", ")", ";", "$", "export", "=", "$", ...
Handle export action @param integer $id An export identifier @return \Thelia\Core\HttpFoundation\Response|\Symfony\Component\HttpFoundation\BinaryFileResponse
[ "Handle", "export", "action" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/ExportController.php#L168-L248
train
grom358/pharborist
src/TokenIterator.php
TokenIterator.current
public function current() { if ($this->position >= $this->length) { return NULL; } return $this->tokens[$this->position]; }
php
public function current() { if ($this->position >= $this->length) { return NULL; } return $this->tokens[$this->position]; }
[ "public", "function", "current", "(", ")", "{", "if", "(", "$", "this", "->", "position", ">=", "$", "this", "->", "length", ")", "{", "return", "NULL", ";", "}", "return", "$", "this", "->", "tokens", "[", "$", "this", "->", "position", "]", ";", ...
Return the current token. @return TokenNode
[ "Return", "the", "current", "token", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/TokenIterator.php#L39-L44
train
grom358/pharborist
src/TokenIterator.php
TokenIterator.peek
public function peek($offset) { if ($this->position + $offset >= $this->length) { return NULL; } return $this->tokens[$this->position + $offset]; }
php
public function peek($offset) { if ($this->position + $offset >= $this->length) { return NULL; } return $this->tokens[$this->position + $offset]; }
[ "public", "function", "peek", "(", "$", "offset", ")", "{", "if", "(", "$", "this", "->", "position", "+", "$", "offset", ">=", "$", "this", "->", "length", ")", "{", "return", "NULL", ";", "}", "return", "$", "this", "->", "tokens", "[", "$", "t...
Peek ahead. @param int $offset Offset from current position. @return TokenNode
[ "Peek", "ahead", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/TokenIterator.php#L51-L56
train
grom358/pharborist
src/TokenIterator.php
TokenIterator.next
public function next() { $this->position++; if ($this->position >= $this->length) { $this->position = $this->length; return NULL; } return $this->tokens[$this->position]; }
php
public function next() { $this->position++; if ($this->position >= $this->length) { $this->position = $this->length; return NULL; } return $this->tokens[$this->position]; }
[ "public", "function", "next", "(", ")", "{", "$", "this", "->", "position", "++", ";", "if", "(", "$", "this", "->", "position", ">=", "$", "this", "->", "length", ")", "{", "$", "this", "->", "position", "=", "$", "this", "->", "length", ";", "r...
Move to the next token and return it. @return TokenNode
[ "Move", "to", "the", "next", "token", "and", "return", "it", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/TokenIterator.php#L62-L69
train
NotifyMeHQ/notifyme
src/Adapters/Yo/YoFactory.php
YoFactory.make
public function make(array $config) { Arr::requires($config, ['token']); $client = new Client(); return new YoGateway($client, $config); }
php
public function make(array $config) { Arr::requires($config, ['token']); $client = new Client(); return new YoGateway($client, $config); }
[ "public", "function", "make", "(", "array", "$", "config", ")", "{", "Arr", "::", "requires", "(", "$", "config", ",", "[", "'token'", "]", ")", ";", "$", "client", "=", "new", "Client", "(", ")", ";", "return", "new", "YoGateway", "(", "$", "clien...
Create a new yo gateway instance. @param string[] $config @return \NotifyMeHQ\Adapters\Yo\YoGateway
[ "Create", "a", "new", "yo", "gateway", "instance", "." ]
2af4bdcfe9df6db7ea79e2dce90b106ccb285b06
https://github.com/NotifyMeHQ/notifyme/blob/2af4bdcfe9df6db7ea79e2dce90b106ccb285b06/src/Adapters/Yo/YoFactory.php#L27-L34
train
thelia/core
lib/Thelia/Model/OrderStatus.php
OrderStatus.isNotPaid
public function isNotPaid($exact = true) { //return $this->hasStatusHelper(OrderStatus::CODE_NOT_PAID); if ($exact) { return $this->hasStatusHelper(OrderStatus::CODE_NOT_PAID); } else { return ! $this->isPaid(false); } }
php
public function isNotPaid($exact = true) { //return $this->hasStatusHelper(OrderStatus::CODE_NOT_PAID); if ($exact) { return $this->hasStatusHelper(OrderStatus::CODE_NOT_PAID); } else { return ! $this->isPaid(false); } }
[ "public", "function", "isNotPaid", "(", "$", "exact", "=", "true", ")", "{", "//return $this->hasStatusHelper(OrderStatus::CODE_NOT_PAID);", "if", "(", "$", "exact", ")", "{", "return", "$", "this", "->", "hasStatusHelper", "(", "OrderStatus", "::", "CODE_NOT_PAID",...
Check if the current status is NOT PAID @param bool $exact if true, the method will check if the current status is exactly OrderStatus::CODE_NOT_PAID. if false, it will check if the order has not been paid, whatever the exact status is. The default is true. @return bool true if NOT PAID, false otherwise.
[ "Check", "if", "the", "current", "status", "is", "NOT", "PAID" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/OrderStatus.php#L29-L37
train
thelia/core
lib/Thelia/Model/OrderStatus.php
OrderStatus.isPaid
public function isPaid($exact = true) { return $this->hasStatusHelper( $exact ? OrderStatus::CODE_PAID : [ OrderStatus::CODE_PAID, OrderStatus::CODE_PROCESSING, OrderStatus::CODE_SENT ] ); }
php
public function isPaid($exact = true) { return $this->hasStatusHelper( $exact ? OrderStatus::CODE_PAID : [ OrderStatus::CODE_PAID, OrderStatus::CODE_PROCESSING, OrderStatus::CODE_SENT ] ); }
[ "public", "function", "isPaid", "(", "$", "exact", "=", "true", ")", "{", "return", "$", "this", "->", "hasStatusHelper", "(", "$", "exact", "?", "OrderStatus", "::", "CODE_PAID", ":", "[", "OrderStatus", "::", "CODE_PAID", ",", "OrderStatus", "::", "CODE_...
Check if the current status is PAID @param bool $exact if true, the method will check if the current status is exactly OrderStatus::CODE_PAID. if false, it will check if the order has been paid, whatever the exact status is. The default is true. @return bool true if PAID, false otherwise.
[ "Check", "if", "the", "current", "status", "is", "PAID" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/OrderStatus.php#L47-L54
train
BoldGrid/library
src/Library/Api/Availability.php
Availability.checkAvailability
private function checkAvailability() { // Get the boldgrid_available transient. $available = get_site_transient( 'boldgrid_available' ); // No transient was found. $wp_http = new WP_Http(); $url = $this->getUrl(); // Check that calling server is not blocked locally. if ( $wp_http->block_request( $url ) === false ) { $available = 1; } // Update the boldgrid_available transient. set_site_transient( 'boldgrid_available', ( int ) $available, 2 * MINUTE_IN_SECONDS ); return $available; }
php
private function checkAvailability() { // Get the boldgrid_available transient. $available = get_site_transient( 'boldgrid_available' ); // No transient was found. $wp_http = new WP_Http(); $url = $this->getUrl(); // Check that calling server is not blocked locally. if ( $wp_http->block_request( $url ) === false ) { $available = 1; } // Update the boldgrid_available transient. set_site_transient( 'boldgrid_available', ( int ) $available, 2 * MINUTE_IN_SECONDS ); return $available; }
[ "private", "function", "checkAvailability", "(", ")", "{", "// Get the boldgrid_available transient.", "$", "available", "=", "get_site_transient", "(", "'boldgrid_available'", ")", ";", "// No transient was found.", "$", "wp_http", "=", "new", "WP_Http", "(", ")", ";",...
Checks that the API can be reached. @since 1.0.0 @return bool
[ "Checks", "that", "the", "API", "can", "be", "reached", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Api/Availability.php#L76-L93
train
melisplatform/melis-cms
src/Controller/TreeSitesController.php
TreeSitesController.getTreePagesByPageIdAction
public function getTreePagesByPageIdAction() { // Get the node id requested, or use default root -1 $idPage = $this->params()->fromQuery('nodeId', -1); $this->getEventManager()->trigger('melis_cms_tree_get_pages_start', $this, array('idPage' => $idPage)); if ($idPage == -1) $rootPages = $this->getRootForUser(); else $rootPages = array($idPage); $final = $this->getPagesDatas($rootPages); $triggerResponse = $this->getEventManager()->trigger('melis_cms_tree_get_pages_end', $this, array('parentId' => $idPage, 'request' => $final)); $response = null; if(isset($triggerResponse[0]) && !empty($triggerResponse[0])) $response = $this->formatTreeResponse($triggerResponse[0]); else $response = $this->formatTreeResponse($final); return $response; }
php
public function getTreePagesByPageIdAction() { // Get the node id requested, or use default root -1 $idPage = $this->params()->fromQuery('nodeId', -1); $this->getEventManager()->trigger('melis_cms_tree_get_pages_start', $this, array('idPage' => $idPage)); if ($idPage == -1) $rootPages = $this->getRootForUser(); else $rootPages = array($idPage); $final = $this->getPagesDatas($rootPages); $triggerResponse = $this->getEventManager()->trigger('melis_cms_tree_get_pages_end', $this, array('parentId' => $idPage, 'request' => $final)); $response = null; if(isset($triggerResponse[0]) && !empty($triggerResponse[0])) $response = $this->formatTreeResponse($triggerResponse[0]); else $response = $this->formatTreeResponse($final); return $response; }
[ "public", "function", "getTreePagesByPageIdAction", "(", ")", "{", "// Get the node id requested, or use default root -1", "$", "idPage", "=", "$", "this", "->", "params", "(", ")", "->", "fromQuery", "(", "'nodeId'", ",", "-", "1", ")", ";", "$", "this", "->", ...
Get the children of an idPage If called in http, will return an html view If called in xhr, will return a json view with the html and others informations like javascript datas. @return \Zend\View\Model\ViewModel|\Zend\View\Model\JsonModel
[ "Get", "the", "children", "of", "an", "idPage", "If", "called", "in", "http", "will", "return", "an", "html", "view", "If", "called", "in", "xhr", "will", "return", "a", "json", "view", "with", "the", "html", "and", "others", "informations", "like", "jav...
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/TreeSitesController.php#L31-L56
train
melisplatform/melis-cms
src/Controller/TreeSitesController.php
TreeSitesController.getTreePagesForRightsManagementAction
public function getTreePagesForRightsManagementAction() { $idPage = $this->params()->fromQuery('nodeId', -1); if ($idPage == MelisCmsRightsService::MELISCMS_PREFIX_PAGES . '_root') $idPage = -1; else $idPage = str_replace(MelisCmsRightsService::MELISCMS_PREFIX_PAGES . '_', '', $idPage); $rootPages = array($idPage); $final = $this->getPagesDatas($rootPages); return $this->formatTreeResponse($final, true); }
php
public function getTreePagesForRightsManagementAction() { $idPage = $this->params()->fromQuery('nodeId', -1); if ($idPage == MelisCmsRightsService::MELISCMS_PREFIX_PAGES . '_root') $idPage = -1; else $idPage = str_replace(MelisCmsRightsService::MELISCMS_PREFIX_PAGES . '_', '', $idPage); $rootPages = array($idPage); $final = $this->getPagesDatas($rootPages); return $this->formatTreeResponse($final, true); }
[ "public", "function", "getTreePagesForRightsManagementAction", "(", ")", "{", "$", "idPage", "=", "$", "this", "->", "params", "(", ")", "->", "fromQuery", "(", "'nodeId'", ",", "-", "1", ")", ";", "if", "(", "$", "idPage", "==", "MelisCmsRightsService", "...
Gets the root page when showing the tree of pages in rights tool so that all pages are displayed and not only the one you have access to @return Ambigous <\Zend\View\Model\ViewModel, \Zend\View\Model\JsonModel>
[ "Gets", "the", "root", "page", "when", "showing", "the", "tree", "of", "pages", "in", "rights", "tool", "so", "that", "all", "pages", "are", "displayed", "and", "not", "only", "the", "one", "you", "have", "access", "to" ]
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/TreeSitesController.php#L85-L98
train
melisplatform/melis-cms
src/Controller/TreeSitesController.php
TreeSitesController.cleanBreadcrumb
private function cleanBreadcrumb($breadcrumb) { $newArray = array(); if (!empty($breadcrumb)) foreach ($breadcrumb as $page) { if (!empty($page->tree_page_id)) array_push($newArray, $page->tree_page_id); } return $newArray; }
php
private function cleanBreadcrumb($breadcrumb) { $newArray = array(); if (!empty($breadcrumb)) foreach ($breadcrumb as $page) { if (!empty($page->tree_page_id)) array_push($newArray, $page->tree_page_id); } return $newArray; }
[ "private", "function", "cleanBreadcrumb", "(", "$", "breadcrumb", ")", "{", "$", "newArray", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "breadcrumb", ")", ")", "foreach", "(", "$", "breadcrumb", "as", "$", "page", ")", "{", "if",...
Creates a simple array with the page ids from the result of db @param array $breadcrumb @return array
[ "Creates", "a", "simple", "array", "with", "the", "page", "ids", "from", "the", "result", "of", "db" ]
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/TreeSitesController.php#L367-L379
train
melisplatform/melis-cms
src/Controller/TreeSitesController.php
TreeSitesController.getRootForUser
private function getRootForUser() { $melisEngineTree = $this->serviceLocator->get('MelisEngineTree'); $melisCoreAuth = $this->getServiceLocator()->get('MelisCoreAuth'); $melisCmsRights = $this->getServiceLocator()->get('MelisCmsRights'); // Get the rights of the user $xmlRights = $melisCoreAuth->getAuthRights(); $rightsObj = simplexml_load_string($xmlRights); $rootPages = array(); $breadcrumbRightPages = array(); // Loop into page ids of the rights to determine what are the root pages // Deleting possible doublons with parent pages selected and also children pages $sectionId = MelisCmsRightsService::MELISCMS_PREFIX_PAGES; if (empty($rightsObj->$sectionId)) return array(); foreach ($rightsObj->$sectionId->id as $rightsPageId) { $rightsPageId = (int)$rightsPageId; // No need to continue, -1 is root, there's a full access if ($rightsPageId == -1) return array(-1); // Get the breadcrumb of the page and reformat it to a more simple array $breadcrumb = $melisEngineTree->getPageBreadcrumb($rightsPageId, 0, true); $breadcrumb = $this->cleanBreadcrumb($breadcrumb); /** * Looping on the temporary array holding pages * Making intersection to compare between the one checked and those already saved * If the one checked is equal with the intersection, it means the one checked contains * already the older one, the page is on top, then we will only keep this one and delete * the old one * Otherwise we save */ $add = true; for ($i = 0; $i < count($breadcrumbRightPages); $i++) { $result = array_intersect($breadcrumb, $breadcrumbRightPages[$i]); if ($result === $breadcrumb) { $add = false; $breadcrumbRightPages[$i] = $breadcrumb; break; } if ($result === $breadcrumbRightPages[$i]) { $add = false; break; } } if ($add) $breadcrumbRightPages[count($breadcrumbRightPages)] = $breadcrumb; } /** * Reformat final result to a simple array with the ids of pages */ foreach ($breadcrumbRightPages as $breadcrumbPage) { if (count($breadcrumbPage) > 0) array_push($rootPages, $breadcrumbPage[count($breadcrumbPage) - 1]); } return $rootPages; }
php
private function getRootForUser() { $melisEngineTree = $this->serviceLocator->get('MelisEngineTree'); $melisCoreAuth = $this->getServiceLocator()->get('MelisCoreAuth'); $melisCmsRights = $this->getServiceLocator()->get('MelisCmsRights'); // Get the rights of the user $xmlRights = $melisCoreAuth->getAuthRights(); $rightsObj = simplexml_load_string($xmlRights); $rootPages = array(); $breadcrumbRightPages = array(); // Loop into page ids of the rights to determine what are the root pages // Deleting possible doublons with parent pages selected and also children pages $sectionId = MelisCmsRightsService::MELISCMS_PREFIX_PAGES; if (empty($rightsObj->$sectionId)) return array(); foreach ($rightsObj->$sectionId->id as $rightsPageId) { $rightsPageId = (int)$rightsPageId; // No need to continue, -1 is root, there's a full access if ($rightsPageId == -1) return array(-1); // Get the breadcrumb of the page and reformat it to a more simple array $breadcrumb = $melisEngineTree->getPageBreadcrumb($rightsPageId, 0, true); $breadcrumb = $this->cleanBreadcrumb($breadcrumb); /** * Looping on the temporary array holding pages * Making intersection to compare between the one checked and those already saved * If the one checked is equal with the intersection, it means the one checked contains * already the older one, the page is on top, then we will only keep this one and delete * the old one * Otherwise we save */ $add = true; for ($i = 0; $i < count($breadcrumbRightPages); $i++) { $result = array_intersect($breadcrumb, $breadcrumbRightPages[$i]); if ($result === $breadcrumb) { $add = false; $breadcrumbRightPages[$i] = $breadcrumb; break; } if ($result === $breadcrumbRightPages[$i]) { $add = false; break; } } if ($add) $breadcrumbRightPages[count($breadcrumbRightPages)] = $breadcrumb; } /** * Reformat final result to a simple array with the ids of pages */ foreach ($breadcrumbRightPages as $breadcrumbPage) { if (count($breadcrumbPage) > 0) array_push($rootPages, $breadcrumbPage[count($breadcrumbPage) - 1]); } return $rootPages; }
[ "private", "function", "getRootForUser", "(", ")", "{", "$", "melisEngineTree", "=", "$", "this", "->", "serviceLocator", "->", "get", "(", "'MelisEngineTree'", ")", ";", "$", "melisCoreAuth", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get...
Gets the root pages for a user depending on his rights @return array
[ "Gets", "the", "root", "pages", "for", "a", "user", "depending", "on", "his", "rights" ]
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/TreeSitesController.php#L385-L457
train
melisplatform/melis-cms
src/Controller/TreeSitesController.php
TreeSitesController.getPageIdBreadcrumbAction
public function getPageIdBreadcrumbAction() { $idPage = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', '')); $idPage = ($idPage == 'root')? -1 : $idPage; $includeSelf = $this->params()->fromRoute('includeSelf', $this->params()->fromQuery('includeSelf', '')); $melisEngineTree = $this->serviceLocator->get('MelisEngineTree'); $breadcrumb = $melisEngineTree->getPageBreadcrumb($idPage, 0, true); $pageFatherId = $idPage; $jsonresult = array(); if($includeSelf){ array_unshift($jsonresult, $pageFatherId); } while($pageFatherId != NULL){ $page = $melisEngineTree->getPageFather($pageFatherId, 'saved')->current(); $pageFatherId = !empty($page)? $page->tree_father_page_id : NULL; if(!empty($pageFatherId)){ array_unshift($jsonresult, $pageFatherId); } } return new JsonModel($jsonresult); }
php
public function getPageIdBreadcrumbAction() { $idPage = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', '')); $idPage = ($idPage == 'root')? -1 : $idPage; $includeSelf = $this->params()->fromRoute('includeSelf', $this->params()->fromQuery('includeSelf', '')); $melisEngineTree = $this->serviceLocator->get('MelisEngineTree'); $breadcrumb = $melisEngineTree->getPageBreadcrumb($idPage, 0, true); $pageFatherId = $idPage; $jsonresult = array(); if($includeSelf){ array_unshift($jsonresult, $pageFatherId); } while($pageFatherId != NULL){ $page = $melisEngineTree->getPageFather($pageFatherId, 'saved')->current(); $pageFatherId = !empty($page)? $page->tree_father_page_id : NULL; if(!empty($pageFatherId)){ array_unshift($jsonresult, $pageFatherId); } } return new JsonModel($jsonresult); }
[ "public", "function", "getPageIdBreadcrumbAction", "(", ")", "{", "$", "idPage", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'idPage'", ",", "$", "this", "->", "params", "(", ")", "->", "fromQuery", "(", "'idPage'", ",", "''", ...
Sends back the pageId breadcrumb @return \Zend\View\Model\JsonModel
[ "Sends", "back", "the", "pageId", "breadcrumb" ]
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/TreeSitesController.php#L514-L542
train
melisplatform/melis-cms
src/Controller/TreeSitesController.php
TreeSitesController.canEditPagesAction
public function canEditPagesAction() { $melisCoreAuth = $this->getServiceLocator()->get('MelisCoreAuth'); $xmlRights = $melisCoreAuth->getAuthRights(); $rightsObj = simplexml_load_string($xmlRights); $sectionId = MelisCmsRightsService::MELISCMS_PREFIX_PAGES; if (empty($rightsObj->$sectionId->id)) $edit = 0; else $edit = 1; $result = array( 'success' => 1, 'edit' => $edit ); return new JsonModel($result); }
php
public function canEditPagesAction() { $melisCoreAuth = $this->getServiceLocator()->get('MelisCoreAuth'); $xmlRights = $melisCoreAuth->getAuthRights(); $rightsObj = simplexml_load_string($xmlRights); $sectionId = MelisCmsRightsService::MELISCMS_PREFIX_PAGES; if (empty($rightsObj->$sectionId->id)) $edit = 0; else $edit = 1; $result = array( 'success' => 1, 'edit' => $edit ); return new JsonModel($result); }
[ "public", "function", "canEditPagesAction", "(", ")", "{", "$", "melisCoreAuth", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'MelisCoreAuth'", ")", ";", "$", "xmlRights", "=", "$", "melisCoreAuth", "->", "getAuthRights", "(", ")...
Sends back if a page can be edited by the user or not @return \Zend\View\Model\JsonModel
[ "Sends", "back", "if", "a", "page", "can", "be", "edited", "by", "the", "user", "or", "not" ]
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/TreeSitesController.php#L549-L566
train
thelia/core
lib/Thelia/Coupon/CouponManager.php
CouponManager.getDiscount
public function getDiscount() { $discount = 0.00; $coupons = $this->facade->getCurrentCoupons(); if (\count($coupons) > 0) { $couponsKept = $this->sortCoupons($coupons); $discount = $this->getEffect($couponsKept); // Just In Case test $checkoutTotalPrice = $this->facade->getCartTotalTaxPrice(); if ($discount >= $checkoutTotalPrice) { $discount = $checkoutTotalPrice; } } return $discount; }
php
public function getDiscount() { $discount = 0.00; $coupons = $this->facade->getCurrentCoupons(); if (\count($coupons) > 0) { $couponsKept = $this->sortCoupons($coupons); $discount = $this->getEffect($couponsKept); // Just In Case test $checkoutTotalPrice = $this->facade->getCartTotalTaxPrice(); if ($discount >= $checkoutTotalPrice) { $discount = $checkoutTotalPrice; } } return $discount; }
[ "public", "function", "getDiscount", "(", ")", "{", "$", "discount", "=", "0.00", ";", "$", "coupons", "=", "$", "this", "->", "facade", "->", "getCurrentCoupons", "(", ")", ";", "if", "(", "\\", "count", "(", "$", "coupons", ")", ">", "0", ")", "{...
Get Discount for the given Coupons @api @return float checkout discount
[ "Get", "Discount", "for", "the", "given", "Coupons" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Coupon/CouponManager.php#L65-L85
train
thelia/core
lib/Thelia/Coupon/CouponManager.php
CouponManager.isCouponRemovingPostage
public function isCouponRemovingPostage(Order $order) { $coupons = $this->facade->getCurrentCoupons(); if (\count($coupons) == 0) { return false; } $couponsKept = $this->sortCoupons($coupons); /** @var CouponInterface $coupon */ foreach ($couponsKept as $coupon) { if ($coupon->isRemovingPostage()) { // Check if delivery country is on the list of countries for which delivery is free // If the list is empty, the shipping is free for all countries. $couponCountries = $coupon->getFreeShippingForCountries(); if (! $couponCountries->isEmpty()) { if (null === $deliveryAddress = AddressQuery::create()->findPk($order->getChoosenDeliveryAddress())) { continue; } $countryValid = false; $deliveryCountryId = $deliveryAddress->getCountryId(); /** @var CouponCountry $couponCountry */ foreach ($couponCountries as $couponCountry) { if ($deliveryCountryId == $couponCountry->getCountryId()) { $countryValid = true; break; } } if (! $countryValid) { continue; } } // Check if shipping method is on the list of methods for which delivery is free // If the list is empty, the shipping is free for all methods. $couponModules = $coupon->getFreeShippingForModules(); if (! $couponModules->isEmpty()) { $moduleValid = false; $shippingModuleId = $order->getDeliveryModuleId(); /** @var CouponModule $couponModule */ foreach ($couponModules as $couponModule) { if ($shippingModuleId == $couponModule->getModuleId()) { $moduleValid = true; break; } } if (! $moduleValid) { continue; } } // All conditions are met, the shipping is free ! return true; } } return false; }
php
public function isCouponRemovingPostage(Order $order) { $coupons = $this->facade->getCurrentCoupons(); if (\count($coupons) == 0) { return false; } $couponsKept = $this->sortCoupons($coupons); /** @var CouponInterface $coupon */ foreach ($couponsKept as $coupon) { if ($coupon->isRemovingPostage()) { // Check if delivery country is on the list of countries for which delivery is free // If the list is empty, the shipping is free for all countries. $couponCountries = $coupon->getFreeShippingForCountries(); if (! $couponCountries->isEmpty()) { if (null === $deliveryAddress = AddressQuery::create()->findPk($order->getChoosenDeliveryAddress())) { continue; } $countryValid = false; $deliveryCountryId = $deliveryAddress->getCountryId(); /** @var CouponCountry $couponCountry */ foreach ($couponCountries as $couponCountry) { if ($deliveryCountryId == $couponCountry->getCountryId()) { $countryValid = true; break; } } if (! $countryValid) { continue; } } // Check if shipping method is on the list of methods for which delivery is free // If the list is empty, the shipping is free for all methods. $couponModules = $coupon->getFreeShippingForModules(); if (! $couponModules->isEmpty()) { $moduleValid = false; $shippingModuleId = $order->getDeliveryModuleId(); /** @var CouponModule $couponModule */ foreach ($couponModules as $couponModule) { if ($shippingModuleId == $couponModule->getModuleId()) { $moduleValid = true; break; } } if (! $moduleValid) { continue; } } // All conditions are met, the shipping is free ! return true; } } return false; }
[ "public", "function", "isCouponRemovingPostage", "(", "Order", "$", "order", ")", "{", "$", "coupons", "=", "$", "this", "->", "facade", "->", "getCurrentCoupons", "(", ")", ";", "if", "(", "\\", "count", "(", "$", "coupons", ")", "==", "0", ")", "{", ...
Check if there is a Coupon removing Postage @param Order $order the order for which we have to check if postage is free @return bool
[ "Check", "if", "there", "is", "a", "Coupon", "removing", "Postage" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Coupon/CouponManager.php#L103-L170
train
thelia/core
lib/Thelia/Coupon/CouponManager.php
CouponManager.sortCoupons
protected function sortCoupons(array $coupons) { $couponsKept = array(); /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { if ($coupon && !$coupon->isExpired()) { if ($coupon->isCumulative()) { if (isset($couponsKept[0])) { /** @var CouponInterface $previousCoupon */ $previousCoupon = $couponsKept[0]; if ($previousCoupon->isCumulative()) { // Add Coupon $couponsKept[] = $coupon; } else { // Reset Coupons, add last $couponsKept = array($coupon); } } else { // Reset Coupons, add last $couponsKept = array($coupon); } } else { // Reset Coupons, add last $couponsKept = array($coupon); } } } $coupons = $couponsKept; $couponsKept = array(); /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { try { if ($coupon->isMatching()) { $couponsKept[] = $coupon; } } catch (UnmatchableConditionException $e) { // ignore unmatchable coupon continue; } } return $couponsKept; }
php
protected function sortCoupons(array $coupons) { $couponsKept = array(); /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { if ($coupon && !$coupon->isExpired()) { if ($coupon->isCumulative()) { if (isset($couponsKept[0])) { /** @var CouponInterface $previousCoupon */ $previousCoupon = $couponsKept[0]; if ($previousCoupon->isCumulative()) { // Add Coupon $couponsKept[] = $coupon; } else { // Reset Coupons, add last $couponsKept = array($coupon); } } else { // Reset Coupons, add last $couponsKept = array($coupon); } } else { // Reset Coupons, add last $couponsKept = array($coupon); } } } $coupons = $couponsKept; $couponsKept = array(); /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { try { if ($coupon->isMatching()) { $couponsKept[] = $coupon; } } catch (UnmatchableConditionException $e) { // ignore unmatchable coupon continue; } } return $couponsKept; }
[ "protected", "function", "sortCoupons", "(", "array", "$", "coupons", ")", "{", "$", "couponsKept", "=", "array", "(", ")", ";", "/** @var CouponInterface $coupon */", "foreach", "(", "$", "coupons", "as", "$", "coupon", ")", "{", "if", "(", "$", "coupon", ...
Sort Coupon to keep Coupon not cumulative cancels previous @param array $coupons CouponInterface to process @return array Array of CouponInterface sorted
[ "Sort", "Coupon", "to", "keep", "Coupon", "not", "cumulative", "cancels", "previous" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Coupon/CouponManager.php#L188-L233
train
thelia/core
lib/Thelia/Coupon/CouponManager.php
CouponManager.getEffect
protected function getEffect(array $coupons) { $discount = 0.00; /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { $discount += $coupon->exec($this->facade); } return $discount; }
php
protected function getEffect(array $coupons) { $discount = 0.00; /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { $discount += $coupon->exec($this->facade); } return $discount; }
[ "protected", "function", "getEffect", "(", "array", "$", "coupons", ")", "{", "$", "discount", "=", "0.00", ";", "/** @var CouponInterface $coupon */", "foreach", "(", "$", "coupons", "as", "$", "coupon", ")", "{", "$", "discount", "+=", "$", "coupon", "->",...
Process given Coupon in order to get their cumulative effects @param array $coupons CouponInterface to process @return float discount
[ "Process", "given", "Coupon", "in", "order", "to", "get", "their", "cumulative", "effects" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Coupon/CouponManager.php#L242-L251
train
thelia/core
lib/Thelia/Coupon/CouponManager.php
CouponManager.clear
public function clear() { $coupons = $this->facade->getCurrentCoupons(); /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { $coupon->clear(); } }
php
public function clear() { $coupons = $this->facade->getCurrentCoupons(); /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { $coupon->clear(); } }
[ "public", "function", "clear", "(", ")", "{", "$", "coupons", "=", "$", "this", "->", "facade", "->", "getCurrentCoupons", "(", ")", ";", "/** @var CouponInterface $coupon */", "foreach", "(", "$", "coupons", "as", "$", "coupon", ")", "{", "$", "coupon", "...
Clear all data kept by coupons
[ "Clear", "all", "data", "kept", "by", "coupons" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Coupon/CouponManager.php#L296-L304
train
thelia/core
lib/Thelia/Coupon/CouponManager.php
CouponManager.decrementQuantity
public function decrementQuantity(Coupon $coupon, $customerId = null) { if ($coupon->isUsageUnlimited()) { return true; } else { try { $usageLeft = $coupon->getUsagesLeft($customerId); if ($usageLeft > 0) { // If the coupon usage is per user, add an entry to coupon customer usage count table if ($coupon->getPerCustomerUsageCount()) { if (null == $customerId) { throw new \LogicException("Customer should not be null at this time."); } $ccc = CouponCustomerCountQuery::create() ->filterByCouponId($coupon->getId()) ->filterByCustomerId($customerId) ->findOne() ; if ($ccc === null) { $ccc = new CouponCustomerCount(); $ccc ->setCustomerId($customerId) ->setCouponId($coupon->getId()) ->setCount(0); } $newCount = 1 + $ccc->getCount(); $ccc ->setCount($newCount) ->save() ; return $usageLeft - $newCount; } else { $coupon->setMaxUsage(--$usageLeft); $coupon->save(); return $usageLeft; } } } catch (\Exception $ex) { // Just log the problem. Tlog::getInstance()->addError(sprintf("Failed to decrement coupon %s: %s", $coupon->getCode(), $ex->getMessage())); } } return false; }
php
public function decrementQuantity(Coupon $coupon, $customerId = null) { if ($coupon->isUsageUnlimited()) { return true; } else { try { $usageLeft = $coupon->getUsagesLeft($customerId); if ($usageLeft > 0) { // If the coupon usage is per user, add an entry to coupon customer usage count table if ($coupon->getPerCustomerUsageCount()) { if (null == $customerId) { throw new \LogicException("Customer should not be null at this time."); } $ccc = CouponCustomerCountQuery::create() ->filterByCouponId($coupon->getId()) ->filterByCustomerId($customerId) ->findOne() ; if ($ccc === null) { $ccc = new CouponCustomerCount(); $ccc ->setCustomerId($customerId) ->setCouponId($coupon->getId()) ->setCount(0); } $newCount = 1 + $ccc->getCount(); $ccc ->setCount($newCount) ->save() ; return $usageLeft - $newCount; } else { $coupon->setMaxUsage(--$usageLeft); $coupon->save(); return $usageLeft; } } } catch (\Exception $ex) { // Just log the problem. Tlog::getInstance()->addError(sprintf("Failed to decrement coupon %s: %s", $coupon->getCode(), $ex->getMessage())); } } return false; }
[ "public", "function", "decrementQuantity", "(", "Coupon", "$", "coupon", ",", "$", "customerId", "=", "null", ")", "{", "if", "(", "$", "coupon", "->", "isUsageUnlimited", "(", ")", ")", "{", "return", "true", ";", "}", "else", "{", "try", "{", "$", ...
Decrement this coupon quantity To call when a coupon is consumed @param \Thelia\Model\Coupon $coupon Coupon consumed @param int|null $customerId the ID of the ordering customer @return int Usage left after decremental
[ "Decrement", "this", "coupon", "quantity" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Coupon/CouponManager.php#L316-L369
train
thelia/core
lib/Thelia/Tools/AddressFormat.php
AddressFormat.format
public function format( AddressInterface $address, $locale = null, $html = true, $htmlTag = "p", $htmlAttributes = [] ) { $locale = $this->normalizeLocale($locale); $addressFormatRepository = new AddressFormatRepository(); $countryRepository = new CountryRepository(); $subdivisionRepository = new SubdivisionRepository(); $formatter = new DefaultFormatter( $addressFormatRepository, $countryRepository, $subdivisionRepository, $locale ); $formatter->setOption('html', $html); $formatter->setOption('html_tag', $htmlTag); $formatter->setOption('html_attributes', $htmlAttributes); $addressFormatted = $formatter->format($address); return $addressFormatted; }
php
public function format( AddressInterface $address, $locale = null, $html = true, $htmlTag = "p", $htmlAttributes = [] ) { $locale = $this->normalizeLocale($locale); $addressFormatRepository = new AddressFormatRepository(); $countryRepository = new CountryRepository(); $subdivisionRepository = new SubdivisionRepository(); $formatter = new DefaultFormatter( $addressFormatRepository, $countryRepository, $subdivisionRepository, $locale ); $formatter->setOption('html', $html); $formatter->setOption('html_tag', $htmlTag); $formatter->setOption('html_attributes', $htmlAttributes); $addressFormatted = $formatter->format($address); return $addressFormatted; }
[ "public", "function", "format", "(", "AddressInterface", "$", "address", ",", "$", "locale", "=", "null", ",", "$", "html", "=", "true", ",", "$", "htmlTag", "=", "\"p\"", ",", "$", "htmlAttributes", "=", "[", "]", ")", "{", "$", "locale", "=", "$", ...
Format an address @param AddressInterface $address @param null $locale @param bool $html @param string $htmlTag @param array $htmlAttributes @return string
[ "Format", "an", "address" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Tools/AddressFormat.php#L64-L92
train
thelia/core
lib/Thelia/Tools/AddressFormat.php
AddressFormat.postalLabelFormat
public function postalLabelFormat(AddressInterface $address, $locale = null, $originCountry = null, $options = []) { $locale = $this->normalizeLocale($locale); $addressFormatRepository = new AddressFormatRepository(); $countryRepository = new CountryRepository(); $subdivisionRepository = new SubdivisionRepository(); if (null === $originCountry) { $countryId = Country::getShopLocation(); if (null === $country = CountryQuery::create()->findPk($countryId)) { $country = Country::getDefaultCountry(); } $originCountry = $country->getIsoalpha2(); } $formatter = new PostalLabelFormatter( $addressFormatRepository, $countryRepository, $subdivisionRepository, $originCountry, $locale, $options ); $addressFormatted = $formatter->format($address); return $addressFormatted; }
php
public function postalLabelFormat(AddressInterface $address, $locale = null, $originCountry = null, $options = []) { $locale = $this->normalizeLocale($locale); $addressFormatRepository = new AddressFormatRepository(); $countryRepository = new CountryRepository(); $subdivisionRepository = new SubdivisionRepository(); if (null === $originCountry) { $countryId = Country::getShopLocation(); if (null === $country = CountryQuery::create()->findPk($countryId)) { $country = Country::getDefaultCountry(); } $originCountry = $country->getIsoalpha2(); } $formatter = new PostalLabelFormatter( $addressFormatRepository, $countryRepository, $subdivisionRepository, $originCountry, $locale, $options ); $addressFormatted = $formatter->format($address); return $addressFormatted; }
[ "public", "function", "postalLabelFormat", "(", "AddressInterface", "$", "address", ",", "$", "locale", "=", "null", ",", "$", "originCountry", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "locale", "=", "$", "this", "->", "normalizeLo...
Format an address to a postal label @param AddressInterface $address @param null $locale @param null $originCountry @param array $options @return string
[ "Format", "an", "address", "to", "a", "postal", "label" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Tools/AddressFormat.php#L119-L148
train
thelia/core
lib/Thelia/Controller/BaseController.php
BaseController.getTranslator
public function getTranslator() { if (null === $this->translator) { $this->translator = $this->container->get('thelia.translator'); } return $this->translator; }
php
public function getTranslator() { if (null === $this->translator) { $this->translator = $this->container->get('thelia.translator'); } return $this->translator; }
[ "public", "function", "getTranslator", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "translator", ")", "{", "$", "this", "->", "translator", "=", "$", "this", "->", "container", "->", "get", "(", "'thelia.translator'", ")", ";", "}", "re...
return the Translator @return Translator
[ "return", "the", "Translator" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/BaseController.php#L142-L148
train
thelia/core
lib/Thelia/Controller/BaseController.php
BaseController.retrieveFormBasedUrl
protected function retrieveFormBasedUrl($parameterName, BaseForm $form = null) { $url = null; if ($form != null) { $url = $form->getFormDefinedUrl($parameterName); } else { $url = $this->container->get('request_stack')->getCurrentRequest()->get($parameterName); } return $url; }
php
protected function retrieveFormBasedUrl($parameterName, BaseForm $form = null) { $url = null; if ($form != null) { $url = $form->getFormDefinedUrl($parameterName); } else { $url = $this->container->get('request_stack')->getCurrentRequest()->get($parameterName); } return $url; }
[ "protected", "function", "retrieveFormBasedUrl", "(", "$", "parameterName", ",", "BaseForm", "$", "form", "=", "null", ")", "{", "$", "url", "=", "null", ";", "if", "(", "$", "form", "!=", "null", ")", "{", "$", "url", "=", "$", "form", "->", "getFor...
Search url in a form parameter, or in a request parameter. @param string $parameterName the form parameter name, or request parameter name. @param BaseForm $form the form @return mixed|null|string
[ "Search", "url", "in", "a", "form", "parameter", "or", "in", "a", "request", "parameter", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/BaseController.php#L341-L352
train
thelia/core
lib/Thelia/Controller/BaseController.php
BaseController.getRoute
protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_URL) { return $this->getRouteFromRouter( $this->getCurrentRouter(), $routeId, $parameters, $referenceType ); }
php
protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_URL) { return $this->getRouteFromRouter( $this->getCurrentRouter(), $routeId, $parameters, $referenceType ); }
[ "protected", "function", "getRoute", "(", "$", "routeId", ",", "$", "parameters", "=", "array", "(", ")", ",", "$", "referenceType", "=", "Router", "::", "ABSOLUTE_URL", ")", "{", "return", "$", "this", "->", "getRouteFromRouter", "(", "$", "this", "->", ...
Return the route path defined for the givent route ID @param string $routeId a route ID, as defines in Config/Resources/routing/admin.xml @param mixed $parameters An array of parameters @param int $referenceType The type of reference to be generated (one of the constants) @throws RouteNotFoundException If the named route doesn't exist @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route @throws InvalidParameterException When a parameter value for a placeholder is not correct because it does not match the requirement @throws \InvalidArgumentException When the router doesn't exist @return string The generated URL @see \Thelia\Controller\BaseController::getRouteFromRouter()
[ "Return", "the", "route", "path", "defined", "for", "the", "givent", "route", "ID" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/BaseController.php#L457-L465
train
thelia/core
lib/Thelia/Controller/BaseController.php
BaseController.getRouteFromRouter
protected function getRouteFromRouter( $routerName, $routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_URL ) { /** @var Router $router */ $router = $this->getRouter($routerName); if ($router == null) { throw new \InvalidArgumentException(sprintf("Router '%s' does not exists.", $routerName)); } return $router->generate($routeId, $parameters, $referenceType); }
php
protected function getRouteFromRouter( $routerName, $routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_URL ) { /** @var Router $router */ $router = $this->getRouter($routerName); if ($router == null) { throw new \InvalidArgumentException(sprintf("Router '%s' does not exists.", $routerName)); } return $router->generate($routeId, $parameters, $referenceType); }
[ "protected", "function", "getRouteFromRouter", "(", "$", "routerName", ",", "$", "routeId", ",", "$", "parameters", "=", "array", "(", ")", ",", "$", "referenceType", "=", "Router", "::", "ABSOLUTE_URL", ")", "{", "/** @var Router $router */", "$", "router", "...
Get a route path from the route id. @param string $routerName Router name @param string $routeId The name of the route @param mixed $parameters An array of parameters @param int $referenceType The type of reference to be generated (one of the constants) @throws RouteNotFoundException If the named route doesn't exist @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route @throws InvalidParameterException When a parameter value for a placeholder is not correct because it does not match the requirement @throws \InvalidArgumentException When the router doesn't exist @return string The generated URL
[ "Get", "a", "route", "path", "from", "the", "route", "id", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/BaseController.php#L482-L496
train
thelia/core
lib/Thelia/Controller/BaseController.php
BaseController.checkXmlHttpRequest
protected function checkXmlHttpRequest() { if (false === $this->container->get('request_stack')->getCurrentRequest()->isXmlHttpRequest() && false === $this->isDebug()) { $this->accessDenied(); } }
php
protected function checkXmlHttpRequest() { if (false === $this->container->get('request_stack')->getCurrentRequest()->isXmlHttpRequest() && false === $this->isDebug()) { $this->accessDenied(); } }
[ "protected", "function", "checkXmlHttpRequest", "(", ")", "{", "if", "(", "false", "===", "$", "this", "->", "container", "->", "get", "(", "'request_stack'", ")", "->", "getCurrentRequest", "(", ")", "->", "isXmlHttpRequest", "(", ")", "&&", "false", "===",...
check if the current http request is a XmlHttpRequest. If not, send a
[ "check", "if", "the", "current", "http", "request", "is", "a", "XmlHttpRequest", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/BaseController.php#L536-L541
train
thelia/core
lib/Thelia/Controller/Admin/TemplateController.php
TemplateController.performAdditionalDeleteAction
protected function performAdditionalDeleteAction($deleteEvent) { if ($deleteEvent->getProductCount() > 0) { $this->getParserContext()->setGeneralError( $this->getTranslator()->trans( "This template is in use in some of your products, and cannot be deleted. Delete it from all your products and try again." ) ); return $this->renderList(); } // Normal delete processing return null; }
php
protected function performAdditionalDeleteAction($deleteEvent) { if ($deleteEvent->getProductCount() > 0) { $this->getParserContext()->setGeneralError( $this->getTranslator()->trans( "This template is in use in some of your products, and cannot be deleted. Delete it from all your products and try again." ) ); return $this->renderList(); } // Normal delete processing return null; }
[ "protected", "function", "performAdditionalDeleteAction", "(", "$", "deleteEvent", ")", "{", "if", "(", "$", "deleteEvent", "->", "getProductCount", "(", ")", ">", "0", ")", "{", "$", "this", "->", "getParserContext", "(", ")", "->", "setGeneralError", "(", ...
Process delete failure, which may occurs if template is in use. @param TemplateDeleteEvent $deleteEvent @return null|\Thelia\Core\HttpFoundation\Response
[ "Process", "delete", "failure", "which", "may", "occurs", "if", "template", "is", "in", "use", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/TemplateController.php#L189-L203
train
thelia/core
lib/Thelia/Model/AdminLog.php
AdminLog.append
public static function append( $resource, $action, $message, Request $request, UserInterface $adminUser = null, $withRequestContent = true, $resourceId = null ) { $log = new AdminLog(); $log ->setAdminLogin($adminUser !== null ? $adminUser->getUsername() : '<no login>') ->setAdminFirstname($adminUser !== null && $adminUser instanceof Admin ? $adminUser->getFirstname() : '<no first name>') ->setAdminLastname($adminUser !== null && $adminUser instanceof Admin ? $adminUser->getLastname() : '<no last name>') ->setResource($resource) ->setResourceId($resourceId) ->setAction($action) ->setMessage($message) ->setRequest($request->toString($withRequestContent)); try { $log->save(); } catch (\Exception $ex) { Tlog::getInstance()->err("Failed to insert new entry in AdminLog: {ex}", array('ex' => $ex)); } }
php
public static function append( $resource, $action, $message, Request $request, UserInterface $adminUser = null, $withRequestContent = true, $resourceId = null ) { $log = new AdminLog(); $log ->setAdminLogin($adminUser !== null ? $adminUser->getUsername() : '<no login>') ->setAdminFirstname($adminUser !== null && $adminUser instanceof Admin ? $adminUser->getFirstname() : '<no first name>') ->setAdminLastname($adminUser !== null && $adminUser instanceof Admin ? $adminUser->getLastname() : '<no last name>') ->setResource($resource) ->setResourceId($resourceId) ->setAction($action) ->setMessage($message) ->setRequest($request->toString($withRequestContent)); try { $log->save(); } catch (\Exception $ex) { Tlog::getInstance()->err("Failed to insert new entry in AdminLog: {ex}", array('ex' => $ex)); } }
[ "public", "static", "function", "append", "(", "$", "resource", ",", "$", "action", ",", "$", "message", ",", "Request", "$", "request", ",", "UserInterface", "$", "adminUser", "=", "null", ",", "$", "withRequestContent", "=", "true", ",", "$", "resourceId...
A simple helper to insert an entry in the admin log @param string $resource @param string $action @param string $message @param Request $request @param UserInterface $adminUser @param bool $withRequestContent @param int $resourceId
[ "A", "simple", "helper", "to", "insert", "an", "entry", "in", "the", "admin", "log" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/AdminLog.php#L23-L49
train
grom358/pharborist
src/Formatter.php
Formatter.spaceBefore
protected function spaceBefore(Node $node) { $prev = $node->previousToken(); if ($prev instanceof WhitespaceNode) { $prev->setText(' '); } else { $node->before(Token::space()); } }
php
protected function spaceBefore(Node $node) { $prev = $node->previousToken(); if ($prev instanceof WhitespaceNode) { $prev->setText(' '); } else { $node->before(Token::space()); } }
[ "protected", "function", "spaceBefore", "(", "Node", "$", "node", ")", "{", "$", "prev", "=", "$", "node", "->", "previousToken", "(", ")", ";", "if", "(", "$", "prev", "instanceof", "WhitespaceNode", ")", "{", "$", "prev", "->", "setText", "(", "' '",...
Set a single space before a node. @param Node $node Node to set space before.
[ "Set", "a", "single", "space", "before", "a", "node", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Formatter.php#L127-L135
train
grom358/pharborist
src/Formatter.php
Formatter.spaceAfter
protected function spaceAfter(Node $node) { $next = $node->nextToken(); if ($next instanceof WhitespaceNode) { $next->setText(' '); } else { $node->after(Token::space()); } }
php
protected function spaceAfter(Node $node) { $next = $node->nextToken(); if ($next instanceof WhitespaceNode) { $next->setText(' '); } else { $node->after(Token::space()); } }
[ "protected", "function", "spaceAfter", "(", "Node", "$", "node", ")", "{", "$", "next", "=", "$", "node", "->", "nextToken", "(", ")", ";", "if", "(", "$", "next", "instanceof", "WhitespaceNode", ")", "{", "$", "next", "->", "setText", "(", "' '", ")...
Set a single space after a node. @param Node $node Node to set space after.
[ "Set", "a", "single", "space", "after", "a", "node", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Formatter.php#L143-L151
train
grom358/pharborist
src/Formatter.php
Formatter.removeSpaceBefore
protected function removeSpaceBefore(Node $node) { $prev = $node->previousToken(); if ($prev instanceof WhitespaceNode) { $prev->remove(); } }
php
protected function removeSpaceBefore(Node $node) { $prev = $node->previousToken(); if ($prev instanceof WhitespaceNode) { $prev->remove(); } }
[ "protected", "function", "removeSpaceBefore", "(", "Node", "$", "node", ")", "{", "$", "prev", "=", "$", "node", "->", "previousToken", "(", ")", ";", "if", "(", "$", "prev", "instanceof", "WhitespaceNode", ")", "{", "$", "prev", "->", "remove", "(", "...
Remove whitespace before a node. @param Node $node Node to remove space before.
[ "Remove", "whitespace", "before", "a", "node", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Formatter.php#L159-L164
train
grom358/pharborist
src/Formatter.php
Formatter.removeSpaceAfter
protected function removeSpaceAfter(Node $node) { $next = $node->nextToken(); if ($next instanceof WhitespaceNode) { $next->remove(); } }
php
protected function removeSpaceAfter(Node $node) { $next = $node->nextToken(); if ($next instanceof WhitespaceNode) { $next->remove(); } }
[ "protected", "function", "removeSpaceAfter", "(", "Node", "$", "node", ")", "{", "$", "next", "=", "$", "node", "->", "nextToken", "(", ")", ";", "if", "(", "$", "next", "instanceof", "WhitespaceNode", ")", "{", "$", "next", "->", "remove", "(", ")", ...
Remove whitespace after a node. @param Node $node Node to remove space after.
[ "Remove", "whitespace", "after", "a", "node", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Formatter.php#L172-L177
train
grom358/pharborist
src/Formatter.php
Formatter.newlineBefore
protected function newlineBefore(Node $node, $close = FALSE) { $prev = $node->previousToken(); if ($prev instanceof WhitespaceNode) { $prev_ws = $prev->previousToken(); if ($prev_ws instanceof CommentNode && $prev_ws->isLineComment() && $prev->getNewlineCount() === 0) { $prev->setText($this->getIndent($close)); } else { $prev->setText($this->getNewlineIndent($prev, $close)); } } else { if ($prev instanceof CommentNode && $prev->isLineComment()) { if ($this->indentLevel > 0) { $node->before(Token::whitespace($this->getIndent($close))); } } else { $node->before(Token::whitespace($this->getNewlineIndent(NULL, $close))); } } }
php
protected function newlineBefore(Node $node, $close = FALSE) { $prev = $node->previousToken(); if ($prev instanceof WhitespaceNode) { $prev_ws = $prev->previousToken(); if ($prev_ws instanceof CommentNode && $prev_ws->isLineComment() && $prev->getNewlineCount() === 0) { $prev->setText($this->getIndent($close)); } else { $prev->setText($this->getNewlineIndent($prev, $close)); } } else { if ($prev instanceof CommentNode && $prev->isLineComment()) { if ($this->indentLevel > 0) { $node->before(Token::whitespace($this->getIndent($close))); } } else { $node->before(Token::whitespace($this->getNewlineIndent(NULL, $close))); } } }
[ "protected", "function", "newlineBefore", "(", "Node", "$", "node", ",", "$", "close", "=", "FALSE", ")", "{", "$", "prev", "=", "$", "node", "->", "previousToken", "(", ")", ";", "if", "(", "$", "prev", "instanceof", "WhitespaceNode", ")", "{", "$", ...
Set so there a newline before a node. @param Node $node Node to set newline before. @param bool $close If the newline is for before a closing token, eg. ) or }
[ "Set", "so", "there", "a", "newline", "before", "a", "node", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Formatter.php#L187-L208
train
grom358/pharborist
src/Formatter.php
Formatter.newlineAfter
protected function newlineAfter(Node $node) { $next = $node->nextToken(); if ($next instanceof WhitespaceNode) { $next->setText($this->getNewlineIndent($next)); } else { $node->after(Token::whitespace($this->getNewlineIndent())); } }
php
protected function newlineAfter(Node $node) { $next = $node->nextToken(); if ($next instanceof WhitespaceNode) { $next->setText($this->getNewlineIndent($next)); } else { $node->after(Token::whitespace($this->getNewlineIndent())); } }
[ "protected", "function", "newlineAfter", "(", "Node", "$", "node", ")", "{", "$", "next", "=", "$", "node", "->", "nextToken", "(", ")", ";", "if", "(", "$", "next", "instanceof", "WhitespaceNode", ")", "{", "$", "next", "->", "setText", "(", "$", "t...
Set so there a newline after a node. @param Node $node Node to set newline after.
[ "Set", "so", "there", "a", "newline", "after", "a", "node", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Formatter.php#L216-L224
train
grom358/pharborist
src/Formatter.php
Formatter.handleBuiltinConstantNode
protected function handleBuiltinConstantNode(ConstantNode $node) { $to_upper = $this->config['boolean_null_upper']; if ($to_upper) { $node->toUpperCase(); } else { $node->toLowerCase(); } }
php
protected function handleBuiltinConstantNode(ConstantNode $node) { $to_upper = $this->config['boolean_null_upper']; if ($to_upper) { $node->toUpperCase(); } else { $node->toLowerCase(); } }
[ "protected", "function", "handleBuiltinConstantNode", "(", "ConstantNode", "$", "node", ")", "{", "$", "to_upper", "=", "$", "this", "->", "config", "[", "'boolean_null_upper'", "]", ";", "if", "(", "$", "to_upper", ")", "{", "$", "node", "->", "toUpperCase"...
Handle formatting of constant node. @param ConstantNode $node true, false, or null node.
[ "Handle", "formatting", "of", "constant", "node", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Formatter.php#L305-L313
train
grom358/pharborist
src/Formatter.php
Formatter.encloseBlock
protected function encloseBlock($node) { if ($node && !($node instanceof StatementBlockNode)) { $blockNode = new StatementBlockNode(); $blockNode->append([Token::openBrace(), clone $node, Token::closeBrace()]); $node->replaceWith($blockNode); } }
php
protected function encloseBlock($node) { if ($node && !($node instanceof StatementBlockNode)) { $blockNode = new StatementBlockNode(); $blockNode->append([Token::openBrace(), clone $node, Token::closeBrace()]); $node->replaceWith($blockNode); } }
[ "protected", "function", "encloseBlock", "(", "$", "node", ")", "{", "if", "(", "$", "node", "&&", "!", "(", "$", "node", "instanceof", "StatementBlockNode", ")", ")", "{", "$", "blockNode", "=", "new", "StatementBlockNode", "(", ")", ";", "$", "blockNod...
Wrap single line body statements in braces. @param Node|NULL $node
[ "Wrap", "single", "line", "body", "statements", "in", "braces", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Formatter.php#L328-L334
train
grom358/pharborist
src/Formatter.php
Formatter.handleParens
protected function handleParens($node) { $open_paren = $node->getOpenParen(); $this->removeSpaceAfter($open_paren); $this->spaceBefore($open_paren); $close_paren = $node->getCloseParen(); $this->removeSpaceBefore($close_paren); }
php
protected function handleParens($node) { $open_paren = $node->getOpenParen(); $this->removeSpaceAfter($open_paren); $this->spaceBefore($open_paren); $close_paren = $node->getCloseParen(); $this->removeSpaceBefore($close_paren); }
[ "protected", "function", "handleParens", "(", "$", "node", ")", "{", "$", "open_paren", "=", "$", "node", "->", "getOpenParen", "(", ")", ";", "$", "this", "->", "removeSpaceAfter", "(", "$", "open_paren", ")", ";", "$", "this", "->", "spaceBefore", "(",...
Handle whitespace around and inside parens for control structures. @param IfNode|ElseIfNode|ForNode|ForeachNode|SwitchNode|DoWhileNode|WhileNode $node
[ "Handle", "whitespace", "around", "and", "inside", "parens", "for", "control", "structures", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Formatter.php#L341-L347
train
grom358/pharborist
src/Formatter.php
Formatter.handleControlStructure
protected function handleControlStructure($node) { $this->handleParens($node); $colons = $node->children(Filter::isTokenType(':')); foreach ($colons as $colon) { $this->removeSpaceBefore($colon); } if ($colons->isNotEmpty()) { $this->newlineBefore($node->lastChild()->previous()); } }
php
protected function handleControlStructure($node) { $this->handleParens($node); $colons = $node->children(Filter::isTokenType(':')); foreach ($colons as $colon) { $this->removeSpaceBefore($colon); } if ($colons->isNotEmpty()) { $this->newlineBefore($node->lastChild()->previous()); } }
[ "protected", "function", "handleControlStructure", "(", "$", "node", ")", "{", "$", "this", "->", "handleParens", "(", "$", "node", ")", ";", "$", "colons", "=", "$", "node", "->", "children", "(", "Filter", "::", "isTokenType", "(", "':'", ")", ")", "...
Generic formatting rules for control structures. @param IfNode|ForNode|ForeachNode|SwitchNode|DoWhileNode|WhileNode $node
[ "Generic", "formatting", "rules", "for", "control", "structures", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Formatter.php#L354-L363
train
grom358/pharborist
src/Formatter.php
Formatter.isDeclaration
protected function isDeclaration(ParentNode $node) { return $node instanceof FunctionDeclarationNode || $node instanceof SingleInheritanceNode || $node instanceof InterfaceNode || $node instanceof ClassMethodNode || $node instanceof InterfaceMethodNode; }
php
protected function isDeclaration(ParentNode $node) { return $node instanceof FunctionDeclarationNode || $node instanceof SingleInheritanceNode || $node instanceof InterfaceNode || $node instanceof ClassMethodNode || $node instanceof InterfaceMethodNode; }
[ "protected", "function", "isDeclaration", "(", "ParentNode", "$", "node", ")", "{", "return", "$", "node", "instanceof", "FunctionDeclarationNode", "||", "$", "node", "instanceof", "SingleInheritanceNode", "||", "$", "node", "instanceof", "InterfaceNode", "||", "$",...
Test if declaration_brace_newline setting applies to node. @param ParentNode $node Node to test. @return bool TRUE if declaration_brace_newline applies to node.
[ "Test", "if", "declaration_brace_newline", "setting", "applies", "to", "node", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Formatter.php#L468-L474
train
grom358/pharborist
src/Formatter.php
Formatter.calculateColumnPosition
protected function calculateColumnPosition(Node $node) { // Add tokens until have whitespace containing newline. $column_position = 1; $start_token = $node instanceof ParentNode ? $node->firstToken() : $node; $token = $start_token; while ($token = $token->previousToken()) { if ($token instanceof WhitespaceNode && $token->getNewlineCount() > 0) { $lines = explode($this->config['nl'], $token->getText()); $last_line = end($lines); $column_position += strlen($last_line); break; } $column_position += strlen($token->getText()); } return $column_position; }
php
protected function calculateColumnPosition(Node $node) { // Add tokens until have whitespace containing newline. $column_position = 1; $start_token = $node instanceof ParentNode ? $node->firstToken() : $node; $token = $start_token; while ($token = $token->previousToken()) { if ($token instanceof WhitespaceNode && $token->getNewlineCount() > 0) { $lines = explode($this->config['nl'], $token->getText()); $last_line = end($lines); $column_position += strlen($last_line); break; } $column_position += strlen($token->getText()); } return $column_position; }
[ "protected", "function", "calculateColumnPosition", "(", "Node", "$", "node", ")", "{", "// Add tokens until have whitespace containing newline.", "$", "column_position", "=", "1", ";", "$", "start_token", "=", "$", "node", "instanceof", "ParentNode", "?", "$", "node"...
Calculate the column start position of the node. @param Node $node Node to calculate column position for. @return int Column position.
[ "Calculate", "the", "column", "start", "position", "of", "the", "node", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Formatter.php#L540-L555
train
thelia/core
lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php
CouponCreateOrUpdateEvent.setEffects
public function setEffects(array $effects) { // Amount is now optionnal. $this->amount = isset($effects['amount']) ? $effects['amount'] : 0; $this->effects = $effects; }
php
public function setEffects(array $effects) { // Amount is now optionnal. $this->amount = isset($effects['amount']) ? $effects['amount'] : 0; $this->effects = $effects; }
[ "public", "function", "setEffects", "(", "array", "$", "effects", ")", "{", "// Amount is now optionnal.", "$", "this", "->", "amount", "=", "isset", "(", "$", "effects", "[", "'amount'", "]", ")", "?", "$", "effects", "[", "'amount'", "]", ":", "0", ";"...
Set effects ready to be serialized @param array $effects Effect ready to be serialized Needs at least the key 'amount' with the amount removed from the cart @throws \Thelia\Model\Exception\InvalidArgumentException
[ "Set", "effects", "ready", "to", "be", "serialized" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php#L359-L365
train
Superbalist/php-event-pubsub
src/Events/TopicEvent.php
TopicEvent.toMessage
public function toMessage() { return array_merge($this->attributes, [ 'topic' => $this->topic, 'event' => $this->name, 'version' => $this->version, ]); }
php
public function toMessage() { return array_merge($this->attributes, [ 'topic' => $this->topic, 'event' => $this->name, 'version' => $this->version, ]); }
[ "public", "function", "toMessage", "(", ")", "{", "return", "array_merge", "(", "$", "this", "->", "attributes", ",", "[", "'topic'", "=>", "$", "this", "->", "topic", ",", "'event'", "=>", "$", "this", "->", "name", ",", "'version'", "=>", "$", "this"...
Return the event in a message format ready for publishing. @return mixed
[ "Return", "the", "event", "in", "a", "message", "format", "ready", "for", "publishing", "." ]
d84b8216137126d314bfaed9ab5efa1a3985e433
https://github.com/Superbalist/php-event-pubsub/blob/d84b8216137126d314bfaed9ab5efa1a3985e433/src/Events/TopicEvent.php#L59-L66
train
Superbalist/php-event-pubsub
src/Events/TopicEvent.php
TopicEvent.matches
public function matches($expr) { $params = self::parseEventExpr($expr); if ($params['topic'] === '*') { return true; } elseif ($this->topic !== $params['topic']) { return false; } if ($params['event'] === '*') { return true; } elseif ($this->name !== $params['event']) { return false; } if ($params['version'] === '*') { return true; } else { return Semver::satisfies($this->version, $params['version']); } }
php
public function matches($expr) { $params = self::parseEventExpr($expr); if ($params['topic'] === '*') { return true; } elseif ($this->topic !== $params['topic']) { return false; } if ($params['event'] === '*') { return true; } elseif ($this->name !== $params['event']) { return false; } if ($params['version'] === '*') { return true; } else { return Semver::satisfies($this->version, $params['version']); } }
[ "public", "function", "matches", "(", "$", "expr", ")", "{", "$", "params", "=", "self", "::", "parseEventExpr", "(", "$", "expr", ")", ";", "if", "(", "$", "params", "[", "'topic'", "]", "===", "'*'", ")", "{", "return", "true", ";", "}", "elseif"...
Check whether or not the event matches the given expression. @param string $expr @return bool
[ "Check", "whether", "or", "not", "the", "event", "matches", "the", "given", "expression", "." ]
d84b8216137126d314bfaed9ab5efa1a3985e433
https://github.com/Superbalist/php-event-pubsub/blob/d84b8216137126d314bfaed9ab5efa1a3985e433/src/Events/TopicEvent.php#L75-L96
train
grom358/pharborist
src/OperatorFactory.php
OperatorFactory.createOperator
public static function createOperator($token_type, $static_only = FALSE) { if (array_key_exists($token_type, self::$operators)) { list($assoc, $precedence, $static, $binary_class_name, $unary_class_name) = self::$operators[$token_type]; if ($static_only && !$static) { return NULL; } $operator = new Operator(); $operator->type = $token_type; $operator->associativity = $assoc; $operator->precedence = $precedence; $operator->hasBinaryMode = $binary_class_name !== NULL; $operator->hasUnaryMode = $unary_class_name !== NULL; $operator->binaryClassName = $binary_class_name; $operator->unaryClassName = $unary_class_name; return $operator; } return NULL; }
php
public static function createOperator($token_type, $static_only = FALSE) { if (array_key_exists($token_type, self::$operators)) { list($assoc, $precedence, $static, $binary_class_name, $unary_class_name) = self::$operators[$token_type]; if ($static_only && !$static) { return NULL; } $operator = new Operator(); $operator->type = $token_type; $operator->associativity = $assoc; $operator->precedence = $precedence; $operator->hasBinaryMode = $binary_class_name !== NULL; $operator->hasUnaryMode = $unary_class_name !== NULL; $operator->binaryClassName = $binary_class_name; $operator->unaryClassName = $unary_class_name; return $operator; } return NULL; }
[ "public", "static", "function", "createOperator", "(", "$", "token_type", ",", "$", "static_only", "=", "FALSE", ")", "{", "if", "(", "array_key_exists", "(", "$", "token_type", ",", "self", "::", "$", "operators", ")", ")", "{", "list", "(", "$", "assoc...
Create an OperatorNode for the given token type. @param int|string $token_type @param bool $static_only @return Operator
[ "Create", "an", "OperatorNode", "for", "the", "given", "token", "type", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/OperatorFactory.php#L84-L101
train
BoldGrid/library
src/Util/Plugin.php
Plugin.getPluginFile
public static function getPluginFile( $slug ) { // Load plugin.php if not already included by core. if ( ! function_exists( 'get_plugins' ) ) { require ABSPATH . '/wp-admin/includes/plugin.php'; } $plugins = get_plugins(); foreach ( $plugins as $file => $info ) { // Get the basename of the plugin. $basename = dirname( plugin_basename( $file ) ); if ( $basename === $slug ) { return $file; } } return null; }
php
public static function getPluginFile( $slug ) { // Load plugin.php if not already included by core. if ( ! function_exists( 'get_plugins' ) ) { require ABSPATH . '/wp-admin/includes/plugin.php'; } $plugins = get_plugins(); foreach ( $plugins as $file => $info ) { // Get the basename of the plugin. $basename = dirname( plugin_basename( $file ) ); if ( $basename === $slug ) { return $file; } } return null; }
[ "public", "static", "function", "getPluginFile", "(", "$", "slug", ")", "{", "// Load plugin.php if not already included by core.", "if", "(", "!", "function_exists", "(", "'get_plugins'", ")", ")", "{", "require", "ABSPATH", ".", "'/wp-admin/includes/plugin.php'", ";",...
Helper to get and verify the plugin file. @since 1.0.2 @param string $slug Slug of the plugin to get main file for. @return mixed $file Main plugin file of slug or null if not found.
[ "Helper", "to", "get", "and", "verify", "the", "plugin", "file", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Util/Plugin.php#L32-L51
train
thelia/core
lib/Thelia/Coupon/CouponFactory.php
CouponFactory.buildCouponFromCode
public function buildCouponFromCode($couponCode) { /** @var Coupon $couponModel */ $couponModel = $this->facade->findOneCouponByCode($couponCode); if ($couponModel === null) { return false; } // check if coupon is enabled if (!$couponModel->getIsEnabled()) { throw new InactiveCouponException($couponCode); } $nowDateTime = new \DateTime(); // Check coupon start date if ($couponModel->getStartDate() !== null && $couponModel->getStartDate() > $nowDateTime) { throw new CouponNotReleaseException($couponCode); } // Check coupon expiration date if ($couponModel->getExpirationDate() < $nowDateTime) { throw new CouponExpiredException($couponCode); } // Check coupon usage count if (! $couponModel->isUsageUnlimited()) { if (null === $customer = $this->facade->getCustomer()) { throw new UnmatchableConditionException($couponCode); } if ($couponModel->getUsagesLeft($customer->getId()) <= 0) { throw new CouponNoUsageLeftException($couponCode); } } /** @var CouponInterface $couponInterface */ $couponInterface = $this->buildCouponFromModel($couponModel); if ($couponInterface && $couponInterface->getConditions()->count() == 0) { throw new InvalidConditionException( \get_class($couponInterface) ); } return $couponInterface; }
php
public function buildCouponFromCode($couponCode) { /** @var Coupon $couponModel */ $couponModel = $this->facade->findOneCouponByCode($couponCode); if ($couponModel === null) { return false; } // check if coupon is enabled if (!$couponModel->getIsEnabled()) { throw new InactiveCouponException($couponCode); } $nowDateTime = new \DateTime(); // Check coupon start date if ($couponModel->getStartDate() !== null && $couponModel->getStartDate() > $nowDateTime) { throw new CouponNotReleaseException($couponCode); } // Check coupon expiration date if ($couponModel->getExpirationDate() < $nowDateTime) { throw new CouponExpiredException($couponCode); } // Check coupon usage count if (! $couponModel->isUsageUnlimited()) { if (null === $customer = $this->facade->getCustomer()) { throw new UnmatchableConditionException($couponCode); } if ($couponModel->getUsagesLeft($customer->getId()) <= 0) { throw new CouponNoUsageLeftException($couponCode); } } /** @var CouponInterface $couponInterface */ $couponInterface = $this->buildCouponFromModel($couponModel); if ($couponInterface && $couponInterface->getConditions()->count() == 0) { throw new InvalidConditionException( \get_class($couponInterface) ); } return $couponInterface; }
[ "public", "function", "buildCouponFromCode", "(", "$", "couponCode", ")", "{", "/** @var Coupon $couponModel */", "$", "couponModel", "=", "$", "this", "->", "facade", "->", "findOneCouponByCode", "(", "$", "couponCode", ")", ";", "if", "(", "$", "couponModel", ...
Build a CouponInterface from its database data @param string $couponCode Coupon code ex: XMAS @return CouponInterface @throws CouponExpiredException @throws CouponNoUsageLeftException @throws CouponNotReleaseException
[ "Build", "a", "CouponInterface", "from", "its", "database", "data" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Coupon/CouponFactory.php#L61-L107
train
thelia/core
lib/Thelia/Coupon/CouponFactory.php
CouponFactory.buildCouponFromModel
public function buildCouponFromModel(Coupon $model) { $isCumulative = ($model->getIsCumulative() == 1 ? true : false); $isRemovingPostage = ($model->getIsRemovingPostage() == 1 ? true : false); if (!$this->container->has($model->getType())) { return false; } /** @var CouponInterface $couponManager*/ $couponManager = $this->container->get($model->getType()); $couponManager->set( $this->facade, $model->getCode(), $model->getTitle(), $model->getShortDescription(), $model->getDescription(), $model->getEffects(), $isCumulative, $isRemovingPostage, $model->getIsAvailableOnSpecialOffers(), $model->getIsEnabled(), $model->getMaxUsage(), $model->getExpirationDate(), $model->getFreeShippingForCountries(), $model->getFreeShippingForModules(), $model->getPerCustomerUsageCount() ); /** @var ConditionFactory $conditionFactory */ $conditionFactory = $this->container->get('thelia.condition.factory'); $conditions = $conditionFactory->unserializeConditionCollection( $model->getSerializedConditions() ); $couponManager->setConditions($conditions); return clone $couponManager; }
php
public function buildCouponFromModel(Coupon $model) { $isCumulative = ($model->getIsCumulative() == 1 ? true : false); $isRemovingPostage = ($model->getIsRemovingPostage() == 1 ? true : false); if (!$this->container->has($model->getType())) { return false; } /** @var CouponInterface $couponManager*/ $couponManager = $this->container->get($model->getType()); $couponManager->set( $this->facade, $model->getCode(), $model->getTitle(), $model->getShortDescription(), $model->getDescription(), $model->getEffects(), $isCumulative, $isRemovingPostage, $model->getIsAvailableOnSpecialOffers(), $model->getIsEnabled(), $model->getMaxUsage(), $model->getExpirationDate(), $model->getFreeShippingForCountries(), $model->getFreeShippingForModules(), $model->getPerCustomerUsageCount() ); /** @var ConditionFactory $conditionFactory */ $conditionFactory = $this->container->get('thelia.condition.factory'); $conditions = $conditionFactory->unserializeConditionCollection( $model->getSerializedConditions() ); $couponManager->setConditions($conditions); return clone $couponManager; }
[ "public", "function", "buildCouponFromModel", "(", "Coupon", "$", "model", ")", "{", "$", "isCumulative", "=", "(", "$", "model", "->", "getIsCumulative", "(", ")", "==", "1", "?", "true", ":", "false", ")", ";", "$", "isRemovingPostage", "=", "(", "$", ...
Build a CouponInterface from its Model data contained in the DataBase @param Coupon $model Database data @return CouponInterface ready to use CouponInterface object instance
[ "Build", "a", "CouponInterface", "from", "its", "Model", "data", "contained", "in", "the", "DataBase" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Coupon/CouponFactory.php#L116-L154
train