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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
melisplatform/melis-cms | src/Controller/PageEditionController.php | PageEditionController.getEditionLogOfPageEditionById | public function getEditionLogOfPageEditionById($pageId)
{
$data = array();
$pageEdition = $this->getServiceLocator()->get('MelisEnginePage');
$dataLogs = $pageEdition->getEditionLogsOfPage($pageId);
$data = $dataLogs;
return $data;
} | php | public function getEditionLogOfPageEditionById($pageId)
{
$data = array();
$pageEdition = $this->getServiceLocator()->get('MelisEnginePage');
$dataLogs = $pageEdition->getEditionLogsOfPage($pageId);
$data = $dataLogs;
return $data;
} | [
"public",
"function",
"getEditionLogOfPageEditionById",
"(",
"$",
"pageId",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"pageEdition",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisEnginePage'",
")",
";",
"$",... | Returns edition log of page edition
@param pageId
return array | [
"Returns",
"edition",
"log",
"of",
"page",
"edition"
] | ed470338f4c7653fd93e530013ab934eb7a52b6f | https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/PageEditionController.php#L233-L243 | train |
melisplatform/melis-cms | src/Controller/PageEditionController.php | PageEditionController.saveEditionAction | public function saveEditionAction()
{
$idPage = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', ''));
$translator = $this->serviceLocator->get('translator');
$eventDatas = array('idPage' => $idPage);
$this->getEventManager()->trigger('meliscms_page_saveedition_start', null, $eventDatas);
$container = new Container('meliscms');
if (empty($idPage))
{
$result = array(
'success' => 0,
'errors' => array(array('empty' => $translator->translate('tr_meliscms_form_common_errors_Empty datas')))
);
}
else
{
// Resave XML of the page
if (!empty($container['content-pages'][$idPage]))
{
// Create the new XML
$newXmlContent = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$newXmlContent .= '<document type="MelisCMS" author="MelisTechnology" version="2.0">' . "\n";
foreach ($container['content-pages'][$idPage] as $namePlugin => $pluginEntries)
{
if($namePlugin != 'private:melisPluginSettings') {
foreach ($pluginEntries as $idEntry => $valueEntry) {
$newXmlContent .= "\t" . $valueEntry . "\n";
}
}
}
$newXmlContent .= '</document>';
// Save the result
$melisPageSavedTable = $this->getServiceLocator()->get('MelisEngineTablePageSaved');
$melisPageSavedTable->save(array('page_content' => $newXmlContent), $idPage);
}
$result = array(
'success' => 1,
'errors' => array(),
);
}
$this->getEventManager()->trigger('meliscms_page_saveedition_end', null, $result);
return new JsonModel($result);
} | php | public function saveEditionAction()
{
$idPage = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', ''));
$translator = $this->serviceLocator->get('translator');
$eventDatas = array('idPage' => $idPage);
$this->getEventManager()->trigger('meliscms_page_saveedition_start', null, $eventDatas);
$container = new Container('meliscms');
if (empty($idPage))
{
$result = array(
'success' => 0,
'errors' => array(array('empty' => $translator->translate('tr_meliscms_form_common_errors_Empty datas')))
);
}
else
{
// Resave XML of the page
if (!empty($container['content-pages'][$idPage]))
{
// Create the new XML
$newXmlContent = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$newXmlContent .= '<document type="MelisCMS" author="MelisTechnology" version="2.0">' . "\n";
foreach ($container['content-pages'][$idPage] as $namePlugin => $pluginEntries)
{
if($namePlugin != 'private:melisPluginSettings') {
foreach ($pluginEntries as $idEntry => $valueEntry) {
$newXmlContent .= "\t" . $valueEntry . "\n";
}
}
}
$newXmlContent .= '</document>';
// Save the result
$melisPageSavedTable = $this->getServiceLocator()->get('MelisEngineTablePageSaved');
$melisPageSavedTable->save(array('page_content' => $newXmlContent), $idPage);
}
$result = array(
'success' => 1,
'errors' => array(),
);
}
$this->getEventManager()->trigger('meliscms_page_saveedition_end', null, $result);
return new JsonModel($result);
} | [
"public",
"function",
"saveEditionAction",
"(",
")",
"{",
"$",
"idPage",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'idPage'",
",",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromQuery",
"(",
"'idPage'",
",",
"''",
")",
"... | Save Page edition
@return \Zend\View\Model\JsonModel | [
"Save",
"Page",
"edition"
] | ed470338f4c7653fd93e530013ab934eb7a52b6f | https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/PageEditionController.php#L249-L299 | train |
melisplatform/melis-cms | src/Controller/PageEditionController.php | PageEditionController.getTinyTemplatesAction | public function getTinyTemplatesAction()
{
$idPage = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', ''));
$success = 1;
$tinyTemplates = array();
// No pageId, return empty array
if (!empty($idPage))
{
// Get datas from page
$melisPage = $this->getServiceLocator()->get('MelisEnginePage');
$datasPage = $melisPage->getDatasPage($idPage, 'saved');
$datasTemplate = $datasPage->getMelisTemplate();
// No template, return empty array
if (!empty($datasTemplate))
{
// Get the path of mini-templates to this website
$folderSite = $datasTemplate->tpl_zf2_website_folder;
$folderSite .= '/public/' . self::MINI_TEMPLATES_FOLDER;
$folderSite = $_SERVER['DOCUMENT_ROOT'] . '/../module/MelisSites/' . $folderSite;
// List the mini-templates from the folder
if (is_dir($folderSite))
{
if ($handle = opendir($folderSite))
{
while (false !== ($entry = readdir($handle)))
{
if (is_dir($folderSite . '/' . $entry) || $entry == '.' || $entry == '..')
continue;
array_push($tinyTemplates,
array(
'title' => $entry,
'url' => "/" . $datasTemplate->tpl_zf2_website_folder . '/' .
self::MINI_TEMPLATES_FOLDER . '/' . $entry
));
}
closedir($handle);
}
}
}
}
return new JsonModel($tinyTemplates);
} | php | public function getTinyTemplatesAction()
{
$idPage = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', ''));
$success = 1;
$tinyTemplates = array();
// No pageId, return empty array
if (!empty($idPage))
{
// Get datas from page
$melisPage = $this->getServiceLocator()->get('MelisEnginePage');
$datasPage = $melisPage->getDatasPage($idPage, 'saved');
$datasTemplate = $datasPage->getMelisTemplate();
// No template, return empty array
if (!empty($datasTemplate))
{
// Get the path of mini-templates to this website
$folderSite = $datasTemplate->tpl_zf2_website_folder;
$folderSite .= '/public/' . self::MINI_TEMPLATES_FOLDER;
$folderSite = $_SERVER['DOCUMENT_ROOT'] . '/../module/MelisSites/' . $folderSite;
// List the mini-templates from the folder
if (is_dir($folderSite))
{
if ($handle = opendir($folderSite))
{
while (false !== ($entry = readdir($handle)))
{
if (is_dir($folderSite . '/' . $entry) || $entry == '.' || $entry == '..')
continue;
array_push($tinyTemplates,
array(
'title' => $entry,
'url' => "/" . $datasTemplate->tpl_zf2_website_folder . '/' .
self::MINI_TEMPLATES_FOLDER . '/' . $entry
));
}
closedir($handle);
}
}
}
}
return new JsonModel($tinyTemplates);
} | [
"public",
"function",
"getTinyTemplatesAction",
"(",
")",
"{",
"$",
"idPage",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'idPage'",
",",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromQuery",
"(",
"'idPage'",
",",
"''",
")"... | This method sends back the list of mini-templates for TinyMCE
It takes the page id as a parameter, determines the website folder
in order to list only the mini-templates of the website and not
all of them
@return \Zend\View\Model\JsonModel | [
"This",
"method",
"sends",
"back",
"the",
"list",
"of",
"mini",
"-",
"templates",
"for",
"TinyMCE",
"It",
"takes",
"the",
"page",
"id",
"as",
"a",
"parameter",
"determines",
"the",
"website",
"folder",
"in",
"order",
"to",
"list",
"only",
"the",
"mini",
... | ed470338f4c7653fd93e530013ab934eb7a52b6f | https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/PageEditionController.php#L309-L355 | train |
grom358/pharborist | src/Objects/ObjectMethodCallNode.php | ObjectMethodCallNode.create | public static function create(Node $object, $method_name) {
/** @var ObjectMethodCallNode $node */
$node = new static();
$node->addChild($object, 'object');
$node->addChild(Token::objectOperator(), 'operator');
$node->addChild(Token::identifier($method_name), 'methodName');
$node->addChild(Token::openParen(), 'openParen');
$node->addChild(new CommaListNode(), 'arguments');
$node->addChild(Token::closeParen(), 'closeParen');
return $node;
} | php | public static function create(Node $object, $method_name) {
/** @var ObjectMethodCallNode $node */
$node = new static();
$node->addChild($object, 'object');
$node->addChild(Token::objectOperator(), 'operator');
$node->addChild(Token::identifier($method_name), 'methodName');
$node->addChild(Token::openParen(), 'openParen');
$node->addChild(new CommaListNode(), 'arguments');
$node->addChild(Token::closeParen(), 'closeParen');
return $node;
} | [
"public",
"static",
"function",
"create",
"(",
"Node",
"$",
"object",
",",
"$",
"method_name",
")",
"{",
"/** @var ObjectMethodCallNode $node */",
"$",
"node",
"=",
"new",
"static",
"(",
")",
";",
"$",
"node",
"->",
"addChild",
"(",
"$",
"object",
",",
"'o... | Creates a method call on an object with an empty argument list.
@param Node $object
The expression that is an object.
@param string $method_name
The name of the called method.
@return static | [
"Creates",
"a",
"method",
"call",
"on",
"an",
"object",
"with",
"an",
"empty",
"argument",
"list",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Objects/ObjectMethodCallNode.php#L76-L86 | train |
thelia/core | lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php | XmlFileLoader.parseFilters | protected function parseFilters(SimpleXMLElement $xml)
{
if (false === $filters = $xml->xpath('//config:filters/config:filter')) {
return;
}
try {
$filterConfig = $this->container->getParameter("Thelia.parser.filters");
} catch (ParameterNotFoundException $e) {
$filterConfig = array();
}
foreach ($filters as $filter) {
$filterConfig[$this->getAttributeAsPhp($filter, "name")] = $this->getAttributeAsPhp($filter, "class");
}
$this->container->setParameter("Thelia.parser.filters", $filterConfig);
} | php | protected function parseFilters(SimpleXMLElement $xml)
{
if (false === $filters = $xml->xpath('//config:filters/config:filter')) {
return;
}
try {
$filterConfig = $this->container->getParameter("Thelia.parser.filters");
} catch (ParameterNotFoundException $e) {
$filterConfig = array();
}
foreach ($filters as $filter) {
$filterConfig[$this->getAttributeAsPhp($filter, "name")] = $this->getAttributeAsPhp($filter, "class");
}
$this->container->setParameter("Thelia.parser.filters", $filterConfig);
} | [
"protected",
"function",
"parseFilters",
"(",
"SimpleXMLElement",
"$",
"xml",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"filters",
"=",
"$",
"xml",
"->",
"xpath",
"(",
"'//config:filters/config:filter'",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"$",
... | parse Filters property
@param SimpleXMLElement $xml | [
"parse",
"Filters",
"property"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php#L197-L213 | train |
thelia/core | lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php | XmlFileLoader.parseTemplateDirectives | protected function parseTemplateDirectives(SimpleXMLElement $xml)
{
if (false === $baseParams = $xml->xpath('//config:templateDirectives/config:templateDirective')) {
return;
}
try {
$baseParamConfig = $this->container->getParameter("Thelia.parser.templateDirectives");
} catch (ParameterNotFoundException $e) {
$baseParamConfig = array();
}
foreach ($baseParams as $baseParam) {
$baseParamConfig[$this->getAttributeAsPhp($baseParam, "name")] = $this->getAttributeAsPhp($baseParam, "class");
}
$this->container->setParameter("Thelia.parser.templateDirectives", $baseParamConfig);
} | php | protected function parseTemplateDirectives(SimpleXMLElement $xml)
{
if (false === $baseParams = $xml->xpath('//config:templateDirectives/config:templateDirective')) {
return;
}
try {
$baseParamConfig = $this->container->getParameter("Thelia.parser.templateDirectives");
} catch (ParameterNotFoundException $e) {
$baseParamConfig = array();
}
foreach ($baseParams as $baseParam) {
$baseParamConfig[$this->getAttributeAsPhp($baseParam, "name")] = $this->getAttributeAsPhp($baseParam, "class");
}
$this->container->setParameter("Thelia.parser.templateDirectives", $baseParamConfig);
} | [
"protected",
"function",
"parseTemplateDirectives",
"(",
"SimpleXMLElement",
"$",
"xml",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"baseParams",
"=",
"$",
"xml",
"->",
"xpath",
"(",
"'//config:templateDirectives/config:templateDirective'",
")",
")",
"{",
"return",
... | parse BaseParams property
@param SimpleXMLElement $xml | [
"parse",
"BaseParams",
"property"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php#L220-L236 | train |
thelia/core | lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php | XmlFileLoader.parseService | protected function parseService($id, $service, $file)
{
if ((string) $service['alias']) {
$public = true;
if (isset($service['public'])) {
$public = $this->getAttributeAsPhp($service, 'public');
}
$this->container->setAlias($id, new Alias((string) $service['alias'], $public));
return;
}
if (isset($service['parent'])) {
$definition = new DefinitionDecorator((string) $service['parent']);
} else {
$definition = new Definition();
}
foreach (array('class', 'scope', 'public', 'factory-class', 'factory-method', 'factory-service', 'synthetic', 'abstract') as $key) {
if (isset($service[$key])) {
$method = 'set'.str_replace('-', '', $key);
$definition->$method((string) $this->getAttributeAsPhp($service, $key));
}
}
if ($service->file) {
$definition->setFile((string) $service->file);
}
$definition->setArguments($this->getArgumentsAsPhp($service, 'argument'));
$definition->setProperties($this->getArgumentsAsPhp($service, 'property'));
if (isset($service->configurator)) {
if (isset($service->configurator['function'])) {
$definition->setConfigurator((string) $service->configurator['function']);
} else {
if (isset($service->configurator['service'])) {
$class = new Reference((string) $service->configurator['service'], ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false);
} else {
$class = (string) $service->configurator['class'];
}
$definition->setConfigurator(array($class, (string) $service->configurator['method']));
}
}
foreach ($service->call as $call) {
$definition->addMethodCall((string) $call['method'], $this->getArgumentsAsPhp($call, 'argument'));
}
foreach ($service->tag as $tag) {
$parameters = array();
foreach ($tag->attributes() as $name => $value) {
if ('name' === $name) {
continue;
}
$parameters[$name] = XmlUtils::phpize($value);
}
$definition->addTag((string) $tag['name'], $parameters);
}
return $definition;
} | php | protected function parseService($id, $service, $file)
{
if ((string) $service['alias']) {
$public = true;
if (isset($service['public'])) {
$public = $this->getAttributeAsPhp($service, 'public');
}
$this->container->setAlias($id, new Alias((string) $service['alias'], $public));
return;
}
if (isset($service['parent'])) {
$definition = new DefinitionDecorator((string) $service['parent']);
} else {
$definition = new Definition();
}
foreach (array('class', 'scope', 'public', 'factory-class', 'factory-method', 'factory-service', 'synthetic', 'abstract') as $key) {
if (isset($service[$key])) {
$method = 'set'.str_replace('-', '', $key);
$definition->$method((string) $this->getAttributeAsPhp($service, $key));
}
}
if ($service->file) {
$definition->setFile((string) $service->file);
}
$definition->setArguments($this->getArgumentsAsPhp($service, 'argument'));
$definition->setProperties($this->getArgumentsAsPhp($service, 'property'));
if (isset($service->configurator)) {
if (isset($service->configurator['function'])) {
$definition->setConfigurator((string) $service->configurator['function']);
} else {
if (isset($service->configurator['service'])) {
$class = new Reference((string) $service->configurator['service'], ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false);
} else {
$class = (string) $service->configurator['class'];
}
$definition->setConfigurator(array($class, (string) $service->configurator['method']));
}
}
foreach ($service->call as $call) {
$definition->addMethodCall((string) $call['method'], $this->getArgumentsAsPhp($call, 'argument'));
}
foreach ($service->tag as $tag) {
$parameters = array();
foreach ($tag->attributes() as $name => $value) {
if ('name' === $name) {
continue;
}
$parameters[$name] = XmlUtils::phpize($value);
}
$definition->addTag((string) $tag['name'], $parameters);
}
return $definition;
} | [
"protected",
"function",
"parseService",
"(",
"$",
"id",
",",
"$",
"service",
",",
"$",
"file",
")",
"{",
"if",
"(",
"(",
"string",
")",
"$",
"service",
"[",
"'alias'",
"]",
")",
"{",
"$",
"public",
"=",
"true",
";",
"if",
"(",
"isset",
"(",
"$",... | Parses an individual Definition
@param string $id
@param SimpleXMLElement $service
@param string $file
@return Definition | [
"Parses",
"an",
"individual",
"Definition"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php#L307-L371 | train |
thelia/core | lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php | XmlFileLoader.getArgumentsAsPhp | private function getArgumentsAsPhp(SimpleXMLElement $xml, $name, $lowercase = true)
{
$arguments = array();
foreach ($xml->$name as $arg) {
if (isset($arg['name'])) {
$arg['key'] = (string) $arg['name'];
}
$key = isset($arg['key']) ? (string) $arg['key'] : (!$arguments ? 0 : max(array_keys($arguments)) + 1);
// parameter keys are case insensitive
if ('parameter' == $name && $lowercase) {
$key = strtolower($key);
}
// this is used by DefinitionDecorator to overwrite a specific
// argument of the parent definition
if (isset($arg['index'])) {
$key = 'index_'.$arg['index'];
}
switch ($arg['type']) {
case 'service':
$invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
if (isset($arg['on-invalid']) && 'ignore' == $arg['on-invalid']) {
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
} elseif (isset($arg['on-invalid']) && 'null' == $arg['on-invalid']) {
$invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
}
if (isset($arg['strict'])) {
$strict = XmlUtils::phpize($arg['strict']);
} else {
$strict = true;
}
$arguments[$key] = new Reference((string) $arg['id'], $invalidBehavior, $strict);
break;
case 'expression':
$arguments[$key] = new Expression((string) $arg);
break;
case 'collection':
$arguments[$key] = $this->getArgumentsAsPhp($arg, $name, false);
break;
case 'string':
$arguments[$key] = (string) $arg;
break;
case 'constant':
$arguments[$key] = constant((string) $arg);
break;
default:
$arguments[$key] = XmlUtils::phpize($arg);
}
}
return $arguments;
} | php | private function getArgumentsAsPhp(SimpleXMLElement $xml, $name, $lowercase = true)
{
$arguments = array();
foreach ($xml->$name as $arg) {
if (isset($arg['name'])) {
$arg['key'] = (string) $arg['name'];
}
$key = isset($arg['key']) ? (string) $arg['key'] : (!$arguments ? 0 : max(array_keys($arguments)) + 1);
// parameter keys are case insensitive
if ('parameter' == $name && $lowercase) {
$key = strtolower($key);
}
// this is used by DefinitionDecorator to overwrite a specific
// argument of the parent definition
if (isset($arg['index'])) {
$key = 'index_'.$arg['index'];
}
switch ($arg['type']) {
case 'service':
$invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
if (isset($arg['on-invalid']) && 'ignore' == $arg['on-invalid']) {
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
} elseif (isset($arg['on-invalid']) && 'null' == $arg['on-invalid']) {
$invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
}
if (isset($arg['strict'])) {
$strict = XmlUtils::phpize($arg['strict']);
} else {
$strict = true;
}
$arguments[$key] = new Reference((string) $arg['id'], $invalidBehavior, $strict);
break;
case 'expression':
$arguments[$key] = new Expression((string) $arg);
break;
case 'collection':
$arguments[$key] = $this->getArgumentsAsPhp($arg, $name, false);
break;
case 'string':
$arguments[$key] = (string) $arg;
break;
case 'constant':
$arguments[$key] = constant((string) $arg);
break;
default:
$arguments[$key] = XmlUtils::phpize($arg);
}
}
return $arguments;
} | [
"private",
"function",
"getArgumentsAsPhp",
"(",
"SimpleXMLElement",
"$",
"xml",
",",
"$",
"name",
",",
"$",
"lowercase",
"=",
"true",
")",
"{",
"$",
"arguments",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"xml",
"->",
"$",
"name",
"as",
"$",
... | Returns arguments as valid PHP types.
@param SimpleXMLElement $xml
@param $name
@param bool $lowercase
@return array | [
"Returns",
"arguments",
"as",
"valid",
"PHP",
"types",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php#L717-L772 | train |
thelia/core | lib/Thelia/Action/Product.php | Product.create | public function create(ProductCreateEvent $event)
{
$defaultTaxRuleId = null;
if (null !== $defaultTaxRule = TaxRuleQuery::create()->findOneByIsDefault(true)) {
$defaultTaxRuleId = $defaultTaxRule->getId();
}
$product = new ProductModel();
$product
->setDispatcher($this->eventDispatcher)
->setRef($event->getRef())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setVisible($event->getVisible() ? 1 : 0)
->setVirtual($event->getVirtual() ? 1 : 0)
->setTemplateId($event->getTemplateId())
->create(
$event->getDefaultCategory(),
$event->getBasePrice(),
$event->getCurrencyId(),
// Set the default tax rule if not defined
$event->getTaxRuleId() ?: $defaultTaxRuleId,
$event->getBaseWeight(),
$event->getBaseQuantity()
)
;
$event->setProduct($product);
} | php | public function create(ProductCreateEvent $event)
{
$defaultTaxRuleId = null;
if (null !== $defaultTaxRule = TaxRuleQuery::create()->findOneByIsDefault(true)) {
$defaultTaxRuleId = $defaultTaxRule->getId();
}
$product = new ProductModel();
$product
->setDispatcher($this->eventDispatcher)
->setRef($event->getRef())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setVisible($event->getVisible() ? 1 : 0)
->setVirtual($event->getVirtual() ? 1 : 0)
->setTemplateId($event->getTemplateId())
->create(
$event->getDefaultCategory(),
$event->getBasePrice(),
$event->getCurrencyId(),
// Set the default tax rule if not defined
$event->getTaxRuleId() ?: $defaultTaxRuleId,
$event->getBaseWeight(),
$event->getBaseQuantity()
)
;
$event->setProduct($product);
} | [
"public",
"function",
"create",
"(",
"ProductCreateEvent",
"$",
"event",
")",
"{",
"$",
"defaultTaxRuleId",
"=",
"null",
";",
"if",
"(",
"null",
"!==",
"$",
"defaultTaxRule",
"=",
"TaxRuleQuery",
"::",
"create",
"(",
")",
"->",
"findOneByIsDefault",
"(",
"tr... | Create a new product entry
@param \Thelia\Core\Event\Product\ProductCreateEvent $event | [
"Create",
"a",
"new",
"product",
"entry"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Product.php#L91-L122 | train |
thelia/core | lib/Thelia/Action/Product.php | Product.update | public function update(ProductUpdateEvent $event)
{
if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) {
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$prevRef = $product->getRef();
$product
->setDispatcher($this->eventDispatcher)
->setRef($event->getRef())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
->setChapo($event->getChapo())
->setPostscriptum($event->getPostscriptum())
->setVisible($event->getVisible() ? 1 : 0)
->setVirtual($event->getVirtual() ? 1 : 0)
->setBrandId($event->getBrandId() <= 0 ? null : $event->getBrandId())
->save($con)
;
// Update default PSE (if product has no attributes and the product's ref change)
$defaultPseRefChange = $prevRef !== $product->getRef()
&& 0 === $product->getDefaultSaleElements()->countAttributeCombinations();
if ($defaultPseRefChange) {
$defaultPse = $product->getDefaultSaleElements();
$defaultPse->setRef($product->getRef())->save();
}
// Update default category (if required)
$product->setDefaultCategory($event->getDefaultCategory());
$event->setProduct($product);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
} | php | public function update(ProductUpdateEvent $event)
{
if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) {
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$prevRef = $product->getRef();
$product
->setDispatcher($this->eventDispatcher)
->setRef($event->getRef())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
->setChapo($event->getChapo())
->setPostscriptum($event->getPostscriptum())
->setVisible($event->getVisible() ? 1 : 0)
->setVirtual($event->getVirtual() ? 1 : 0)
->setBrandId($event->getBrandId() <= 0 ? null : $event->getBrandId())
->save($con)
;
// Update default PSE (if product has no attributes and the product's ref change)
$defaultPseRefChange = $prevRef !== $product->getRef()
&& 0 === $product->getDefaultSaleElements()->countAttributeCombinations();
if ($defaultPseRefChange) {
$defaultPse = $product->getDefaultSaleElements();
$defaultPse->setRef($product->getRef())->save();
}
// Update default category (if required)
$product->setDefaultCategory($event->getDefaultCategory());
$event->setProduct($product);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
} | [
"public",
"function",
"update",
"(",
"ProductUpdateEvent",
"$",
"event",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"product",
"=",
"ProductQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"event",
"->",
"getProductId",
"(",
")",
")",
")",
"{"... | Change a product
@param \Thelia\Core\Event\Product\ProductUpdateEvent $event
@throws PropelException
@throws \Exception | [
"Change",
"a",
"product"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Product.php#L343-L385 | train |
thelia/core | lib/Thelia/Action/Product.php | Product.delete | public function delete(ProductDeleteEvent $event)
{
if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) {
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$fileList = ['images' => [], 'documentList' => []];
// Get product's files to delete after product deletion
$fileList['images']['list'] = ProductImageQuery::create()
->findByProductId($event->getProductId());
$fileList['images']['type'] = TheliaEvents::IMAGE_DELETE;
$fileList['documentList']['list'] = ProductDocumentQuery::create()
->findByProductId($event->getProductId());
$fileList['documentList']['type'] = TheliaEvents::DOCUMENT_DELETE;
// Delete product
$product
->setDispatcher($this->eventDispatcher)
->delete($con)
;
$event->setProduct($product);
// Dispatch delete product's files event
foreach ($fileList as $fileTypeList) {
foreach ($fileTypeList['list'] as $fileToDelete) {
$fileDeleteEvent = new FileDeleteEvent($fileToDelete);
$this->eventDispatcher->dispatch($fileTypeList['type'], $fileDeleteEvent);
}
}
$con->commit();
} catch (\Exception $e) {
$con->rollBack();
throw $e;
}
}
} | php | public function delete(ProductDeleteEvent $event)
{
if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) {
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$fileList = ['images' => [], 'documentList' => []];
// Get product's files to delete after product deletion
$fileList['images']['list'] = ProductImageQuery::create()
->findByProductId($event->getProductId());
$fileList['images']['type'] = TheliaEvents::IMAGE_DELETE;
$fileList['documentList']['list'] = ProductDocumentQuery::create()
->findByProductId($event->getProductId());
$fileList['documentList']['type'] = TheliaEvents::DOCUMENT_DELETE;
// Delete product
$product
->setDispatcher($this->eventDispatcher)
->delete($con)
;
$event->setProduct($product);
// Dispatch delete product's files event
foreach ($fileList as $fileTypeList) {
foreach ($fileTypeList['list'] as $fileToDelete) {
$fileDeleteEvent = new FileDeleteEvent($fileToDelete);
$this->eventDispatcher->dispatch($fileTypeList['type'], $fileDeleteEvent);
}
}
$con->commit();
} catch (\Exception $e) {
$con->rollBack();
throw $e;
}
}
} | [
"public",
"function",
"delete",
"(",
"ProductDeleteEvent",
"$",
"event",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"product",
"=",
"ProductQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"event",
"->",
"getProductId",
"(",
")",
")",
")",
"{"... | Delete a product entry
@param \Thelia\Core\Event\Product\ProductDeleteEvent $event
@throws \Exception | [
"Delete",
"a",
"product",
"entry"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Product.php#L404-L444 | train |
thelia/core | lib/Thelia/Action/Product.php | Product.toggleVisibility | public function toggleVisibility(ProductToggleVisibilityEvent $event)
{
$product = $event->getProduct();
$product
->setDispatcher($this->eventDispatcher)
->setVisible($product->getVisible() ? false : true)
->save()
;
$event->setProduct($product);
} | php | public function toggleVisibility(ProductToggleVisibilityEvent $event)
{
$product = $event->getProduct();
$product
->setDispatcher($this->eventDispatcher)
->setVisible($product->getVisible() ? false : true)
->save()
;
$event->setProduct($product);
} | [
"public",
"function",
"toggleVisibility",
"(",
"ProductToggleVisibilityEvent",
"$",
"event",
")",
"{",
"$",
"product",
"=",
"$",
"event",
"->",
"getProduct",
"(",
")",
";",
"$",
"product",
"->",
"setDispatcher",
"(",
"$",
"this",
"->",
"eventDispatcher",
")",
... | Toggle product visibility. No form used here
@param ProductToggleVisibilityEvent $event | [
"Toggle",
"product",
"visibility",
".",
"No",
"form",
"used",
"here"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Product.php#L451-L462 | train |
thelia/core | lib/Thelia/Action/Product.php | Product.updateAccessoryPosition | public function updateAccessoryPosition(UpdatePositionEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
return $this->genericUpdatePosition(AccessoryQuery::create(), $event, $dispatcher);
} | php | public function updateAccessoryPosition(UpdatePositionEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
return $this->genericUpdatePosition(AccessoryQuery::create(), $event, $dispatcher);
} | [
"public",
"function",
"updateAccessoryPosition",
"(",
"UpdatePositionEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"return",
"$",
"this",
"->",
"genericUpdatePosition",
"(",
"AccessoryQuery",
"::",
"create",... | Changes accessry position, selecting absolute ou relative change.
@param UpdatePositionEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher
@return Object | [
"Changes",
"accessry",
"position",
"selecting",
"absolute",
"ou",
"relative",
"change",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Product.php#L677-L680 | train |
thelia/core | lib/Thelia/Action/Product.php | Product.deleteFeatureProductValue | public function deleteFeatureProductValue(FeatureProductDeleteEvent $event)
{
FeatureProductQuery::create()
->filterByProductId($event->getProductId())
->filterByFeatureId($event->getFeatureId())
->delete()
;
} | php | public function deleteFeatureProductValue(FeatureProductDeleteEvent $event)
{
FeatureProductQuery::create()
->filterByProductId($event->getProductId())
->filterByFeatureId($event->getFeatureId())
->delete()
;
} | [
"public",
"function",
"deleteFeatureProductValue",
"(",
"FeatureProductDeleteEvent",
"$",
"event",
")",
"{",
"FeatureProductQuery",
"::",
"create",
"(",
")",
"->",
"filterByProductId",
"(",
"$",
"event",
"->",
"getProductId",
"(",
")",
")",
"->",
"filterByFeatureId"... | Delete a product feature value
@param FeatureProductDeleteEvent $event | [
"Delete",
"a",
"product",
"feature",
"value"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Product.php#L804-L811 | train |
thelia/core | lib/Thelia/Action/Product.php | Product.deleteTemplateFeature | public function deleteTemplateFeature(TemplateDeleteFeatureEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
// Detete the removed feature in all products which are using this template
$products = ProductQuery::create()
->filterByTemplateId($event->getTemplate()->getId())
->find()
;
foreach ($products as $product) {
$dispatcher->dispatch(
TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE,
new FeatureProductDeleteEvent($product->getId(), $event->getFeatureId())
);
}
} | php | public function deleteTemplateFeature(TemplateDeleteFeatureEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
// Detete the removed feature in all products which are using this template
$products = ProductQuery::create()
->filterByTemplateId($event->getTemplate()->getId())
->find()
;
foreach ($products as $product) {
$dispatcher->dispatch(
TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE,
new FeatureProductDeleteEvent($product->getId(), $event->getFeatureId())
);
}
} | [
"public",
"function",
"deleteTemplateFeature",
"(",
"TemplateDeleteFeatureEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"// Detete the removed feature in all products which are using this template",
"$",
"products",
"... | When a feature is removed from a template, the products which are using this feature should be updated.
@param TemplateDeleteFeatureEvent $event
@param string $eventName
@param EventDispatcherInterface $dispatcher | [
"When",
"a",
"feature",
"is",
"removed",
"from",
"a",
"template",
"the",
"products",
"which",
"are",
"using",
"this",
"feature",
"should",
"be",
"updated",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Product.php#L838-L852 | train |
thelia/core | lib/Thelia/Action/Product.php | Product.deleteTemplateAttribute | public function deleteTemplateAttribute(TemplateDeleteAttributeEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
// Detete the removed attribute in all products which are using this template
$pseToDelete = ProductSaleElementsQuery::create()
->useProductQuery()
->filterByTemplateId($event->getTemplate()->getId())
->endUse()
->useAttributeCombinationQuery()
->filterByAttributeId($event->getAttributeId())
->endUse()
->select([ ProductSaleElementsTableMap::COL_ID ])
->find();
$currencyId = CurrencyModel::getDefaultCurrency()->getId();
foreach ($pseToDelete->getData() as $pseId) {
$dispatcher->dispatch(
TheliaEvents::PRODUCT_DELETE_PRODUCT_SALE_ELEMENT,
new ProductSaleElementDeleteEvent(
$pseId,
$currencyId
)
);
}
} | php | public function deleteTemplateAttribute(TemplateDeleteAttributeEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
// Detete the removed attribute in all products which are using this template
$pseToDelete = ProductSaleElementsQuery::create()
->useProductQuery()
->filterByTemplateId($event->getTemplate()->getId())
->endUse()
->useAttributeCombinationQuery()
->filterByAttributeId($event->getAttributeId())
->endUse()
->select([ ProductSaleElementsTableMap::COL_ID ])
->find();
$currencyId = CurrencyModel::getDefaultCurrency()->getId();
foreach ($pseToDelete->getData() as $pseId) {
$dispatcher->dispatch(
TheliaEvents::PRODUCT_DELETE_PRODUCT_SALE_ELEMENT,
new ProductSaleElementDeleteEvent(
$pseId,
$currencyId
)
);
}
} | [
"public",
"function",
"deleteTemplateAttribute",
"(",
"TemplateDeleteAttributeEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"// Detete the removed attribute in all products which are using this template",
"$",
"pseToDel... | When an attribute is removed from a template, the conbinations and PSE of products which are using this template
should be updated.
@param TemplateDeleteAttributeEvent $event
@param string $eventName
@param EventDispatcherInterface $dispatcher | [
"When",
"an",
"attribute",
"is",
"removed",
"from",
"a",
"template",
"the",
"conbinations",
"and",
"PSE",
"of",
"products",
"which",
"are",
"using",
"this",
"template",
"should",
"be",
"updated",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Product.php#L862-L886 | train |
thelia/core | lib/Thelia/Action/Product.php | Product.viewCheck | public function viewCheck(ViewCheckEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if ($event->getView() == 'product') {
$product = ProductQuery::create()
->filterById($event->getViewId())
->filterByVisible(1)
->count();
if ($product == 0) {
$dispatcher->dispatch(TheliaEvents::VIEW_PRODUCT_ID_NOT_VISIBLE, $event);
}
}
} | php | public function viewCheck(ViewCheckEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if ($event->getView() == 'product') {
$product = ProductQuery::create()
->filterById($event->getViewId())
->filterByVisible(1)
->count();
if ($product == 0) {
$dispatcher->dispatch(TheliaEvents::VIEW_PRODUCT_ID_NOT_VISIBLE, $event);
}
}
} | [
"public",
"function",
"viewCheck",
"(",
"ViewCheckEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"getView",
"(",
")",
"==",
"'product'",
")",
"{",
"$",
"product",
"=... | Check if is a product view and if product_id is visible
@param ViewCheckEvent $event
@param string $eventName
@param EventDispatcherInterface $dispatcher | [
"Check",
"if",
"is",
"a",
"product",
"view",
"and",
"if",
"product_id",
"is",
"visible"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Product.php#L895-L907 | train |
thelia/core | lib/Thelia/Form/CouponCreationForm.php | CouponCreationForm.checkDuplicateCouponCode | public function checkDuplicateCouponCode($value, ExecutionContextInterface $context)
{
$exists = CouponQuery::create()->filterByCode($value)->count() > 0;
if ($exists) {
$context->addViolation(
Translator::getInstance()->trans(
"The coupon code '%code' already exists. Please choose another coupon code",
['%code' => $value]
)
);
}
} | php | public function checkDuplicateCouponCode($value, ExecutionContextInterface $context)
{
$exists = CouponQuery::create()->filterByCode($value)->count() > 0;
if ($exists) {
$context->addViolation(
Translator::getInstance()->trans(
"The coupon code '%code' already exists. Please choose another coupon code",
['%code' => $value]
)
);
}
} | [
"public",
"function",
"checkDuplicateCouponCode",
"(",
"$",
"value",
",",
"ExecutionContextInterface",
"$",
"context",
")",
"{",
"$",
"exists",
"=",
"CouponQuery",
"::",
"create",
"(",
")",
"->",
"filterByCode",
"(",
"$",
"value",
")",
"->",
"count",
"(",
")... | Check coupon code unicity
@param string $value
@param ExecutionContextInterface $context | [
"Check",
"coupon",
"code",
"unicity"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Form/CouponCreationForm.php#L261-L273 | train |
thelia/core | lib/Thelia/Form/CouponCreationForm.php | CouponCreationForm.checkLocalizedDate | public function checkLocalizedDate($value, ExecutionContextInterface $context)
{
$format = LangQuery::create()->findOneByByDefault(true)->getDatetimeFormat();
if (false === \DateTime::createFromFormat($format, $value)) {
$context->addViolation(
Translator::getInstance()->trans(
"Date '%date' is invalid, please enter a valid date using %fmt format",
[
'%fmt' => $format,
'%date' => $value
]
)
);
}
} | php | public function checkLocalizedDate($value, ExecutionContextInterface $context)
{
$format = LangQuery::create()->findOneByByDefault(true)->getDatetimeFormat();
if (false === \DateTime::createFromFormat($format, $value)) {
$context->addViolation(
Translator::getInstance()->trans(
"Date '%date' is invalid, please enter a valid date using %fmt format",
[
'%fmt' => $format,
'%date' => $value
]
)
);
}
} | [
"public",
"function",
"checkLocalizedDate",
"(",
"$",
"value",
",",
"ExecutionContextInterface",
"$",
"context",
")",
"{",
"$",
"format",
"=",
"LangQuery",
"::",
"create",
"(",
")",
"->",
"findOneByByDefault",
"(",
"true",
")",
"->",
"getDatetimeFormat",
"(",
... | Validate a date entered with the default Language date format.
@param string $value
@param ExecutionContextInterface $context | [
"Validate",
"a",
"date",
"entered",
"with",
"the",
"default",
"Language",
"date",
"format",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Form/CouponCreationForm.php#L296-L311 | train |
thelia/core | lib/Thelia/Module/Validator/ModuleValidator.php | ModuleValidator.getModulesDependOf | public function getModulesDependOf($active = true)
{
$code = $this->getModuleDefinition()->getCode();
$query = ModuleQuery::create();
$dependantModules = [];
if (true === $active) {
$query->findByActivate(1);
} elseif (false === $active) {
$query->findByActivate(0);
}
$modules = $query->find();
/** @var Module $module */
foreach ($modules as $module) {
try {
$validator = new ModuleValidator($module->getAbsoluteBaseDir());
$definition = $validator->getModuleDefinition();
$dependencies = $definition->getDependencies();
if (\count($dependencies) > 0) {
foreach ($dependencies as $dependency) {
if ($dependency[0] == $code) {
$dependantModules[] = [
'code' => $definition->getCode(),
'version' => $dependency[1]
];
break;
}
}
}
} catch (\Exception $ex) {
;
}
}
return $dependantModules;
} | php | public function getModulesDependOf($active = true)
{
$code = $this->getModuleDefinition()->getCode();
$query = ModuleQuery::create();
$dependantModules = [];
if (true === $active) {
$query->findByActivate(1);
} elseif (false === $active) {
$query->findByActivate(0);
}
$modules = $query->find();
/** @var Module $module */
foreach ($modules as $module) {
try {
$validator = new ModuleValidator($module->getAbsoluteBaseDir());
$definition = $validator->getModuleDefinition();
$dependencies = $definition->getDependencies();
if (\count($dependencies) > 0) {
foreach ($dependencies as $dependency) {
if ($dependency[0] == $code) {
$dependantModules[] = [
'code' => $definition->getCode(),
'version' => $dependency[1]
];
break;
}
}
}
} catch (\Exception $ex) {
;
}
}
return $dependantModules;
} | [
"public",
"function",
"getModulesDependOf",
"(",
"$",
"active",
"=",
"true",
")",
"{",
"$",
"code",
"=",
"$",
"this",
"->",
"getModuleDefinition",
"(",
")",
"->",
"getCode",
"(",
")",
";",
"$",
"query",
"=",
"ModuleQuery",
"::",
"create",
"(",
")",
";"... | Get an array of modules that depend of the current module
@param bool|null $active if true only search in activated module, false only deactivated and null on all modules
@return array array of array with `code` which is the module code that depends of this current module and
`version` which is the required version of current module | [
"Get",
"an",
"array",
"of",
"modules",
"that",
"depend",
"of",
"the",
"current",
"module"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Module/Validator/ModuleValidator.php#L348-L388 | train |
thelia/core | lib/Thelia/Module/Validator/ModuleValidator.php | ModuleValidator.getCurrentModuleDependencies | public function getCurrentModuleDependencies($recursive = false)
{
if (empty($this->moduleDescriptor->required)) {
return [];
}
$dependencies = [];
foreach ($this->moduleDescriptor->required->module as $dependency) {
$dependencyArray = [
"code" => (string)$dependency,
"version" => (string)$dependency['version'],
];
if (!\in_array($dependencyArray, $dependencies)) {
$dependencies[] = $dependencyArray;
}
if ($recursive) {
$recursiveModuleValidator = new ModuleValidator(THELIA_MODULE_DIR . '/' . (string)$dependency);
array_merge(
$dependencies,
$recursiveModuleValidator->getCurrentModuleDependencies(true)
);
}
}
return $dependencies;
} | php | public function getCurrentModuleDependencies($recursive = false)
{
if (empty($this->moduleDescriptor->required)) {
return [];
}
$dependencies = [];
foreach ($this->moduleDescriptor->required->module as $dependency) {
$dependencyArray = [
"code" => (string)$dependency,
"version" => (string)$dependency['version'],
];
if (!\in_array($dependencyArray, $dependencies)) {
$dependencies[] = $dependencyArray;
}
if ($recursive) {
$recursiveModuleValidator = new ModuleValidator(THELIA_MODULE_DIR . '/' . (string)$dependency);
array_merge(
$dependencies,
$recursiveModuleValidator->getCurrentModuleDependencies(true)
);
}
}
return $dependencies;
} | [
"public",
"function",
"getCurrentModuleDependencies",
"(",
"$",
"recursive",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"moduleDescriptor",
"->",
"required",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"dependencies",
"=",
... | Get the dependencies of this module.
@param bool $recursive Whether to also get the dependencies of dependencies, their dependencies, and so on...
@return array Array of dependencies as ["code" => ..., "version" => ...]. No check for duplicates is made. | [
"Get",
"the",
"dependencies",
"of",
"this",
"module",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Module/Validator/ModuleValidator.php#L395-L421 | train |
grom358/pharborist | src/Node.php | Node.sortKey | public function sortKey() {
if ($this instanceof RootNode) {
return spl_object_hash($this);
}
if (!$this->parent) {
return '~/' . spl_object_hash($this);
}
$path = $this->parent->sortKey() . '/';
$position = 0;
$previous = $this->previous;
while ($previous) {
$position++;
$previous = $previous->previous;
}
$path .= $position;
return $path;
} | php | public function sortKey() {
if ($this instanceof RootNode) {
return spl_object_hash($this);
}
if (!$this->parent) {
return '~/' . spl_object_hash($this);
}
$path = $this->parent->sortKey() . '/';
$position = 0;
$previous = $this->previous;
while ($previous) {
$position++;
$previous = $previous->previous;
}
$path .= $position;
return $path;
} | [
"public",
"function",
"sortKey",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"instanceof",
"RootNode",
")",
"{",
"return",
"spl_object_hash",
"(",
"$",
"this",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"parent",
")",
"{",
"return",
"'~/'",
".",
... | Get a unique key for sorting this node.
Used to sort nodes into tree order. That is top to bottom and then left
to right.
@return string | [
"Get",
"a",
"unique",
"key",
"for",
"sorting",
"this",
"node",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Node.php#L451-L467 | train |
grom358/pharborist | src/Node.php | Node.is | public function is($test) {
if (is_callable($test)) {
return (boolean) $test($this);
}
elseif (is_string($test)) {
return $this->is(Filter::isInstanceOf($test));
}
else {
throw new \InvalidArgumentException();
}
} | php | public function is($test) {
if (is_callable($test)) {
return (boolean) $test($this);
}
elseif (is_string($test)) {
return $this->is(Filter::isInstanceOf($test));
}
else {
throw new \InvalidArgumentException();
}
} | [
"public",
"function",
"is",
"(",
"$",
"test",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"test",
")",
")",
"{",
"return",
"(",
"boolean",
")",
"$",
"test",
"(",
"$",
"this",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"test",
")",
"... | Tests this node against a condition.
@param callable|string $test
Either a callback function to test the node against, or a class name
(wrapper around instanceof). Eventually this will accept a callable
or a filter query (issue #61).
@return boolean
@throws \InvalidArgumentException | [
"Tests",
"this",
"node",
"against",
"a",
"condition",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Node.php#L481-L491 | train |
grom358/pharborist | src/Node.php | Node.isAnyOf | public function isAnyOf(array $tests) {
foreach ($tests as $test) {
if ($this->is($test)) {
return TRUE;
}
}
return FALSE;
} | php | public function isAnyOf(array $tests) {
foreach ($tests as $test) {
if ($this->is($test)) {
return TRUE;
}
}
return FALSE;
} | [
"public",
"function",
"isAnyOf",
"(",
"array",
"$",
"tests",
")",
"{",
"foreach",
"(",
"$",
"tests",
"as",
"$",
"test",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is",
"(",
"$",
"test",
")",
")",
"{",
"return",
"TRUE",
";",
"}",
"}",
"return",
"F... | Tests if this node matches any the tests in the array.
@param string|callable[] $tests
@return boolean | [
"Tests",
"if",
"this",
"node",
"matches",
"any",
"the",
"tests",
"in",
"the",
"array",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Node.php#L500-L507 | train |
grom358/pharborist | src/Node.php | Node.isAllOf | public function isAllOf(array $tests) {
foreach ($tests as $test) {
if (! $this->is($test)) {
return FALSE;
}
}
return TRUE;
} | php | public function isAllOf(array $tests) {
foreach ($tests as $test) {
if (! $this->is($test)) {
return FALSE;
}
}
return TRUE;
} | [
"public",
"function",
"isAllOf",
"(",
"array",
"$",
"tests",
")",
"{",
"foreach",
"(",
"$",
"tests",
"as",
"$",
"test",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"is",
"(",
"$",
"test",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"}",
"retur... | Tests if this node matches all of the tests in the array.
@param string|callable[] $tests
@return boolean | [
"Tests",
"if",
"this",
"node",
"matches",
"all",
"of",
"the",
"tests",
"in",
"the",
"array",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Node.php#L516-L523 | train |
grom358/pharborist | src/Node.php | Node.fromValue | public static function fromValue($value) {
if (is_array($value)) {
$elements = [];
foreach ($value as $k => $v) {
$elements[] = ArrayPairNode::create(static::fromValue($k), static::fromValue($v));
}
return ArrayNode::create($elements);
}
elseif (is_string($value)) {
return StringNode::create(var_export($value, TRUE));
}
elseif (is_integer($value)) {
return new IntegerNode(T_LNUMBER, $value);
}
elseif (is_float($value)) {
return new FloatNode(T_DNUMBER, $value);
}
elseif (is_bool($value)) {
return BooleanNode::create($value);
}
elseif (is_null($value)) {
return NullNode::create('NULL');
}
else {
throw new \InvalidArgumentException();
}
} | php | public static function fromValue($value) {
if (is_array($value)) {
$elements = [];
foreach ($value as $k => $v) {
$elements[] = ArrayPairNode::create(static::fromValue($k), static::fromValue($v));
}
return ArrayNode::create($elements);
}
elseif (is_string($value)) {
return StringNode::create(var_export($value, TRUE));
}
elseif (is_integer($value)) {
return new IntegerNode(T_LNUMBER, $value);
}
elseif (is_float($value)) {
return new FloatNode(T_DNUMBER, $value);
}
elseif (is_bool($value)) {
return BooleanNode::create($value);
}
elseif (is_null($value)) {
return NullNode::create('NULL');
}
else {
throw new \InvalidArgumentException();
}
} | [
"public",
"static",
"function",
"fromValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"elements",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",... | Creates a Node from a php value.
@param string|integer|float|boolean|array|null $value
The value to create a node for.
@return FloatNode|IntegerNode|StringNode|BooleanNode|NullNode|ArrayNode
@throws \InvalidArgumentException if $value is not a scalar. | [
"Creates",
"a",
"Node",
"from",
"a",
"php",
"value",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Node.php#L548-L574 | train |
thelia/core | lib/Thelia/Log/Tlog.php | Tlog.init | protected function init()
{
$this->setLevel(ConfigQuery::read(self::VAR_LEVEL, self::DEFAULT_LEVEL));
$this->dir_destinations = array(
__DIR__.DS.'Destination',
THELIA_LOCAL_DIR.'tlog'.DS.'destinations'
);
$this->setPrefix(ConfigQuery::read(self::VAR_PREFIXE, self::DEFAUT_PREFIXE));
$this->setFiles(ConfigQuery::read(self::VAR_FILES, self::DEFAUT_FILES));
$this->setIp(ConfigQuery::read(self::VAR_IP, self::DEFAUT_IP));
$this->setDestinations(ConfigQuery::read(self::VAR_DESTINATIONS, self::DEFAUT_DESTINATIONS));
$this->setShowRedirect(ConfigQuery::read(self::VAR_SHOW_REDIRECT, self::DEFAUT_SHOW_REDIRECT));
// Au cas ou il y aurait un exit() quelque part dans le code.
register_shutdown_function(array($this, 'writeOnExit'));
} | php | protected function init()
{
$this->setLevel(ConfigQuery::read(self::VAR_LEVEL, self::DEFAULT_LEVEL));
$this->dir_destinations = array(
__DIR__.DS.'Destination',
THELIA_LOCAL_DIR.'tlog'.DS.'destinations'
);
$this->setPrefix(ConfigQuery::read(self::VAR_PREFIXE, self::DEFAUT_PREFIXE));
$this->setFiles(ConfigQuery::read(self::VAR_FILES, self::DEFAUT_FILES));
$this->setIp(ConfigQuery::read(self::VAR_IP, self::DEFAUT_IP));
$this->setDestinations(ConfigQuery::read(self::VAR_DESTINATIONS, self::DEFAUT_DESTINATIONS));
$this->setShowRedirect(ConfigQuery::read(self::VAR_SHOW_REDIRECT, self::DEFAUT_SHOW_REDIRECT));
// Au cas ou il y aurait un exit() quelque part dans le code.
register_shutdown_function(array($this, 'writeOnExit'));
} | [
"protected",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"setLevel",
"(",
"ConfigQuery",
"::",
"read",
"(",
"self",
"::",
"VAR_LEVEL",
",",
"self",
"::",
"DEFAULT_LEVEL",
")",
")",
";",
"$",
"this",
"->",
"dir_destinations",
"=",
"array",
"(",
... | initialize default configuration | [
"initialize",
"default",
"configuration"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Log/Tlog.php#L135-L152 | train |
thelia/core | lib/Thelia/Command/ExportCommand.php | ExportCommand.listExport | protected function listExport(OutputInterface $output)
{
$table = new Table($output);
foreach ((new ExportQuery)->find() as $export) {
$table->addRow([
$export->getRef(),
$export->getTitle(),
$export->getDescription()
]);
}
$table
->setHeaders([
'Reference',
'Title',
'Description'
])
->render()
;
} | php | protected function listExport(OutputInterface $output)
{
$table = new Table($output);
foreach ((new ExportQuery)->find() as $export) {
$table->addRow([
$export->getRef(),
$export->getTitle(),
$export->getDescription()
]);
}
$table
->setHeaders([
'Reference',
'Title',
'Description'
])
->render()
;
} | [
"protected",
"function",
"listExport",
"(",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"table",
"=",
"new",
"Table",
"(",
"$",
"output",
")",
";",
"foreach",
"(",
"(",
"new",
"ExportQuery",
")",
"->",
"find",
"(",
")",
"as",
"$",
"export",
")",
... | Output available exports
@param \Symfony\Component\Console\Output\OutputInterface $output An output interface | [
"Output",
"available",
"exports"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Command/ExportCommand.php#L154-L174 | train |
thelia/core | lib/Thelia/Command/ExportCommand.php | ExportCommand.listSerializer | protected function listSerializer(OutputInterface $output)
{
$table = new Table($output);
/** @var SerializerManager $serializerManager */
$serializerManager = $this->getContainer()->get(RegisterSerializerPass::MANAGER_SERVICE_ID);
/** @var SerializerInterface $serializer */
foreach ($serializerManager->getSerializers() as $serializer) {
$table->addRow([
$serializer->getId(),
$serializer->getName(),
$serializer->getExtension(),
$serializer->getMimeType()
]);
}
$table
->setHeaders([
'Id',
'Name',
'Extension',
'MIME type'
])
->render()
;
} | php | protected function listSerializer(OutputInterface $output)
{
$table = new Table($output);
/** @var SerializerManager $serializerManager */
$serializerManager = $this->getContainer()->get(RegisterSerializerPass::MANAGER_SERVICE_ID);
/** @var SerializerInterface $serializer */
foreach ($serializerManager->getSerializers() as $serializer) {
$table->addRow([
$serializer->getId(),
$serializer->getName(),
$serializer->getExtension(),
$serializer->getMimeType()
]);
}
$table
->setHeaders([
'Id',
'Name',
'Extension',
'MIME type'
])
->render()
;
} | [
"protected",
"function",
"listSerializer",
"(",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"table",
"=",
"new",
"Table",
"(",
"$",
"output",
")",
";",
"/** @var SerializerManager $serializerManager */",
"$",
"serializerManager",
"=",
"$",
"this",
"->",
"getC... | Output available serializers
@param \Symfony\Component\Console\Output\OutputInterface $output An output interface | [
"Output",
"available",
"serializers"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Command/ExportCommand.php#L181-L207 | train |
thelia/core | lib/Thelia/Command/ExportCommand.php | ExportCommand.listArchiver | protected function listArchiver(OutputInterface $output)
{
$table = new Table($output);
/** @var ArchiverManager $archiverManager */
$archiverManager = $this->getContainer()->get(RegisterArchiverPass::MANAGER_SERVICE_ID);
/** @var ArchiverInterface $archiver */
foreach ($archiverManager->getArchivers(true) as $archiver) {
$table->addRow([
$archiver->getId(),
$archiver->getName(),
$archiver->getExtension(),
$archiver->getMimeType()
]);
}
$table
->setHeaders([
'Id',
'Name',
'Extension',
'MIME type'
])
->render()
;
} | php | protected function listArchiver(OutputInterface $output)
{
$table = new Table($output);
/** @var ArchiverManager $archiverManager */
$archiverManager = $this->getContainer()->get(RegisterArchiverPass::MANAGER_SERVICE_ID);
/** @var ArchiverInterface $archiver */
foreach ($archiverManager->getArchivers(true) as $archiver) {
$table->addRow([
$archiver->getId(),
$archiver->getName(),
$archiver->getExtension(),
$archiver->getMimeType()
]);
}
$table
->setHeaders([
'Id',
'Name',
'Extension',
'MIME type'
])
->render()
;
} | [
"protected",
"function",
"listArchiver",
"(",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"table",
"=",
"new",
"Table",
"(",
"$",
"output",
")",
";",
"/** @var ArchiverManager $archiverManager */",
"$",
"archiverManager",
"=",
"$",
"this",
"->",
"getContainer... | Output available archivers
@param \Symfony\Component\Console\Output\OutputInterface $output An output interface | [
"Output",
"available",
"archivers"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Command/ExportCommand.php#L214-L240 | train |
thelia/core | lib/Thelia/Core/HttpFoundation/Session/Session.php | Session.getCurrency | public function getCurrency($forceDefault = true)
{
$currency = $this->get("thelia.current.currency");
if (null === $currency && $forceDefault) {
$currency = Currency::getDefaultCurrency();
}
return $currency;
} | php | public function getCurrency($forceDefault = true)
{
$currency = $this->get("thelia.current.currency");
if (null === $currency && $forceDefault) {
$currency = Currency::getDefaultCurrency();
}
return $currency;
} | [
"public",
"function",
"getCurrency",
"(",
"$",
"forceDefault",
"=",
"true",
")",
"{",
"$",
"currency",
"=",
"$",
"this",
"->",
"get",
"(",
"\"thelia.current.currency\"",
")",
";",
"if",
"(",
"null",
"===",
"$",
"currency",
"&&",
"$",
"forceDefault",
")",
... | Return current currency
@param bool $forceDefault if true, the default currency will be returned if no current currency is defined.
@return Currency | [
"Return",
"current",
"currency"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/HttpFoundation/Session/Session.php#L81-L90 | train |
thelia/core | lib/Thelia/Core/HttpFoundation/Session/Session.php | Session.setSessionCart | public function setSessionCart(Cart $cart = null)
{
if (null === $cart || $cart->isNew()) {
self::$transientCart = $cart;
$this->remove("thelia.cart_id");
} else {
self::$transientCart = null;
$this->set("thelia.cart_id", $cart->getId());
}
return $this;
} | php | public function setSessionCart(Cart $cart = null)
{
if (null === $cart || $cart->isNew()) {
self::$transientCart = $cart;
$this->remove("thelia.cart_id");
} else {
self::$transientCart = null;
$this->set("thelia.cart_id", $cart->getId());
}
return $this;
} | [
"public",
"function",
"setSessionCart",
"(",
"Cart",
"$",
"cart",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"cart",
"||",
"$",
"cart",
"->",
"isNew",
"(",
")",
")",
"{",
"self",
"::",
"$",
"transientCart",
"=",
"$",
"cart",
";",
"$",
... | Set the cart to store in the current session.
@param Cart|null The cart to store in session
@return $this | [
"Set",
"the",
"cart",
"to",
"store",
"in",
"the",
"current",
"session",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/HttpFoundation/Session/Session.php#L223-L234 | train |
thelia/core | lib/Thelia/Core/HttpFoundation/Session/Session.php | Session.getSessionCart | public function getSessionCart(EventDispatcherInterface $dispatcher = null)
{
$cart_id = $this->get("thelia.cart_id", null);
if (null !== $cart_id) {
$cart = CartQuery::create()->findPk($cart_id);
} else {
$cart = self::$transientCart;
}
// If we do not have a cart, or if the current cart is nor valid
// restore it from the cart cookie, or create a new one
if (null === $cart || ! $this->isValidCart($cart)) {
// A dispatcher is required here. If we do not have it, throw an exception
// This is a temporary workaround to ensure backward compatibility with getCart(),
// When genCart() will be removed, this check should be removed, and $dispatcher should become
// a required parameter.
if (null == $dispatcher) {
throw new \InvalidArgumentException(
"In this context (no cart in session), an EventDispatcher should be provided to Session::getSessionCart()."
);
}
$cartEvent = new CartRestoreEvent();
if (null !== $cart) {
$cartEvent->setCart($cart);
}
$dispatcher->dispatch(TheliaEvents::CART_RESTORE_CURRENT, $cartEvent);
if (null === $cart = $cartEvent->getCart()) {
throw new \LogicException(
"Unable to get a Cart."
);
}
// Store the cart.
$this->setSessionCart($cart);
}
return $cart;
} | php | public function getSessionCart(EventDispatcherInterface $dispatcher = null)
{
$cart_id = $this->get("thelia.cart_id", null);
if (null !== $cart_id) {
$cart = CartQuery::create()->findPk($cart_id);
} else {
$cart = self::$transientCart;
}
// If we do not have a cart, or if the current cart is nor valid
// restore it from the cart cookie, or create a new one
if (null === $cart || ! $this->isValidCart($cart)) {
// A dispatcher is required here. If we do not have it, throw an exception
// This is a temporary workaround to ensure backward compatibility with getCart(),
// When genCart() will be removed, this check should be removed, and $dispatcher should become
// a required parameter.
if (null == $dispatcher) {
throw new \InvalidArgumentException(
"In this context (no cart in session), an EventDispatcher should be provided to Session::getSessionCart()."
);
}
$cartEvent = new CartRestoreEvent();
if (null !== $cart) {
$cartEvent->setCart($cart);
}
$dispatcher->dispatch(TheliaEvents::CART_RESTORE_CURRENT, $cartEvent);
if (null === $cart = $cartEvent->getCart()) {
throw new \LogicException(
"Unable to get a Cart."
);
}
// Store the cart.
$this->setSessionCart($cart);
}
return $cart;
} | [
"public",
"function",
"getSessionCart",
"(",
"EventDispatcherInterface",
"$",
"dispatcher",
"=",
"null",
")",
"{",
"$",
"cart_id",
"=",
"$",
"this",
"->",
"get",
"(",
"\"thelia.cart_id\"",
",",
"null",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"cart_id",
")... | Return the cart stored in the current session
@param EventDispatcherInterface $dispatcher the event dispatcher, required if no cart is currently stored in the session
@return Cart The cart in the current session. | [
"Return",
"the",
"cart",
"stored",
"in",
"the",
"current",
"session"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/HttpFoundation/Session/Session.php#L244-L286 | train |
thelia/core | lib/Thelia/Core/HttpFoundation/Session/Session.php | Session.clearSessionCart | public function clearSessionCart(EventDispatcherInterface $dispatcher)
{
$event = new CartCreateEvent();
$dispatcher->dispatch(TheliaEvents::CART_CREATE_NEW, $event);
if (null === $cart = $event->getCart()) {
throw new \LogicException(
"Unable to get a new empty Cart."
);
}
// Store the cart
$this->setSessionCart($cart);
} | php | public function clearSessionCart(EventDispatcherInterface $dispatcher)
{
$event = new CartCreateEvent();
$dispatcher->dispatch(TheliaEvents::CART_CREATE_NEW, $event);
if (null === $cart = $event->getCart()) {
throw new \LogicException(
"Unable to get a new empty Cart."
);
}
// Store the cart
$this->setSessionCart($cart);
} | [
"public",
"function",
"clearSessionCart",
"(",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"event",
"=",
"new",
"CartCreateEvent",
"(",
")",
";",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"TheliaEvents",
"::",
"CART_CREATE_NEW",
",",
"$",
"even... | Clear the current session cart, and store a new, empty one in the session.
@param EventDispatcherInterface $dispatcher | [
"Clear",
"the",
"current",
"session",
"cart",
"and",
"store",
"a",
"new",
"empty",
"one",
"in",
"the",
"session",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/HttpFoundation/Session/Session.php#L293-L307 | train |
thelia/core | lib/Thelia/Core/HttpFoundation/Session/Session.php | Session.isValidCart | protected function isValidCart(Cart $cart)
{
$customer = $this->getCustomerUser();
return (null !== $customer && $cart->getCustomerId() == $customer->getId())
||
(null === $customer && $cart->getCustomerId() === null);
} | php | protected function isValidCart(Cart $cart)
{
$customer = $this->getCustomerUser();
return (null !== $customer && $cart->getCustomerId() == $customer->getId())
||
(null === $customer && $cart->getCustomerId() === null);
} | [
"protected",
"function",
"isValidCart",
"(",
"Cart",
"$",
"cart",
")",
"{",
"$",
"customer",
"=",
"$",
"this",
"->",
"getCustomerUser",
"(",
")",
";",
"return",
"(",
"null",
"!==",
"$",
"customer",
"&&",
"$",
"cart",
"->",
"getCustomerId",
"(",
")",
"=... | A cart is valid if its customer ID is the same as the current logged in user
@param Cart $cart The cart to check
@return bool true if the cart is valid, false otherwise | [
"A",
"cart",
"is",
"valid",
"if",
"its",
"customer",
"ID",
"is",
"the",
"same",
"as",
"the",
"current",
"logged",
"in",
"user"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/HttpFoundation/Session/Session.php#L332-L339 | train |
thelia/core | lib/Thelia/Action/Coupon.php | Coupon.create | public function create(CouponCreateOrUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$coupon = new CouponModel();
$this->createOrUpdate($coupon, $event, $dispatcher);
} | php | public function create(CouponCreateOrUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$coupon = new CouponModel();
$this->createOrUpdate($coupon, $event, $dispatcher);
} | [
"public",
"function",
"create",
"(",
"CouponCreateOrUpdateEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"coupon",
"=",
"new",
"CouponModel",
"(",
")",
";",
"$",
"this",
"->",
"createOrUpdate",
"... | Occurring when a Coupon is about to be created
@param CouponCreateOrUpdateEvent $event Event creation or update Coupon
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Occurring",
"when",
"a",
"Coupon",
"is",
"about",
"to",
"be",
"created"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Coupon.php#L89-L94 | train |
thelia/core | lib/Thelia/Action/Coupon.php | Coupon.update | public function update(CouponCreateOrUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$coupon = $event->getCouponModel();
$this->createOrUpdate($coupon, $event, $dispatcher);
} | php | public function update(CouponCreateOrUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$coupon = $event->getCouponModel();
$this->createOrUpdate($coupon, $event, $dispatcher);
} | [
"public",
"function",
"update",
"(",
"CouponCreateOrUpdateEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"coupon",
"=",
"$",
"event",
"->",
"getCouponModel",
"(",
")",
";",
"$",
"this",
"->",
"... | Occurring when a Coupon is about to be updated
@param CouponCreateOrUpdateEvent $event Event creation or update Coupon
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Occurring",
"when",
"a",
"Coupon",
"is",
"about",
"to",
"be",
"updated"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Coupon.php#L103-L108 | train |
thelia/core | lib/Thelia/Action/Coupon.php | Coupon.updateCondition | public function updateCondition(CouponCreateOrUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$modelCoupon = $event->getCouponModel();
$this->createOrUpdateCondition($modelCoupon, $event, $dispatcher);
} | php | public function updateCondition(CouponCreateOrUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$modelCoupon = $event->getCouponModel();
$this->createOrUpdateCondition($modelCoupon, $event, $dispatcher);
} | [
"public",
"function",
"updateCondition",
"(",
"CouponCreateOrUpdateEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"modelCoupon",
"=",
"$",
"event",
"->",
"getCouponModel",
"(",
")",
";",
"$",
"this... | Occurring when a Coupon condition is about to be updated
@param CouponCreateOrUpdateEvent $event Event creation or update Coupon condition
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Occurring",
"when",
"a",
"Coupon",
"condition",
"is",
"about",
"to",
"be",
"updated"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Coupon.php#L135-L140 | train |
thelia/core | lib/Thelia/Action/Coupon.php | Coupon.clearAllCoupons | public function clearAllCoupons(Event $event, $eventName, EventDispatcherInterface $dispatcher)
{
// Tell coupons to clear any data they may have stored
$this->couponManager->clear();
$this->getSession()->setConsumedCoupons(array());
$this->updateOrderDiscount($event, $eventName, $dispatcher);
} | php | public function clearAllCoupons(Event $event, $eventName, EventDispatcherInterface $dispatcher)
{
// Tell coupons to clear any data they may have stored
$this->couponManager->clear();
$this->getSession()->setConsumedCoupons(array());
$this->updateOrderDiscount($event, $eventName, $dispatcher);
} | [
"public",
"function",
"clearAllCoupons",
"(",
"Event",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"// Tell coupons to clear any data they may have stored",
"$",
"this",
"->",
"couponManager",
"->",
"clear",
"(",
... | Clear all coupons in session.
@param Event $event
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Clear",
"all",
"coupons",
"in",
"session",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Coupon.php#L149-L157 | train |
thelia/core | lib/Thelia/Action/Coupon.php | Coupon.consume | public function consume(CouponConsumeEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$totalDiscount = 0;
$isValid = false;
/** @var CouponInterface $coupon */
$coupon = $this->couponFactory->buildCouponFromCode($event->getCode());
if ($coupon) {
$isValid = $coupon->isMatching();
if ($isValid) {
$this->couponManager->pushCouponInSession($event->getCode());
$totalDiscount = $this->couponManager->getDiscount();
$this->getSession()
->getSessionCart($dispatcher)
->setDiscount($totalDiscount)
->save();
$this->getSession()
->getOrder()
->setDiscount($totalDiscount)
;
}
}
$event->setIsValid($isValid);
$event->setDiscount($totalDiscount);
} | php | public function consume(CouponConsumeEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$totalDiscount = 0;
$isValid = false;
/** @var CouponInterface $coupon */
$coupon = $this->couponFactory->buildCouponFromCode($event->getCode());
if ($coupon) {
$isValid = $coupon->isMatching();
if ($isValid) {
$this->couponManager->pushCouponInSession($event->getCode());
$totalDiscount = $this->couponManager->getDiscount();
$this->getSession()
->getSessionCart($dispatcher)
->setDiscount($totalDiscount)
->save();
$this->getSession()
->getOrder()
->setDiscount($totalDiscount)
;
}
}
$event->setIsValid($isValid);
$event->setDiscount($totalDiscount);
} | [
"public",
"function",
"consume",
"(",
"CouponConsumeEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"totalDiscount",
"=",
"0",
";",
"$",
"isValid",
"=",
"false",
";",
"/** @var CouponInterface $coupon... | Occurring when a Coupon condition is about to be consumed
@param CouponConsumeEvent $event Event consuming Coupon
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Occurring",
"when",
"a",
"Coupon",
"condition",
"is",
"about",
"to",
"be",
"consumed"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Coupon.php#L166-L195 | train |
thelia/core | lib/Thelia/Action/Coupon.php | Coupon.orderStatusChange | public function orderStatusChange(OrderEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
// The order has been canceled or refunded ?
if ($event->getOrder()->isCancelled() || $event->getOrder()->isRefunded()) {
// Cancel usage of all coupons for this order
$usedCoupons = OrderCouponQuery::create()
->filterByUsageCanceled(false)
->findByOrderId($event->getOrder()->getId());
$customerId = $event->getOrder()->getCustomerId();
/** @var OrderCoupon $usedCoupon */
foreach ($usedCoupons as $usedCoupon) {
if (null !== $couponModel = CouponQuery::create()->findOneByCode($usedCoupon->getCode())) {
// If the coupon still exists, restore one usage to the usage count.
$this->couponManager->incrementQuantity($couponModel, $customerId);
}
// Mark coupon usage as canceled in the OrderCoupon table
$usedCoupon->setUsageCanceled(true)->save();
}
} else {
// Mark canceled coupons for this order as used again
$usedCoupons = OrderCouponQuery::create()
->filterByUsageCanceled(true)
->findByOrderId($event->getOrder()->getId());
$customerId = $event->getOrder()->getCustomerId();
/** @var OrderCoupon $usedCoupon */
foreach ($usedCoupons as $usedCoupon) {
if (null !== $couponModel = CouponQuery::create()->findOneByCode($usedCoupon->getCode())) {
// If the coupon still exists, mark the coupon as used
$this->couponManager->decrementQuantity($couponModel, $customerId);
}
// The coupon is no longer canceled
$usedCoupon->setUsageCanceled(false)->save();
}
}
} | php | public function orderStatusChange(OrderEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
// The order has been canceled or refunded ?
if ($event->getOrder()->isCancelled() || $event->getOrder()->isRefunded()) {
// Cancel usage of all coupons for this order
$usedCoupons = OrderCouponQuery::create()
->filterByUsageCanceled(false)
->findByOrderId($event->getOrder()->getId());
$customerId = $event->getOrder()->getCustomerId();
/** @var OrderCoupon $usedCoupon */
foreach ($usedCoupons as $usedCoupon) {
if (null !== $couponModel = CouponQuery::create()->findOneByCode($usedCoupon->getCode())) {
// If the coupon still exists, restore one usage to the usage count.
$this->couponManager->incrementQuantity($couponModel, $customerId);
}
// Mark coupon usage as canceled in the OrderCoupon table
$usedCoupon->setUsageCanceled(true)->save();
}
} else {
// Mark canceled coupons for this order as used again
$usedCoupons = OrderCouponQuery::create()
->filterByUsageCanceled(true)
->findByOrderId($event->getOrder()->getId());
$customerId = $event->getOrder()->getCustomerId();
/** @var OrderCoupon $usedCoupon */
foreach ($usedCoupons as $usedCoupon) {
if (null !== $couponModel = CouponQuery::create()->findOneByCode($usedCoupon->getCode())) {
// If the coupon still exists, mark the coupon as used
$this->couponManager->decrementQuantity($couponModel, $customerId);
}
// The coupon is no longer canceled
$usedCoupon->setUsageCanceled(false)->save();
}
}
} | [
"public",
"function",
"orderStatusChange",
"(",
"OrderEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"// The order has been canceled or refunded ?",
"if",
"(",
"$",
"event",
"->",
"getOrder",
"(",
")",
"->"... | Cancels order coupons usage when order is canceled or refunded,
or use canceled coupons again if the order is no longer canceled or refunded
@param OrderEvent $event
@param string $eventName
@param EventDispatcherInterface $dispatcher
@throws \Exception
@throws \Propel\Runtime\Exception\PropelException | [
"Cancels",
"order",
"coupons",
"usage",
"when",
"order",
"is",
"canceled",
"or",
"refunded",
"or",
"use",
"canceled",
"coupons",
"again",
"if",
"the",
"order",
"is",
"no",
"longer",
"canceled",
"or",
"refunded"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Coupon.php#L393-L433 | train |
thelia/core | lib/Thelia/Action/Sale.php | Sale.updateProductSaleElementsPrices | protected function updateProductSaleElementsPrices($pseList, $promoStatus, $offsetType, Calculator $taxCalculator, $saleOffsetByCurrency, ConnectionInterface $con)
{
/** @var ProductSaleElements $pse */
foreach ($pseList as $pse) {
if ($pse->getPromo()!= $promoStatus) {
$pse
->setPromo($promoStatus)
->save($con)
;
}
/** @var SaleOffsetCurrency $offsetByCurrency */
foreach ($saleOffsetByCurrency as $currencyId => $offset) {
$productPrice = ProductPriceQuery::create()
->filterByProductSaleElementsId($pse->getId())
->filterByCurrencyId($currencyId)
->findOne($con);
if (null !== $productPrice) {
// Get the taxed price
$priceWithTax = $taxCalculator->getTaxedPrice($productPrice->getPrice());
// Remove the price offset to get the taxed promo price
switch ($offsetType) {
case SaleModel::OFFSET_TYPE_AMOUNT:
$promoPrice = max(0, $priceWithTax - $offset);
break;
case SaleModel::OFFSET_TYPE_PERCENTAGE:
$promoPrice = $priceWithTax * (1 - $offset / 100);
break;
default:
$promoPrice = $priceWithTax;
}
// and then get the untaxed promo price.
$promoPrice = $taxCalculator->getUntaxedPrice($promoPrice);
$productPrice
->setPromoPrice($promoPrice)
->save($con)
;
}
}
}
} | php | protected function updateProductSaleElementsPrices($pseList, $promoStatus, $offsetType, Calculator $taxCalculator, $saleOffsetByCurrency, ConnectionInterface $con)
{
/** @var ProductSaleElements $pse */
foreach ($pseList as $pse) {
if ($pse->getPromo()!= $promoStatus) {
$pse
->setPromo($promoStatus)
->save($con)
;
}
/** @var SaleOffsetCurrency $offsetByCurrency */
foreach ($saleOffsetByCurrency as $currencyId => $offset) {
$productPrice = ProductPriceQuery::create()
->filterByProductSaleElementsId($pse->getId())
->filterByCurrencyId($currencyId)
->findOne($con);
if (null !== $productPrice) {
// Get the taxed price
$priceWithTax = $taxCalculator->getTaxedPrice($productPrice->getPrice());
// Remove the price offset to get the taxed promo price
switch ($offsetType) {
case SaleModel::OFFSET_TYPE_AMOUNT:
$promoPrice = max(0, $priceWithTax - $offset);
break;
case SaleModel::OFFSET_TYPE_PERCENTAGE:
$promoPrice = $priceWithTax * (1 - $offset / 100);
break;
default:
$promoPrice = $priceWithTax;
}
// and then get the untaxed promo price.
$promoPrice = $taxCalculator->getUntaxedPrice($promoPrice);
$productPrice
->setPromoPrice($promoPrice)
->save($con)
;
}
}
}
} | [
"protected",
"function",
"updateProductSaleElementsPrices",
"(",
"$",
"pseList",
",",
"$",
"promoStatus",
",",
"$",
"offsetType",
",",
"Calculator",
"$",
"taxCalculator",
",",
"$",
"saleOffsetByCurrency",
",",
"ConnectionInterface",
"$",
"con",
")",
"{",
"/** @var P... | Update PSE for a given product
@param array $pseList an array of priduct sale elements
@param bool $promoStatus true if the PSEs are on sale, false otherwise
@param int $offsetType the offset type, see SaleModel::OFFSET_* constants
@param Calculator $taxCalculator the tax calculator
@param array $saleOffsetByCurrency an array of price offset for each currency (currency ID => offset_amount)
@param ConnectionInterface $con
@throws PropelException | [
"Update",
"PSE",
"for",
"a",
"given",
"product"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Sale.php#L61-L107 | train |
thelia/core | lib/Thelia/Action/Sale.php | Sale.updateProductsSaleStatus | public function updateProductsSaleStatus(ProductSaleStatusUpdateEvent $event)
{
$taxCalculator = new Calculator();
$sale = $event->getSale();
// Get all selected product sale elements for this sale
if (null !== $saleProducts = SaleProductQuery::create()->filterBySale($sale)->orderByProductId()) {
$saleOffsetByCurrency = $sale->getPriceOffsets();
$offsetType = $sale->getPriceOffsetType();
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
/** @var SaleProduct $saleProduct */
foreach ($saleProducts as $saleProduct) {
// Reset all sale status on product's PSE
ProductSaleElementsQuery::create()
->filterByProductId($saleProduct->getProductId())
->update([ 'Promo' => false], $con)
;
$taxCalculator->load(
$saleProduct->getProduct($con),
CountryModel::getShopLocation()
);
$attributeAvId = $saleProduct->getAttributeAvId();
$pseRequest = ProductSaleElementsQuery::create()
->filterByProductId($saleProduct->getProductId())
;
// If no attribute AV id is defined, consider ALL product combinations
if (! \is_null($attributeAvId)) {
// Find PSE attached to combination containing this attribute av :
// SELECT * from product_sale_elements pse
// left join attribute_combination ac on ac.product_sale_elements_id = pse.id
// where pse.product_id=363
// and ac.attribute_av_id = 7
// group by pse.id
$pseRequest
->useAttributeCombinationQuery(null, Criteria::LEFT_JOIN)
->filterByAttributeAvId($attributeAvId)
->endUse()
;
}
$pseList = $pseRequest->find();
if (null !== $pseList) {
$this->updateProductSaleElementsPrices(
$pseList,
$sale->getActive(),
$offsetType,
$taxCalculator,
$saleOffsetByCurrency,
$con
);
}
}
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
} | php | public function updateProductsSaleStatus(ProductSaleStatusUpdateEvent $event)
{
$taxCalculator = new Calculator();
$sale = $event->getSale();
// Get all selected product sale elements for this sale
if (null !== $saleProducts = SaleProductQuery::create()->filterBySale($sale)->orderByProductId()) {
$saleOffsetByCurrency = $sale->getPriceOffsets();
$offsetType = $sale->getPriceOffsetType();
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
/** @var SaleProduct $saleProduct */
foreach ($saleProducts as $saleProduct) {
// Reset all sale status on product's PSE
ProductSaleElementsQuery::create()
->filterByProductId($saleProduct->getProductId())
->update([ 'Promo' => false], $con)
;
$taxCalculator->load(
$saleProduct->getProduct($con),
CountryModel::getShopLocation()
);
$attributeAvId = $saleProduct->getAttributeAvId();
$pseRequest = ProductSaleElementsQuery::create()
->filterByProductId($saleProduct->getProductId())
;
// If no attribute AV id is defined, consider ALL product combinations
if (! \is_null($attributeAvId)) {
// Find PSE attached to combination containing this attribute av :
// SELECT * from product_sale_elements pse
// left join attribute_combination ac on ac.product_sale_elements_id = pse.id
// where pse.product_id=363
// and ac.attribute_av_id = 7
// group by pse.id
$pseRequest
->useAttributeCombinationQuery(null, Criteria::LEFT_JOIN)
->filterByAttributeAvId($attributeAvId)
->endUse()
;
}
$pseList = $pseRequest->find();
if (null !== $pseList) {
$this->updateProductSaleElementsPrices(
$pseList,
$sale->getActive(),
$offsetType,
$taxCalculator,
$saleOffsetByCurrency,
$con
);
}
}
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
} | [
"public",
"function",
"updateProductsSaleStatus",
"(",
"ProductSaleStatusUpdateEvent",
"$",
"event",
")",
"{",
"$",
"taxCalculator",
"=",
"new",
"Calculator",
"(",
")",
";",
"$",
"sale",
"=",
"$",
"event",
"->",
"getSale",
"(",
")",
";",
"// Get all selected pro... | Update the promo status of the sale's selected products and combinations
@param ProductSaleStatusUpdateEvent $event
@throws \RuntimeException
@throws \Exception
@throws \Propel\Runtime\Exception\PropelException | [
"Update",
"the",
"promo",
"status",
"of",
"the",
"sale",
"s",
"selected",
"products",
"and",
"combinations"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Sale.php#L116-L188 | train |
thelia/core | lib/Thelia/Action/Sale.php | Sale.create | public function create(SaleCreateEvent $event)
{
$sale = new SaleModel();
$sale
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setSaleLabel($event->getSaleLabel())
->save()
;
$event->setSale($sale);
} | php | public function create(SaleCreateEvent $event)
{
$sale = new SaleModel();
$sale
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setSaleLabel($event->getSaleLabel())
->save()
;
$event->setSale($sale);
} | [
"public",
"function",
"create",
"(",
"SaleCreateEvent",
"$",
"event",
")",
"{",
"$",
"sale",
"=",
"new",
"SaleModel",
"(",
")",
";",
"$",
"sale",
"->",
"setLocale",
"(",
"$",
"event",
"->",
"getLocale",
"(",
")",
")",
"->",
"setTitle",
"(",
"$",
"eve... | Create a new Sale
@param SaleCreateEvent $event | [
"Create",
"a",
"new",
"Sale"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Sale.php#L195-L207 | train |
thelia/core | lib/Thelia/Action/Sale.php | Sale.update | public function update(SaleUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $sale = SaleQuery::create()->findPk($event->getSaleId())) {
$sale->setDispatcher($dispatcher);
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
// Disable all promo flag on sale's currently selected products,
// to reset promo status of the products that may have been removed from the selection.
$sale->setActive(false);
$dispatcher->dispatch(
TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
new ProductSaleStatusUpdateEvent($sale)
);
$sale
->setActive($event->getActive())
->setStartDate($event->getStartDate())
->setEndDate($event->getEndDate())
->setPriceOffsetType($event->getPriceOffsetType())
->setDisplayInitialPrice($event->getDisplayInitialPrice())
->setLocale($event->getLocale())
->setSaleLabel($event->getSaleLabel())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
->setChapo($event->getChapo())
->setPostscriptum($event->getPostscriptum())
->save($con)
;
$event->setSale($sale);
// Update price offsets
SaleOffsetCurrencyQuery::create()->filterBySaleId($sale->getId())->delete($con);
foreach ($event->getPriceOffsets() as $currencyId => $priceOffset) {
$saleOffset = new SaleOffsetCurrency();
$saleOffset
->setCurrencyId($currencyId)
->setSaleId($sale->getId())
->setPriceOffsetValue($priceOffset)
->save($con)
;
}
// Update products
SaleProductQuery::create()->filterBySaleId($sale->getId())->delete($con);
$productAttributesArray = $event->getProductAttributes();
foreach ($event->getProducts() as $productId) {
if (isset($productAttributesArray[$productId])) {
foreach ($productAttributesArray[$productId] as $attributeId) {
$saleProduct = new SaleProduct();
$saleProduct
->setSaleId($sale->getId())
->setProductId($productId)
->setAttributeAvId($attributeId)
->save($con)
;
}
} else {
$saleProduct = new SaleProduct();
$saleProduct
->setSaleId($sale->getId())
->setProductId($productId)
->setAttributeAvId(null)
->save($con)
;
}
}
// Update related products sale status if the Sale is active. This is not required if the sale is
// not active, as we de-activated promotion for this sale at the beginning ofd this method
if ($sale->getActive()) {
$dispatcher->dispatch(
TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
new ProductSaleStatusUpdateEvent($sale)
);
}
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
} | php | public function update(SaleUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $sale = SaleQuery::create()->findPk($event->getSaleId())) {
$sale->setDispatcher($dispatcher);
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
// Disable all promo flag on sale's currently selected products,
// to reset promo status of the products that may have been removed from the selection.
$sale->setActive(false);
$dispatcher->dispatch(
TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
new ProductSaleStatusUpdateEvent($sale)
);
$sale
->setActive($event->getActive())
->setStartDate($event->getStartDate())
->setEndDate($event->getEndDate())
->setPriceOffsetType($event->getPriceOffsetType())
->setDisplayInitialPrice($event->getDisplayInitialPrice())
->setLocale($event->getLocale())
->setSaleLabel($event->getSaleLabel())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
->setChapo($event->getChapo())
->setPostscriptum($event->getPostscriptum())
->save($con)
;
$event->setSale($sale);
// Update price offsets
SaleOffsetCurrencyQuery::create()->filterBySaleId($sale->getId())->delete($con);
foreach ($event->getPriceOffsets() as $currencyId => $priceOffset) {
$saleOffset = new SaleOffsetCurrency();
$saleOffset
->setCurrencyId($currencyId)
->setSaleId($sale->getId())
->setPriceOffsetValue($priceOffset)
->save($con)
;
}
// Update products
SaleProductQuery::create()->filterBySaleId($sale->getId())->delete($con);
$productAttributesArray = $event->getProductAttributes();
foreach ($event->getProducts() as $productId) {
if (isset($productAttributesArray[$productId])) {
foreach ($productAttributesArray[$productId] as $attributeId) {
$saleProduct = new SaleProduct();
$saleProduct
->setSaleId($sale->getId())
->setProductId($productId)
->setAttributeAvId($attributeId)
->save($con)
;
}
} else {
$saleProduct = new SaleProduct();
$saleProduct
->setSaleId($sale->getId())
->setProductId($productId)
->setAttributeAvId(null)
->save($con)
;
}
}
// Update related products sale status if the Sale is active. This is not required if the sale is
// not active, as we de-activated promotion for this sale at the beginning ofd this method
if ($sale->getActive()) {
$dispatcher->dispatch(
TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
new ProductSaleStatusUpdateEvent($sale)
);
}
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
} | [
"public",
"function",
"update",
"(",
"SaleUpdateEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"sale",
"=",
"SaleQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(... | Process update sale
@param SaleUpdateEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher
@throws PropelException | [
"Process",
"update",
"sale"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Sale.php#L217-L311 | train |
thelia/core | lib/Thelia/Action/Sale.php | Sale.toggleActivity | public function toggleActivity(SaleToggleActivityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$sale = $event->getSale();
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$sale
->setDispatcher($dispatcher)
->setActive(!$sale->getActive())
->save($con);
// Update related products sale status
$dispatcher->dispatch(
TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
new ProductSaleStatusUpdateEvent($sale)
);
$event->setSale($sale);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
} | php | public function toggleActivity(SaleToggleActivityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$sale = $event->getSale();
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$sale
->setDispatcher($dispatcher)
->setActive(!$sale->getActive())
->save($con);
// Update related products sale status
$dispatcher->dispatch(
TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
new ProductSaleStatusUpdateEvent($sale)
);
$event->setSale($sale);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
} | [
"public",
"function",
"toggleActivity",
"(",
"SaleToggleActivityEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"sale",
"=",
"$",
"event",
"->",
"getSale",
"(",
")",
";",
"$",
"con",
"=",
"Prope... | Toggle Sale activity
@param SaleToggleActivityEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher
@throws \Propel\Runtime\Exception\PropelException | [
"Toggle",
"Sale",
"activity"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Sale.php#L321-L348 | train |
thelia/core | lib/Thelia/Action/Sale.php | Sale.delete | public function delete(SaleDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $sale = SaleQuery::create()->findPk($event->getSaleId())) {
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
// Update related products sale status, if required
if ($sale->getActive()) {
$sale->setActive(false);
// Update related products sale status
$dispatcher->dispatch(
TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
new ProductSaleStatusUpdateEvent($sale)
);
}
$sale->setDispatcher($dispatcher)->delete($con);
$event->setSale($sale);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
} | php | public function delete(SaleDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $sale = SaleQuery::create()->findPk($event->getSaleId())) {
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
// Update related products sale status, if required
if ($sale->getActive()) {
$sale->setActive(false);
// Update related products sale status
$dispatcher->dispatch(
TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
new ProductSaleStatusUpdateEvent($sale)
);
}
$sale->setDispatcher($dispatcher)->delete($con);
$event->setSale($sale);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
} | [
"public",
"function",
"delete",
"(",
"SaleDeleteEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"sale",
"=",
"SaleQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(... | Delete a sale
@param SaleDeleteEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher
@throws \Propel\Runtime\Exception\PropelException | [
"Delete",
"a",
"sale"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Sale.php#L358-L387 | train |
thelia/core | lib/Thelia/Action/Sale.php | Sale.clearStatus | public function clearStatus(/** @noinspection PhpUnusedParameterInspection */ SaleClearStatusEvent $event)
{
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
// Set the active status of all Sales to false
SaleQuery::create()
->filterByActive(true)
->update([ 'Active' => false ], $con)
;
// Reset all sale status on PSE
ProductSaleElementsQuery::create()
->filterByPromo(true)
->update([ 'Promo' => false], $con)
;
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
} | php | public function clearStatus(/** @noinspection PhpUnusedParameterInspection */ SaleClearStatusEvent $event)
{
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
// Set the active status of all Sales to false
SaleQuery::create()
->filterByActive(true)
->update([ 'Active' => false ], $con)
;
// Reset all sale status on PSE
ProductSaleElementsQuery::create()
->filterByPromo(true)
->update([ 'Promo' => false], $con)
;
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
} | [
"public",
"function",
"clearStatus",
"(",
"/** @noinspection PhpUnusedParameterInspection */",
"SaleClearStatusEvent",
"$",
"event",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getWriteConnection",
"(",
"SaleTableMap",
"::",
"DATABASE_NAME",
")",
";",
"$",
"con",
"->"... | Clear all sales
@param SaleClearStatusEvent $event
@throws \Exception | [
"Clear",
"all",
"sales"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Sale.php#L395-L418 | train |
thelia/core | lib/Thelia/Action/Sale.php | Sale.checkSaleActivation | public function checkSaleActivation(SaleActiveStatusCheckEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$now = time();
// Disable expired sales
if (null !== $salesToDisable = SaleQuery::create()
->filterByActive(true)
->filterByEndDate($now, Criteria::LESS_THAN)
->find()) {
/** @var SaleModel $sale */
foreach ($salesToDisable as $sale) {
$sale->setActive(false)->save();
// Update related products sale status
$dispatcher->dispatch(
TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
new ProductSaleStatusUpdateEvent($sale)
);
}
}
// Enable sales that should be enabled.
if (null !== $salesToEnable = SaleQuery::create()
->filterByActive(false)
->filterByStartDate($now, Criteria::LESS_EQUAL)
->filterByEndDate($now, Criteria::GREATER_EQUAL)
->find()) {
/** @var SaleModel $sale */
foreach ($salesToEnable as $sale) {
$sale->setActive(true)->save();
// Update related products sale status
$dispatcher->dispatch(
TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
new ProductSaleStatusUpdateEvent($sale)
);
}
}
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
} | php | public function checkSaleActivation(SaleActiveStatusCheckEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$now = time();
// Disable expired sales
if (null !== $salesToDisable = SaleQuery::create()
->filterByActive(true)
->filterByEndDate($now, Criteria::LESS_THAN)
->find()) {
/** @var SaleModel $sale */
foreach ($salesToDisable as $sale) {
$sale->setActive(false)->save();
// Update related products sale status
$dispatcher->dispatch(
TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
new ProductSaleStatusUpdateEvent($sale)
);
}
}
// Enable sales that should be enabled.
if (null !== $salesToEnable = SaleQuery::create()
->filterByActive(false)
->filterByStartDate($now, Criteria::LESS_EQUAL)
->filterByEndDate($now, Criteria::GREATER_EQUAL)
->find()) {
/** @var SaleModel $sale */
foreach ($salesToEnable as $sale) {
$sale->setActive(true)->save();
// Update related products sale status
$dispatcher->dispatch(
TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
new ProductSaleStatusUpdateEvent($sale)
);
}
}
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
} | [
"public",
"function",
"checkSaleActivation",
"(",
"SaleActiveStatusCheckEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getWriteConnection",
"(",
"SaleTableMap",
"::",
"DATA... | This method check the activation and deactivation dates of sales, and perform
the required action depending on the current date.
@param SaleActiveStatusCheckEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher
@throws \Propel\Runtime\Exception\PropelException | [
"This",
"method",
"check",
"the",
"activation",
"and",
"deactivation",
"dates",
"of",
"sales",
"and",
"perform",
"the",
"required",
"action",
"depending",
"on",
"the",
"current",
"date",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Sale.php#L429-L477 | train |
thelia/core | lib/Thelia/Core/Propel/Schema/SchemaCombiner.php | SchemaCombiner.combine | public function combine(array $schemaDocuments = [], array $externalSchemaDocuments = [])
{
$globalDatabaseElements = [];
// merge schema documents, per database
foreach ($schemaDocuments as $sourceSchemaDocument) {
if (!$sourceSchemaDocument instanceof \DOMDocument) {
throw new \InvalidArgumentException('Schema file is not a \DOMDocument');
}
// work on document clones since we are going to edit them
$sourceSchemaDocument = clone $sourceSchemaDocument;
// process all <database> elements in the document
/** @var \DOMElement $sourceDatabaseElement */
foreach ($sourceSchemaDocument->getElementsByTagName('database') as $sourceDatabaseElement) {
// pre-process the element
$this->filterExternalSchemaElements($sourceDatabaseElement);
$this->inheritDatabaseAttributes($sourceDatabaseElement);
$this->applyDatabaseTablePrefix($sourceDatabaseElement);
// append the element
$this->mergeDatabaseElement($sourceDatabaseElement);
}
}
// include external schema documents, per database
foreach ($externalSchemaDocuments as $externalSchemaDocument) {
if (!$externalSchemaDocument instanceof \DOMDocument) {
throw new \InvalidArgumentException('Schema file is not a \DOMDocument');
}
// process all <database> elements in the document
/** @var \DOMElement $externalSchemaDatabaseElement */
foreach ($externalSchemaDocument->getElementsByTagName('database') as $externalSchemaDatabaseElement) {
// include the document
$this->includeExternalSchema($externalSchemaDatabaseElement);
}
}
// return the documents, not the database elements
$globalSchemaDocuments = [];
/**
* @var string $database
* @var \DOMElement $globalDatabaseElement
*/
foreach ($globalDatabaseElements as $database => $globalDatabaseElement) {
$globalSchemaDocuments[$database] = $globalDatabaseElement->ownerDocument;
}
return $globalSchemaDocuments;
} | php | public function combine(array $schemaDocuments = [], array $externalSchemaDocuments = [])
{
$globalDatabaseElements = [];
// merge schema documents, per database
foreach ($schemaDocuments as $sourceSchemaDocument) {
if (!$sourceSchemaDocument instanceof \DOMDocument) {
throw new \InvalidArgumentException('Schema file is not a \DOMDocument');
}
// work on document clones since we are going to edit them
$sourceSchemaDocument = clone $sourceSchemaDocument;
// process all <database> elements in the document
/** @var \DOMElement $sourceDatabaseElement */
foreach ($sourceSchemaDocument->getElementsByTagName('database') as $sourceDatabaseElement) {
// pre-process the element
$this->filterExternalSchemaElements($sourceDatabaseElement);
$this->inheritDatabaseAttributes($sourceDatabaseElement);
$this->applyDatabaseTablePrefix($sourceDatabaseElement);
// append the element
$this->mergeDatabaseElement($sourceDatabaseElement);
}
}
// include external schema documents, per database
foreach ($externalSchemaDocuments as $externalSchemaDocument) {
if (!$externalSchemaDocument instanceof \DOMDocument) {
throw new \InvalidArgumentException('Schema file is not a \DOMDocument');
}
// process all <database> elements in the document
/** @var \DOMElement $externalSchemaDatabaseElement */
foreach ($externalSchemaDocument->getElementsByTagName('database') as $externalSchemaDatabaseElement) {
// include the document
$this->includeExternalSchema($externalSchemaDatabaseElement);
}
}
// return the documents, not the database elements
$globalSchemaDocuments = [];
/**
* @var string $database
* @var \DOMElement $globalDatabaseElement
*/
foreach ($globalDatabaseElements as $database => $globalDatabaseElement) {
$globalSchemaDocuments[$database] = $globalDatabaseElement->ownerDocument;
}
return $globalSchemaDocuments;
} | [
"public",
"function",
"combine",
"(",
"array",
"$",
"schemaDocuments",
"=",
"[",
"]",
",",
"array",
"$",
"externalSchemaDocuments",
"=",
"[",
"]",
")",
"{",
"$",
"globalDatabaseElements",
"=",
"[",
"]",
";",
"// merge schema documents, per database",
"foreach",
... | Combine multiple schemas into one schema per database.
@param \DOMDocument[] $schemaDocuments Schema documents to combine.
@param \DOMDocument[] $externalSchemaDocuments Schemas documents to include as external schemas in the combined
documents.
@return array A map of [database name => \DOMDocument schema for that database]. | [
"Combine",
"multiple",
"schemas",
"into",
"one",
"schema",
"per",
"database",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Propel/Schema/SchemaCombiner.php#L157-L208 | train |
thelia/core | lib/Thelia/Core/Propel/Schema/SchemaCombiner.php | SchemaCombiner.inheritDatabaseAttributes | protected function inheritDatabaseAttributes(\DOMElement $databaseElement)
{
$attributesToInherit = [];
foreach (static::$DATABASE_INHERITABLE_ATTRIBUTES as $databaseAttribute => $tableAttribute) {
if (!$databaseElement->hasAttribute($databaseAttribute)) {
continue;
}
$attributesToInherit[$tableAttribute] = $databaseElement->getAttribute($databaseAttribute);
}
/** @var \DOMElement $tableElement */
foreach ($databaseElement->getElementsByTagName('table') as $tableElement) {
foreach (static::$DATABASE_INHERITABLE_ATTRIBUTES as $databaseAttribute => $tableAttribute) {
if (!isset($attributesToInherit[$tableAttribute])) {
continue;
}
if ($tableElement->hasAttribute($tableAttribute)) {
// do not inherit the attribute if the table defines its own
continue;
}
// add an inheritance notice
$databaseAttributeInheritanceNoticeComment = $tableElement->ownerDocument->createComment(
"Attribute '{$tableAttribute}'"
. " inherited from parent database attribute '{$databaseAttribute}'"
);
$tableElement->insertBefore(
$databaseAttributeInheritanceNoticeComment,
$tableElement->firstChild
);
$tableElement->setAttribute($tableAttribute, $attributesToInherit[$tableAttribute]);
}
}
} | php | protected function inheritDatabaseAttributes(\DOMElement $databaseElement)
{
$attributesToInherit = [];
foreach (static::$DATABASE_INHERITABLE_ATTRIBUTES as $databaseAttribute => $tableAttribute) {
if (!$databaseElement->hasAttribute($databaseAttribute)) {
continue;
}
$attributesToInherit[$tableAttribute] = $databaseElement->getAttribute($databaseAttribute);
}
/** @var \DOMElement $tableElement */
foreach ($databaseElement->getElementsByTagName('table') as $tableElement) {
foreach (static::$DATABASE_INHERITABLE_ATTRIBUTES as $databaseAttribute => $tableAttribute) {
if (!isset($attributesToInherit[$tableAttribute])) {
continue;
}
if ($tableElement->hasAttribute($tableAttribute)) {
// do not inherit the attribute if the table defines its own
continue;
}
// add an inheritance notice
$databaseAttributeInheritanceNoticeComment = $tableElement->ownerDocument->createComment(
"Attribute '{$tableAttribute}'"
. " inherited from parent database attribute '{$databaseAttribute}'"
);
$tableElement->insertBefore(
$databaseAttributeInheritanceNoticeComment,
$tableElement->firstChild
);
$tableElement->setAttribute($tableAttribute, $attributesToInherit[$tableAttribute]);
}
}
} | [
"protected",
"function",
"inheritDatabaseAttributes",
"(",
"\\",
"DOMElement",
"$",
"databaseElement",
")",
"{",
"$",
"attributesToInherit",
"=",
"[",
"]",
";",
"foreach",
"(",
"static",
"::",
"$",
"DATABASE_INHERITABLE_ATTRIBUTES",
"as",
"$",
"databaseAttribute",
"... | Copy inheritable database attribute to the tables in the database.
@param \DOMElement $databaseElement Database element to process. | [
"Copy",
"inheritable",
"database",
"attribute",
"to",
"the",
"tables",
"in",
"the",
"database",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Propel/Schema/SchemaCombiner.php#L238-L274 | train |
thelia/core | lib/Thelia/Core/Propel/Schema/SchemaCombiner.php | SchemaCombiner.applyDatabaseTablePrefix | protected function applyDatabaseTablePrefix(\DOMElement $databaseElement)
{
if (!$databaseElement->hasAttribute('tablePrefix')) {
return;
}
$tablePrefix = $databaseElement->getAttribute('tablePrefix');
/** @var \DOMElement $tableElement */
foreach ($databaseElement->getElementsByTagName('table') as $tableElement) {
if (!$tableElement->hasAttribute('name')) {
// this is probably wrong, but not our problem here - we do not validate the schema
continue;
}
// add a prefixing notice
$tablePrefixingNoticeComment = $tableElement->ownerDocument->createComment(
"Table name prefixed with parent database 'tablePrefix'"
);
$tableElement->appendChild($tablePrefixingNoticeComment);
$table = $tableElement->getAttribute('name');
$tableElement->setAttribute('name', $tablePrefix . $table);
}
} | php | protected function applyDatabaseTablePrefix(\DOMElement $databaseElement)
{
if (!$databaseElement->hasAttribute('tablePrefix')) {
return;
}
$tablePrefix = $databaseElement->getAttribute('tablePrefix');
/** @var \DOMElement $tableElement */
foreach ($databaseElement->getElementsByTagName('table') as $tableElement) {
if (!$tableElement->hasAttribute('name')) {
// this is probably wrong, but not our problem here - we do not validate the schema
continue;
}
// add a prefixing notice
$tablePrefixingNoticeComment = $tableElement->ownerDocument->createComment(
"Table name prefixed with parent database 'tablePrefix'"
);
$tableElement->appendChild($tablePrefixingNoticeComment);
$table = $tableElement->getAttribute('name');
$tableElement->setAttribute('name', $tablePrefix . $table);
}
} | [
"protected",
"function",
"applyDatabaseTablePrefix",
"(",
"\\",
"DOMElement",
"$",
"databaseElement",
")",
"{",
"if",
"(",
"!",
"$",
"databaseElement",
"->",
"hasAttribute",
"(",
"'tablePrefix'",
")",
")",
"{",
"return",
";",
"}",
"$",
"tablePrefix",
"=",
"$",... | Prefix table names with the prefix defined on the database.
@param \DOMElement $databaseElement Database element to process. | [
"Prefix",
"table",
"names",
"with",
"the",
"prefix",
"defined",
"on",
"the",
"database",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Propel/Schema/SchemaCombiner.php#L280-L304 | train |
thelia/core | lib/Thelia/Core/Propel/Schema/SchemaCombiner.php | SchemaCombiner.getDatabaseFromDatabaseElement | protected function getDatabaseFromDatabaseElement(\DOMElement $databaseElement)
{
$database = $databaseElement->getAttribute('name');
if (empty($database)) {
throw new \LogicException('Unnamed database node.');
}
return $database;
} | php | protected function getDatabaseFromDatabaseElement(\DOMElement $databaseElement)
{
$database = $databaseElement->getAttribute('name');
if (empty($database)) {
throw new \LogicException('Unnamed database node.');
}
return $database;
} | [
"protected",
"function",
"getDatabaseFromDatabaseElement",
"(",
"\\",
"DOMElement",
"$",
"databaseElement",
")",
"{",
"$",
"database",
"=",
"$",
"databaseElement",
"->",
"getAttribute",
"(",
"'name'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"database",
")",
")... | Get the database name from a database element.
@param \DOMElement $databaseElement Database element.
@return string Database name.
@throws \LogicException If the database element is unnamed. | [
"Get",
"the",
"database",
"name",
"from",
"a",
"database",
"element",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Propel/Schema/SchemaCombiner.php#L312-L320 | train |
thelia/core | lib/Thelia/Core/Propel/Schema/SchemaCombiner.php | SchemaCombiner.initGlobalDatabaseElement | protected function initGlobalDatabaseElement($database)
{
if (\in_array($database, $this->databases)) {
return;
}
$databaseDocument = new \DOMDocument(static::$GLOBAL_SCHEMA_XML_VERSION, static::$GLOBAL_SCHEMA_XML_ENCODING);
$databaseElement = $databaseDocument->createElement('database');
$databaseElement->setAttribute('name', $database);
$identifierQuotingNoticeComment = $databaseElement->ownerDocument->createComment(
"Attribute 'identifierQuoting' generated"
);
$databaseElement->appendChild($identifierQuotingNoticeComment);
$databaseElement->setAttribute('identifierQuoting', 'true');
$databaseDocument->appendChild($databaseElement);
$this->databases[] = $database;
$this->globalDatabaseElements[$database] = $databaseElement;
$this->sourceDatabaseElements[$database] = [];
$this->externalSchemaDatabaseElements[$database] = [];
} | php | protected function initGlobalDatabaseElement($database)
{
if (\in_array($database, $this->databases)) {
return;
}
$databaseDocument = new \DOMDocument(static::$GLOBAL_SCHEMA_XML_VERSION, static::$GLOBAL_SCHEMA_XML_ENCODING);
$databaseElement = $databaseDocument->createElement('database');
$databaseElement->setAttribute('name', $database);
$identifierQuotingNoticeComment = $databaseElement->ownerDocument->createComment(
"Attribute 'identifierQuoting' generated"
);
$databaseElement->appendChild($identifierQuotingNoticeComment);
$databaseElement->setAttribute('identifierQuoting', 'true');
$databaseDocument->appendChild($databaseElement);
$this->databases[] = $database;
$this->globalDatabaseElements[$database] = $databaseElement;
$this->sourceDatabaseElements[$database] = [];
$this->externalSchemaDatabaseElements[$database] = [];
} | [
"protected",
"function",
"initGlobalDatabaseElement",
"(",
"$",
"database",
")",
"{",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"database",
",",
"$",
"this",
"->",
"databases",
")",
")",
"{",
"return",
";",
"}",
"$",
"databaseDocument",
"=",
"new",
"\\",
"D... | Create a global database element in a new document.
@param string $database Database. | [
"Create",
"a",
"global",
"database",
"element",
"in",
"a",
"new",
"document",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Propel/Schema/SchemaCombiner.php#L326-L350 | train |
thelia/core | lib/Thelia/Core/Propel/Schema/SchemaCombiner.php | SchemaCombiner.mergeDatabaseElement | protected function mergeDatabaseElement(\DOMElement $sourceDatabaseElement)
{
$database = $this->getDatabaseFromDatabaseElement($sourceDatabaseElement);
$this->initGlobalDatabaseElement($database);
$globalDatabaseElement = $this->globalDatabaseElements[$database];
// add a source schema start marker
$fileStartMarkerComment = $globalDatabaseElement->ownerDocument->createComment(
"Start of schema from '{$sourceDatabaseElement->ownerDocument->baseURI}'"
);
$globalDatabaseElement->appendChild($fileStartMarkerComment);
// merge the element
foreach ($sourceDatabaseElement->childNodes as $childNode) {
$importedNode = $globalDatabaseElement->ownerDocument->importNode($childNode, true);
$globalDatabaseElement->appendChild($importedNode);
}
// and a source schema end marker
$fileEndMarkerComment = $globalDatabaseElement->ownerDocument->createComment(
"End of schema from '{$sourceDatabaseElement->ownerDocument->baseURI}'"
);
$globalDatabaseElement->appendChild($fileEndMarkerComment);
$this->sourceDatabaseElements[$database][] = $sourceDatabaseElement;
} | php | protected function mergeDatabaseElement(\DOMElement $sourceDatabaseElement)
{
$database = $this->getDatabaseFromDatabaseElement($sourceDatabaseElement);
$this->initGlobalDatabaseElement($database);
$globalDatabaseElement = $this->globalDatabaseElements[$database];
// add a source schema start marker
$fileStartMarkerComment = $globalDatabaseElement->ownerDocument->createComment(
"Start of schema from '{$sourceDatabaseElement->ownerDocument->baseURI}'"
);
$globalDatabaseElement->appendChild($fileStartMarkerComment);
// merge the element
foreach ($sourceDatabaseElement->childNodes as $childNode) {
$importedNode = $globalDatabaseElement->ownerDocument->importNode($childNode, true);
$globalDatabaseElement->appendChild($importedNode);
}
// and a source schema end marker
$fileEndMarkerComment = $globalDatabaseElement->ownerDocument->createComment(
"End of schema from '{$sourceDatabaseElement->ownerDocument->baseURI}'"
);
$globalDatabaseElement->appendChild($fileEndMarkerComment);
$this->sourceDatabaseElements[$database][] = $sourceDatabaseElement;
} | [
"protected",
"function",
"mergeDatabaseElement",
"(",
"\\",
"DOMElement",
"$",
"sourceDatabaseElement",
")",
"{",
"$",
"database",
"=",
"$",
"this",
"->",
"getDatabaseFromDatabaseElement",
"(",
"$",
"sourceDatabaseElement",
")",
";",
"$",
"this",
"->",
"initGlobalDa... | Merge a source database element into the corresponding global database element for this database.
@param \DOMElement $sourceDatabaseElement Source database element to merge. | [
"Merge",
"a",
"source",
"database",
"element",
"into",
"the",
"corresponding",
"global",
"database",
"element",
"for",
"this",
"database",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Propel/Schema/SchemaCombiner.php#L356-L383 | train |
thelia/core | lib/Thelia/Core/Propel/Schema/SchemaCombiner.php | SchemaCombiner.includeExternalSchema | protected function includeExternalSchema(\DOMElement $externalDatabaseElement)
{
$database = $this->getDatabaseFromDatabaseElement($externalDatabaseElement);
$this->initGlobalDatabaseElement($database);
$globalDatabaseElement = $this->globalDatabaseElements[$database];
// add an inclusion notice
$externalSchemaIncludeComment = $globalDatabaseElement->ownerDocument->createComment(
"External schema included in the combining process"
);
$globalDatabaseElement->appendChild($externalSchemaIncludeComment);
// include the external schema
$externalSchemaInclude = $globalDatabaseElement->ownerDocument->createElement(
'external-schema',
$externalDatabaseElement->ownerDocument->baseURI
);
$globalDatabaseElement->appendChild($externalSchemaInclude);
$this->externalSchemaDatabaseElements[$database][] = $externalDatabaseElement;
} | php | protected function includeExternalSchema(\DOMElement $externalDatabaseElement)
{
$database = $this->getDatabaseFromDatabaseElement($externalDatabaseElement);
$this->initGlobalDatabaseElement($database);
$globalDatabaseElement = $this->globalDatabaseElements[$database];
// add an inclusion notice
$externalSchemaIncludeComment = $globalDatabaseElement->ownerDocument->createComment(
"External schema included in the combining process"
);
$globalDatabaseElement->appendChild($externalSchemaIncludeComment);
// include the external schema
$externalSchemaInclude = $globalDatabaseElement->ownerDocument->createElement(
'external-schema',
$externalDatabaseElement->ownerDocument->baseURI
);
$globalDatabaseElement->appendChild($externalSchemaInclude);
$this->externalSchemaDatabaseElements[$database][] = $externalDatabaseElement;
} | [
"protected",
"function",
"includeExternalSchema",
"(",
"\\",
"DOMElement",
"$",
"externalDatabaseElement",
")",
"{",
"$",
"database",
"=",
"$",
"this",
"->",
"getDatabaseFromDatabaseElement",
"(",
"$",
"externalDatabaseElement",
")",
";",
"$",
"this",
"->",
"initGlo... | Include an external schema into a database element.
@param \DOMElement $externalDatabaseElement External schema database element to include. | [
"Include",
"an",
"external",
"schema",
"into",
"a",
"database",
"element",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Propel/Schema/SchemaCombiner.php#L389-L411 | train |
thelia/core | lib/Thelia/Handler/ImportHandler.php | ImportHandler.getImport | public function getImport($importId, $dispatchException = false)
{
$import = (new ImportQuery)->findPk($importId);
if ($import === null && $dispatchException) {
throw new \ErrorException(
Translator::getInstance()->trans(
'There is no id "%id" in the imports',
[
'%id' => $importId
]
)
);
}
return $import;
} | php | public function getImport($importId, $dispatchException = false)
{
$import = (new ImportQuery)->findPk($importId);
if ($import === null && $dispatchException) {
throw new \ErrorException(
Translator::getInstance()->trans(
'There is no id "%id" in the imports',
[
'%id' => $importId
]
)
);
}
return $import;
} | [
"public",
"function",
"getImport",
"(",
"$",
"importId",
",",
"$",
"dispatchException",
"=",
"false",
")",
"{",
"$",
"import",
"=",
"(",
"new",
"ImportQuery",
")",
"->",
"findPk",
"(",
"$",
"importId",
")",
";",
"if",
"(",
"$",
"import",
"===",
"null",... | Get import model based on given identifier
@param integer $importId An import identifier
@param boolean $dispatchException Dispatch exception if model doesn't exist
@throws \ErrorException
@return null|\Thelia\Model\Import | [
"Get",
"import",
"model",
"based",
"on",
"given",
"identifier"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Handler/ImportHandler.php#L89-L105 | train |
thelia/core | lib/Thelia/Handler/ImportHandler.php | ImportHandler.getImportByRef | public function getImportByRef($importRef, $dispatchException = false)
{
$import = (new ImportQuery)->findOneByRef($importRef);
if ($import === null && $dispatchException) {
throw new \ErrorException(
Translator::getInstance()->trans(
'There is no id "%ref" in the imports',
[
'%ref' => $importRef
]
)
);
}
return $import;
} | php | public function getImportByRef($importRef, $dispatchException = false)
{
$import = (new ImportQuery)->findOneByRef($importRef);
if ($import === null && $dispatchException) {
throw new \ErrorException(
Translator::getInstance()->trans(
'There is no id "%ref" in the imports',
[
'%ref' => $importRef
]
)
);
}
return $import;
} | [
"public",
"function",
"getImportByRef",
"(",
"$",
"importRef",
",",
"$",
"dispatchException",
"=",
"false",
")",
"{",
"$",
"import",
"=",
"(",
"new",
"ImportQuery",
")",
"->",
"findOneByRef",
"(",
"$",
"importRef",
")",
";",
"if",
"(",
"$",
"import",
"==... | Get import model based on given reference
@param string $importRef An import reference
@param boolean $dispatchException Dispatch exception if model doesn't exist
@throws \ErrorException
@return null|\Thelia\Model\Import | [
"Get",
"import",
"model",
"based",
"on",
"given",
"reference"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Handler/ImportHandler.php#L117-L133 | train |
thelia/core | lib/Thelia/Handler/ImportHandler.php | ImportHandler.getCategory | public function getCategory($importCategoryId, $dispatchException = false)
{
$category = (new ImportCategoryQuery)->findPk($importCategoryId);
if ($category === null && $dispatchException) {
throw new \ErrorException(
Translator::getInstance()->trans(
'There is no id "%id" in the import categories',
[
'%id' => $importCategoryId
]
)
);
}
return $category;
} | php | public function getCategory($importCategoryId, $dispatchException = false)
{
$category = (new ImportCategoryQuery)->findPk($importCategoryId);
if ($category === null && $dispatchException) {
throw new \ErrorException(
Translator::getInstance()->trans(
'There is no id "%id" in the import categories',
[
'%id' => $importCategoryId
]
)
);
}
return $category;
} | [
"public",
"function",
"getCategory",
"(",
"$",
"importCategoryId",
",",
"$",
"dispatchException",
"=",
"false",
")",
"{",
"$",
"category",
"=",
"(",
"new",
"ImportCategoryQuery",
")",
"->",
"findPk",
"(",
"$",
"importCategoryId",
")",
";",
"if",
"(",
"$",
... | Get import category model based on given identifier
@param integer $importCategoryId An import category identifier
@param boolean $dispatchException Dispatch exception if model doesn't exist
@throws \ErrorException
@return null|\Thelia\Model\ImportCategory | [
"Get",
"import",
"category",
"model",
"based",
"on",
"given",
"identifier"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Handler/ImportHandler.php#L145-L161 | train |
thelia/core | lib/Thelia/Handler/ImportHandler.php | ImportHandler.matchArchiverByExtension | public function matchArchiverByExtension($fileName)
{
/** @var \Thelia\Core\Archiver\AbstractArchiver $archiver */
foreach ($this->archiverManager->getArchivers(true) as $archiver) {
if (stripos($fileName, '.' . $archiver->getExtension()) !== false) {
return $archiver;
}
}
return null;
} | php | public function matchArchiverByExtension($fileName)
{
/** @var \Thelia\Core\Archiver\AbstractArchiver $archiver */
foreach ($this->archiverManager->getArchivers(true) as $archiver) {
if (stripos($fileName, '.' . $archiver->getExtension()) !== false) {
return $archiver;
}
}
return null;
} | [
"public",
"function",
"matchArchiverByExtension",
"(",
"$",
"fileName",
")",
"{",
"/** @var \\Thelia\\Core\\Archiver\\AbstractArchiver $archiver */",
"foreach",
"(",
"$",
"this",
"->",
"archiverManager",
"->",
"getArchivers",
"(",
"true",
")",
"as",
"$",
"archiver",
")"... | Match archiver relative to file name
@param string $fileName File name
@return null|\Thelia\Core\Archiver\AbstractArchiver | [
"Match",
"archiver",
"relative",
"to",
"file",
"name"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Handler/ImportHandler.php#L226-L236 | train |
thelia/core | lib/Thelia/Handler/ImportHandler.php | ImportHandler.matchSerializerByExtension | public function matchSerializerByExtension($fileName)
{
/** @var \Thelia\Core\Serializer\AbstractSerializer $serializer */
foreach ($this->serializerManager->getSerializers() as $serializer) {
if (stripos($fileName, '.' . $serializer->getExtension()) !== false) {
return $serializer;
}
}
return null;
} | php | public function matchSerializerByExtension($fileName)
{
/** @var \Thelia\Core\Serializer\AbstractSerializer $serializer */
foreach ($this->serializerManager->getSerializers() as $serializer) {
if (stripos($fileName, '.' . $serializer->getExtension()) !== false) {
return $serializer;
}
}
return null;
} | [
"public",
"function",
"matchSerializerByExtension",
"(",
"$",
"fileName",
")",
"{",
"/** @var \\Thelia\\Core\\Serializer\\AbstractSerializer $serializer */",
"foreach",
"(",
"$",
"this",
"->",
"serializerManager",
"->",
"getSerializers",
"(",
")",
"as",
"$",
"serializer",
... | Match serializer relative to file name
@param string $fileName File name
@return null|\Thelia\Core\Serializer\AbstractSerializer | [
"Match",
"serializer",
"relative",
"to",
"file",
"name"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Handler/ImportHandler.php#L245-L255 | train |
thelia/core | lib/Thelia/Core/Event/Hook/HookRenderEvent.php | HookRenderEvent.dump | public function dump($glue = '', $before = '', $after = '')
{
$ret = '';
if (0 !== \count($this->fragments)) {
$ret = $before . implode($glue, $this->fragments) . $after;
}
return $ret;
} | php | public function dump($glue = '', $before = '', $after = '')
{
$ret = '';
if (0 !== \count($this->fragments)) {
$ret = $before . implode($glue, $this->fragments) . $after;
}
return $ret;
} | [
"public",
"function",
"dump",
"(",
"$",
"glue",
"=",
"''",
",",
"$",
"before",
"=",
"''",
",",
"$",
"after",
"=",
"''",
")",
"{",
"$",
"ret",
"=",
"''",
";",
"if",
"(",
"0",
"!==",
"\\",
"count",
"(",
"$",
"this",
"->",
"fragments",
")",
")",... | Concatenates all fragments in a string.
@param string $glue the glue between fragments
@param string $before the text before the concatenated string
@param string $after the text after the concatenated string
@return string the concatenate string | [
"Concatenates",
"all",
"fragments",
"in",
"a",
"string",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Event/Hook/HookRenderEvent.php#L64-L72 | train |
thelia/core | lib/Thelia/Config/DatabaseConfiguration.php | DatabaseConfiguration.buildConnectionNode | public function buildConnectionNode($rootName, $isArray)
{
$treeBuilder = new TreeBuilder();
$connectionNode = $treeBuilder->root($rootName);
if ($isArray) {
/** @var ArrayNodeDefinition $connectionNodePrototype */
$connectionNodePrototype = $connectionNode->prototype('array');
$connectionNodeBuilder = $connectionNodePrototype->children();
} else {
$connectionNodeBuilder = $connectionNode->children();
}
$connectionNodeBuilder->scalarNode('driver')
->defaultValue('mysql');
$connectionNodeBuilder->scalarNode('user')
->defaultValue('root');
$connectionNodeBuilder->scalarNode('password')
->defaultValue('');
$connectionNodeBuilder->scalarNode('dsn')
->cannotBeEmpty();
$connectionNodeBuilder->scalarNode('classname')
->defaultValue('\Propel\Runtime\Connection\ConnectionWrapper');
return $connectionNode;
} | php | public function buildConnectionNode($rootName, $isArray)
{
$treeBuilder = new TreeBuilder();
$connectionNode = $treeBuilder->root($rootName);
if ($isArray) {
/** @var ArrayNodeDefinition $connectionNodePrototype */
$connectionNodePrototype = $connectionNode->prototype('array');
$connectionNodeBuilder = $connectionNodePrototype->children();
} else {
$connectionNodeBuilder = $connectionNode->children();
}
$connectionNodeBuilder->scalarNode('driver')
->defaultValue('mysql');
$connectionNodeBuilder->scalarNode('user')
->defaultValue('root');
$connectionNodeBuilder->scalarNode('password')
->defaultValue('');
$connectionNodeBuilder->scalarNode('dsn')
->cannotBeEmpty();
$connectionNodeBuilder->scalarNode('classname')
->defaultValue('\Propel\Runtime\Connection\ConnectionWrapper');
return $connectionNode;
} | [
"public",
"function",
"buildConnectionNode",
"(",
"$",
"rootName",
",",
"$",
"isArray",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"connectionNode",
"=",
"$",
"treeBuilder",
"->",
"root",
"(",
"$",
"rootName",
")",
";",
... | Build a configuration node describing one or more database connection
@param string $rootName Node name.
@param bool $isArray Whether the node is a single connection or an array of connections.
@return ArrayNodeDefinition|NodeDefinition Connection(s) node. | [
"Build",
"a",
"configuration",
"node",
"describing",
"one",
"or",
"more",
"database",
"connection"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Config/DatabaseConfiguration.php#L76-L104 | train |
grom358/pharborist | src/StatementBlockNode.php | StatementBlockNode.getUseDeclarations | public function getUseDeclarations() {
$declarations = [];
/** @var \Pharborist\Namespaces\UseDeclarationBlockNode[] $use_blocks */
$use_blocks = $this->children(Filter::isInstanceOf('\Pharborist\Namespaces\UseDeclarationBlockNode'));
foreach ($use_blocks as $use_block) {
foreach ($use_block->getDeclarationStatements() as $use_statement) {
$declarations = array_merge($declarations, $use_statement->getDeclarations()->toArray());
}
}
return new NodeCollection($declarations, FALSE);
} | php | public function getUseDeclarations() {
$declarations = [];
/** @var \Pharborist\Namespaces\UseDeclarationBlockNode[] $use_blocks */
$use_blocks = $this->children(Filter::isInstanceOf('\Pharborist\Namespaces\UseDeclarationBlockNode'));
foreach ($use_blocks as $use_block) {
foreach ($use_block->getDeclarationStatements() as $use_statement) {
$declarations = array_merge($declarations, $use_statement->getDeclarations()->toArray());
}
}
return new NodeCollection($declarations, FALSE);
} | [
"public",
"function",
"getUseDeclarations",
"(",
")",
"{",
"$",
"declarations",
"=",
"[",
"]",
";",
"/** @var \\Pharborist\\Namespaces\\UseDeclarationBlockNode[] $use_blocks */",
"$",
"use_blocks",
"=",
"$",
"this",
"->",
"children",
"(",
"Filter",
"::",
"isInstanceOf",... | Get the use declarations of this statement block.
@return NodeCollection|UseDeclarationNode[]
Use declarations. | [
"Get",
"the",
"use",
"declarations",
"of",
"this",
"statement",
"block",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/StatementBlockNode.php#L38-L48 | train |
grom358/pharborist | src/StatementBlockNode.php | StatementBlockNode.getClassAliases | public function getClassAliases() {
$mappings = array();
foreach ($this->getUseDeclarations() as $use_declaration) {
if ($use_declaration->isClass()) {
$mappings[$use_declaration->getBoundedName()] = $use_declaration->getName()->getAbsolutePath();
}
}
return $mappings;
} | php | public function getClassAliases() {
$mappings = array();
foreach ($this->getUseDeclarations() as $use_declaration) {
if ($use_declaration->isClass()) {
$mappings[$use_declaration->getBoundedName()] = $use_declaration->getName()->getAbsolutePath();
}
}
return $mappings;
} | [
"public",
"function",
"getClassAliases",
"(",
")",
"{",
"$",
"mappings",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getUseDeclarations",
"(",
")",
"as",
"$",
"use_declaration",
")",
"{",
"if",
"(",
"$",
"use_declaration",
"->",
"isC... | Return mapping of class names to fully qualified names.
@return array
Associative array of namespace alias to fully qualified names. | [
"Return",
"mapping",
"of",
"class",
"names",
"to",
"fully",
"qualified",
"names",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/StatementBlockNode.php#L56-L64 | train |
grom358/pharborist | src/StatementBlockNode.php | StatementBlockNode.appendStatement | public function appendStatement(StatementNode $statementNode) {
if (!$this->isEmpty() && $this->firstToken()->getType() === '{') {
$this->lastChild()->before($statementNode);
}
else {
$this->appendChild($statementNode);
}
return $this;
} | php | public function appendStatement(StatementNode $statementNode) {
if (!$this->isEmpty() && $this->firstToken()->getType() === '{') {
$this->lastChild()->before($statementNode);
}
else {
$this->appendChild($statementNode);
}
return $this;
} | [
"public",
"function",
"appendStatement",
"(",
"StatementNode",
"$",
"statementNode",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEmpty",
"(",
")",
"&&",
"$",
"this",
"->",
"firstToken",
"(",
")",
"->",
"getType",
"(",
")",
"===",
"'{'",
")",
"{",
... | Append statement to block.
@param StatementNode $statementNode
Statement to append.
@return $this | [
"Append",
"statement",
"to",
"block",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/StatementBlockNode.php#L73-L81 | train |
NotifyMeHQ/notifyme | src/Adapters/Slack/SlackFactory.php | SlackFactory.make | public function make(array $config)
{
Arr::requires($config, ['token']);
$client = new Client();
return new SlackGateway($client, $config);
} | php | public function make(array $config)
{
Arr::requires($config, ['token']);
$client = new Client();
return new SlackGateway($client, $config);
} | [
"public",
"function",
"make",
"(",
"array",
"$",
"config",
")",
"{",
"Arr",
"::",
"requires",
"(",
"$",
"config",
",",
"[",
"'token'",
"]",
")",
";",
"$",
"client",
"=",
"new",
"Client",
"(",
")",
";",
"return",
"new",
"SlackGateway",
"(",
"$",
"cl... | Create a new slack gateway instance.
@param string[] $config
@return \NotifyMeHQ\Adapters\Slack\SlackGateway | [
"Create",
"a",
"new",
"slack",
"gateway",
"instance",
"."
] | 2af4bdcfe9df6db7ea79e2dce90b106ccb285b06 | https://github.com/NotifyMeHQ/notifyme/blob/2af4bdcfe9df6db7ea79e2dce90b106ccb285b06/src/Adapters/Slack/SlackFactory.php#L27-L34 | train |
BoldGrid/library | src/Library/Configs.php | Configs.get | public static function get( $key = null ) {
$configs = self::$configs;
if ( $key ) {
$configs = ! empty( self::$configs[ $key ] ) ? self::$configs[ $key ] : null;
} else {
$configs = self::$configs;
}
return $configs;
} | php | public static function get( $key = null ) {
$configs = self::$configs;
if ( $key ) {
$configs = ! empty( self::$configs[ $key ] ) ? self::$configs[ $key ] : null;
} else {
$configs = self::$configs;
}
return $configs;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"configs",
"=",
"self",
"::",
"$",
"configs",
";",
"if",
"(",
"$",
"key",
")",
"{",
"$",
"configs",
"=",
"!",
"empty",
"(",
"self",
"::",
"$",
"configs",
"[",
"... | Get configs or config by key.
@since 1.0.0
@param [type] $key [description]
@return [type] [description] | [
"Get",
"configs",
"or",
"config",
"by",
"key",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Configs.php#L95-L104 | train |
grom358/pharborist | src/Filter.php | Filter.any | public static function any($filters) {
return function ($node) use ($filters) {
foreach ($filters as $filter) {
if ($filter($node)) {
return TRUE;
}
}
return FALSE;
};
} | php | public static function any($filters) {
return function ($node) use ($filters) {
foreach ($filters as $filter) {
if ($filter($node)) {
return TRUE;
}
}
return FALSE;
};
} | [
"public",
"static",
"function",
"any",
"(",
"$",
"filters",
")",
"{",
"return",
"function",
"(",
"$",
"node",
")",
"use",
"(",
"$",
"filters",
")",
"{",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"filter",
")",
"{",
"if",
"(",
"$",
"filter",
"(",
... | Callback returns true if any of the callbacks pass.
@param callable[] $filters
@return callable | [
"Callback",
"returns",
"true",
"if",
"any",
"of",
"the",
"callbacks",
"pass",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Filter.php#L20-L29 | train |
grom358/pharborist | src/Filter.php | Filter.all | public static function all($filters) {
return function ($node) use ($filters) {
foreach ($filters as $filter) {
if (!$filter($node)) {
return FALSE;
}
}
return TRUE;
};
} | php | public static function all($filters) {
return function ($node) use ($filters) {
foreach ($filters as $filter) {
if (!$filter($node)) {
return FALSE;
}
}
return TRUE;
};
} | [
"public",
"static",
"function",
"all",
"(",
"$",
"filters",
")",
"{",
"return",
"function",
"(",
"$",
"node",
")",
"use",
"(",
"$",
"filters",
")",
"{",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"filter",
")",
"{",
"if",
"(",
"!",
"$",
"filter",
... | Callback returns true if all of the callbacks pass.
@param callable[] $filters
@return callable | [
"Callback",
"returns",
"true",
"if",
"all",
"of",
"the",
"callbacks",
"pass",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Filter.php#L37-L46 | train |
grom358/pharborist | src/Filter.php | Filter.isInstanceOf | public static function isInstanceOf($class_name) {
$classes = func_get_args();
return function ($node) use ($classes) {
foreach ($classes as $class) {
if ($node instanceof $class) {
return TRUE;
}
}
return FALSE;
};
} | php | public static function isInstanceOf($class_name) {
$classes = func_get_args();
return function ($node) use ($classes) {
foreach ($classes as $class) {
if ($node instanceof $class) {
return TRUE;
}
}
return FALSE;
};
} | [
"public",
"static",
"function",
"isInstanceOf",
"(",
"$",
"class_name",
")",
"{",
"$",
"classes",
"=",
"func_get_args",
"(",
")",
";",
"return",
"function",
"(",
"$",
"node",
")",
"use",
"(",
"$",
"classes",
")",
"{",
"foreach",
"(",
"$",
"classes",
"a... | Callback to filter for nodes of certain types.
@param string $class_name ...
At least one fully-qualified Pharborist node type to search for.
@return callable | [
"Callback",
"to",
"filter",
"for",
"nodes",
"of",
"certain",
"types",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Filter.php#L56-L67 | train |
grom358/pharborist | src/Filter.php | Filter.isFunction | public static function isFunction($function_name) {
$function_names = func_get_args();
return function ($node) use ($function_names) {
if ($node instanceof FunctionDeclarationNode) {
return in_array($node->getName()->getText(), $function_names, TRUE);
}
return FALSE;
};
} | php | public static function isFunction($function_name) {
$function_names = func_get_args();
return function ($node) use ($function_names) {
if ($node instanceof FunctionDeclarationNode) {
return in_array($node->getName()->getText(), $function_names, TRUE);
}
return FALSE;
};
} | [
"public",
"static",
"function",
"isFunction",
"(",
"$",
"function_name",
")",
"{",
"$",
"function_names",
"=",
"func_get_args",
"(",
")",
";",
"return",
"function",
"(",
"$",
"node",
")",
"use",
"(",
"$",
"function_names",
")",
"{",
"if",
"(",
"$",
"node... | Callback to filter for specific function declaration.
@param string $function_name ...
At least one function name to search for.
@return callable | [
"Callback",
"to",
"filter",
"for",
"specific",
"function",
"declaration",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Filter.php#L77-L86 | train |
grom358/pharborist | src/Filter.php | Filter.isFunctionCall | public static function isFunctionCall($function_name) {
$function_names = func_get_args();
return function ($node) use ($function_names) {
if ($node instanceof FunctionCallNode) {
return in_array($node->getName()->getText(), $function_names, TRUE);
}
return FALSE;
};
} | php | public static function isFunctionCall($function_name) {
$function_names = func_get_args();
return function ($node) use ($function_names) {
if ($node instanceof FunctionCallNode) {
return in_array($node->getName()->getText(), $function_names, TRUE);
}
return FALSE;
};
} | [
"public",
"static",
"function",
"isFunctionCall",
"(",
"$",
"function_name",
")",
"{",
"$",
"function_names",
"=",
"func_get_args",
"(",
")",
";",
"return",
"function",
"(",
"$",
"node",
")",
"use",
"(",
"$",
"function_names",
")",
"{",
"if",
"(",
"$",
"... | Callback to filter for calls to a function.
@param string $function_name ...
At least one function name to search for.
@return callable | [
"Callback",
"to",
"filter",
"for",
"calls",
"to",
"a",
"function",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Filter.php#L96-L105 | train |
grom358/pharborist | src/Filter.php | Filter.isClass | public static function isClass($class_name) {
$class_names = func_get_args();
return function ($node) use ($class_names) {
if ($node instanceof ClassNode) {
return in_array($node->getName()->getText(), $class_names, TRUE);
}
return FALSE;
};
} | php | public static function isClass($class_name) {
$class_names = func_get_args();
return function ($node) use ($class_names) {
if ($node instanceof ClassNode) {
return in_array($node->getName()->getText(), $class_names, TRUE);
}
return FALSE;
};
} | [
"public",
"static",
"function",
"isClass",
"(",
"$",
"class_name",
")",
"{",
"$",
"class_names",
"=",
"func_get_args",
"(",
")",
";",
"return",
"function",
"(",
"$",
"node",
")",
"use",
"(",
"$",
"class_names",
")",
"{",
"if",
"(",
"$",
"node",
"instan... | Callback to filter for specific class declaration.
@param string $class_name ...
At least one class name to search for.
@return callable | [
"Callback",
"to",
"filter",
"for",
"specific",
"class",
"declaration",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Filter.php#L115-L124 | train |
grom358/pharborist | src/Filter.php | Filter.isClassMethodCall | public static function isClassMethodCall($class_name, $method_name) {
return function ($node) use ($class_name, $method_name) {
if ($node instanceof ClassMethodCallNode) {
$call_class_name_node = $node->getClassName();
$call_class_name = $call_class_name_node instanceof NameNode ? $call_class_name_node->getAbsolutePath() : $call_class_name_node->getText();
$class_matches = $call_class_name === $class_name;
$method_matches = $node->getMethodName()->getText() === $method_name;
return $class_matches && $method_matches;
}
return FALSE;
};
} | php | public static function isClassMethodCall($class_name, $method_name) {
return function ($node) use ($class_name, $method_name) {
if ($node instanceof ClassMethodCallNode) {
$call_class_name_node = $node->getClassName();
$call_class_name = $call_class_name_node instanceof NameNode ? $call_class_name_node->getAbsolutePath() : $call_class_name_node->getText();
$class_matches = $call_class_name === $class_name;
$method_matches = $node->getMethodName()->getText() === $method_name;
return $class_matches && $method_matches;
}
return FALSE;
};
} | [
"public",
"static",
"function",
"isClassMethodCall",
"(",
"$",
"class_name",
",",
"$",
"method_name",
")",
"{",
"return",
"function",
"(",
"$",
"node",
")",
"use",
"(",
"$",
"class_name",
",",
"$",
"method_name",
")",
"{",
"if",
"(",
"$",
"node",
"instan... | Callback to filter for calls to a class method.
@param string $class_name
Fully qualified class name or expression string.
@param string $method_name
Method name or expression string.
@return callable
Filter callable. | [
"Callback",
"to",
"filter",
"for",
"calls",
"to",
"a",
"class",
"method",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Filter.php#L136-L147 | train |
grom358/pharborist | src/Filter.php | Filter.isComment | public static function isComment($include_doc_comment = TRUE) {
if ($include_doc_comment) {
return function ($node) {
if ($node instanceof LineCommentBlockNode) {
return TRUE;
}
elseif ($node instanceof CommentNode) {
return !($node->parent() instanceof LineCommentBlockNode);
}
else {
return FALSE;
}
};
}
else {
return function ($node) {
if ($node instanceof LineCommentBlockNode) {
return TRUE;
}
elseif ($node instanceof DocCommentNode) {
return FALSE;
}
elseif ($node instanceof CommentNode) {
return !($node->parent() instanceof LineCommentBlockNode);
}
else {
return FALSE;
}
};
}
} | php | public static function isComment($include_doc_comment = TRUE) {
if ($include_doc_comment) {
return function ($node) {
if ($node instanceof LineCommentBlockNode) {
return TRUE;
}
elseif ($node instanceof CommentNode) {
return !($node->parent() instanceof LineCommentBlockNode);
}
else {
return FALSE;
}
};
}
else {
return function ($node) {
if ($node instanceof LineCommentBlockNode) {
return TRUE;
}
elseif ($node instanceof DocCommentNode) {
return FALSE;
}
elseif ($node instanceof CommentNode) {
return !($node->parent() instanceof LineCommentBlockNode);
}
else {
return FALSE;
}
};
}
} | [
"public",
"static",
"function",
"isComment",
"(",
"$",
"include_doc_comment",
"=",
"TRUE",
")",
"{",
"if",
"(",
"$",
"include_doc_comment",
")",
"{",
"return",
"function",
"(",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"LineCommentBlockNod... | Callback to filter comments.
@param bool $include_doc_comment
@return callable | [
"Callback",
"to",
"filter",
"comments",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Filter.php#L154-L184 | train |
grom358/pharborist | src/Filter.php | Filter.isTokenType | public static function isTokenType($type) {
$types = func_get_args();
return function ($node) use ($types) {
return $node instanceof TokenNode && in_array($node->getType(), $types);
};
} | php | public static function isTokenType($type) {
$types = func_get_args();
return function ($node) use ($types) {
return $node instanceof TokenNode && in_array($node->getType(), $types);
};
} | [
"public",
"static",
"function",
"isTokenType",
"(",
"$",
"type",
")",
"{",
"$",
"types",
"=",
"func_get_args",
"(",
")",
";",
"return",
"function",
"(",
"$",
"node",
")",
"use",
"(",
"$",
"types",
")",
"{",
"return",
"$",
"node",
"instanceof",
"TokenNo... | Callback to test if match to given token type.
@param int|string $type
Token type.
@return callable | [
"Callback",
"to",
"test",
"if",
"match",
"to",
"given",
"token",
"type",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Filter.php#L207-L212 | train |
grom358/pharborist | src/Filter.php | Filter.isNewline | public static function isNewline() {
static $callback = NULL;
if (!$callback) {
$callback = function (Node $node) {
return $node instanceof WhitespaceNode && $node->getNewlineCount() > 0;
};
}
return $callback;
} | php | public static function isNewline() {
static $callback = NULL;
if (!$callback) {
$callback = function (Node $node) {
return $node instanceof WhitespaceNode && $node->getNewlineCount() > 0;
};
}
return $callback;
} | [
"public",
"static",
"function",
"isNewline",
"(",
")",
"{",
"static",
"$",
"callback",
"=",
"NULL",
";",
"if",
"(",
"!",
"$",
"callback",
")",
"{",
"$",
"callback",
"=",
"function",
"(",
"Node",
"$",
"node",
")",
"{",
"return",
"$",
"node",
"instance... | Callback to match whitespace containing newlines.
@return callable | [
"Callback",
"to",
"match",
"whitespace",
"containing",
"newlines",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Filter.php#L230-L238 | train |
GrahamCampbell/Analyzer | src/DocVisitor.php | DocVisitor.create | public static function create(string $contents)
{
$contextInst = new ContextFactory();
$context = function (string $namespace) use ($contents, $contextInst) {
return $contextInst->createForNamespace($namespace, $contents);
};
$phpdocInst = DocBlockFactory::createInstance();
$phpdoc = function (string $doc, Context $context) use ($phpdocInst) {
return $phpdocInst->create($doc, $context);
};
return new self($context, $phpdoc);
} | php | public static function create(string $contents)
{
$contextInst = new ContextFactory();
$context = function (string $namespace) use ($contents, $contextInst) {
return $contextInst->createForNamespace($namespace, $contents);
};
$phpdocInst = DocBlockFactory::createInstance();
$phpdoc = function (string $doc, Context $context) use ($phpdocInst) {
return $phpdocInst->create($doc, $context);
};
return new self($context, $phpdoc);
} | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"contents",
")",
"{",
"$",
"contextInst",
"=",
"new",
"ContextFactory",
"(",
")",
";",
"$",
"context",
"=",
"function",
"(",
"string",
"$",
"namespace",
")",
"use",
"(",
"$",
"contents",
",",
... | Create a new doc visitor aware of file contents.
@param string $contents
@return \GrahamCampbell\Analyzer\DocVisitor | [
"Create",
"a",
"new",
"doc",
"visitor",
"aware",
"of",
"file",
"contents",
"."
] | e918797f052c001362bda65e7364026910608bef | https://github.com/GrahamCampbell/Analyzer/blob/e918797f052c001362bda65e7364026910608bef/src/DocVisitor.php#L67-L82 | train |
GrahamCampbell/Analyzer | src/DocVisitor.php | DocVisitor.enterNode | public function enterNode(Node $node)
{
if ($node instanceof Namespace_) {
$this->resetContext($node->name);
}
$this->recordDoc($node->getAttribute('comments', []));
return $node;
} | php | public function enterNode(Node $node)
{
if ($node instanceof Namespace_) {
$this->resetContext($node->name);
}
$this->recordDoc($node->getAttribute('comments', []));
return $node;
} | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Namespace_",
")",
"{",
"$",
"this",
"->",
"resetContext",
"(",
"$",
"node",
"->",
"name",
")",
";",
"}",
"$",
"this",
"->",
"recordDoc",
"("... | Enter the node and record the phpdoc.
@param \PhpParser\Node $node
@return \PhpParser\Node | [
"Enter",
"the",
"node",
"and",
"record",
"the",
"phpdoc",
"."
] | e918797f052c001362bda65e7364026910608bef | https://github.com/GrahamCampbell/Analyzer/blob/e918797f052c001362bda65e7364026910608bef/src/DocVisitor.php#L118-L127 | train |
GrahamCampbell/Analyzer | src/DocVisitor.php | DocVisitor.recordDoc | protected function recordDoc(array $comments)
{
$callable = $this->phpdocFactory;
foreach ($comments as $comment) {
if ($comment instanceof Doc) {
$this->doc[] = $callable($comment->getText(), $this->context);
}
}
} | php | protected function recordDoc(array $comments)
{
$callable = $this->phpdocFactory;
foreach ($comments as $comment) {
if ($comment instanceof Doc) {
$this->doc[] = $callable($comment->getText(), $this->context);
}
}
} | [
"protected",
"function",
"recordDoc",
"(",
"array",
"$",
"comments",
")",
"{",
"$",
"callable",
"=",
"$",
"this",
"->",
"phpdocFactory",
";",
"foreach",
"(",
"$",
"comments",
"as",
"$",
"comment",
")",
"{",
"if",
"(",
"$",
"comment",
"instanceof",
"Doc",... | Reset the visitor context.
@param \PhpParser\Comment[] $comments
@return void | [
"Reset",
"the",
"visitor",
"context",
"."
] | e918797f052c001362bda65e7364026910608bef | https://github.com/GrahamCampbell/Analyzer/blob/e918797f052c001362bda65e7364026910608bef/src/DocVisitor.php#L150-L159 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.sortUnique | protected static function sortUnique($nodes) {
$sort = [];
$detached = [];
foreach ($nodes as $node) {
$key = $node->sortKey();
if ($key[0] === '~') {
$detached[] = $node;
}
else {
$sort[$key] = $node;
}
}
ksort($sort, SORT_NATURAL);
return array_merge(array_values($sort), $detached);
} | php | protected static function sortUnique($nodes) {
$sort = [];
$detached = [];
foreach ($nodes as $node) {
$key = $node->sortKey();
if ($key[0] === '~') {
$detached[] = $node;
}
else {
$sort[$key] = $node;
}
}
ksort($sort, SORT_NATURAL);
return array_merge(array_values($sort), $detached);
} | [
"protected",
"static",
"function",
"sortUnique",
"(",
"$",
"nodes",
")",
"{",
"$",
"sort",
"=",
"[",
"]",
";",
"$",
"detached",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"key",
"=",
"$",
"node",
"->",
"... | Sort nodes and remove duplicates
@param Node[] $nodes
@return Node[] | [
"Sort",
"nodes",
"and",
"remove",
"duplicates"
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L20-L34 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.slice | public function slice($start_index, $end_index = NULL) {
if ($start_index < 0) {
$start_index = $this->count() + $start_index;
}
if ($end_index < 0) {
$end_index = $this->count() + $end_index;
}
$last_index = $this->count() - 1;
if ($start_index > $last_index) {
$start_index = $last_index;
}
if ($end_index !== NULL) {
if ($end_index > $last_index) {
$end_index = $last_index;
}
if ($start_index > $end_index) {
$start_index = $end_index;
}
$length = $end_index - $start_index;
}
else {
$length = $this->count() - $start_index;
}
return new NodeCollection(array_slice($this->nodes, $start_index, $length));
} | php | public function slice($start_index, $end_index = NULL) {
if ($start_index < 0) {
$start_index = $this->count() + $start_index;
}
if ($end_index < 0) {
$end_index = $this->count() + $end_index;
}
$last_index = $this->count() - 1;
if ($start_index > $last_index) {
$start_index = $last_index;
}
if ($end_index !== NULL) {
if ($end_index > $last_index) {
$end_index = $last_index;
}
if ($start_index > $end_index) {
$start_index = $end_index;
}
$length = $end_index - $start_index;
}
else {
$length = $this->count() - $start_index;
}
return new NodeCollection(array_slice($this->nodes, $start_index, $length));
} | [
"public",
"function",
"slice",
"(",
"$",
"start_index",
",",
"$",
"end_index",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"start_index",
"<",
"0",
")",
"{",
"$",
"start_index",
"=",
"$",
"this",
"->",
"count",
"(",
")",
"+",
"$",
"start_index",
";",
"}... | Reduce the set of matched nodes to a subset specified by a range.
@param int $start_index
@param int $end_index
@return NodeCollection | [
"Reduce",
"the",
"set",
"of",
"matched",
"nodes",
"to",
"a",
"subset",
"specified",
"by",
"a",
"range",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L132-L156 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.indexOf | public function indexOf(callable $callback) {
foreach ($this->nodes as $i => $node) {
if ($callback($node)) {
return $i;
}
}
return -1;
} | php | public function indexOf(callable $callback) {
foreach ($this->nodes as $i => $node) {
if ($callback($node)) {
return $i;
}
}
return -1;
} | [
"public",
"function",
"indexOf",
"(",
"callable",
"$",
"callback",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"i",
"=>",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"callback",
"(",
"$",
"node",
")",
")",
"{",
"return",
"$",
"i",... | Index of first element that is matched by callback.
@param callable $callback
Callback to test for node match.
@return int
Index of first element that is matched by callback. | [
"Index",
"of",
"first",
"element",
"that",
"is",
"matched",
"by",
"callback",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L219-L226 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.is | public function is(callable $callback) {
foreach ($this->nodes as $node) {
if ($callback($node)) {
return TRUE;
}
}
return FALSE;
} | php | public function is(callable $callback) {
foreach ($this->nodes as $node) {
if ($callback($node)) {
return TRUE;
}
}
return FALSE;
} | [
"public",
"function",
"is",
"(",
"callable",
"$",
"callback",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"callback",
"(",
"$",
"node",
")",
")",
"{",
"return",
"TRUE",
";",
"}",
"}",
"return... | Test is any element in collection matches.
@param callable $callback
Callback to test for node match.
@return boolean
TRUE if any element in set of nodes matches. | [
"Test",
"is",
"any",
"element",
"in",
"collection",
"matches",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L237-L244 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.closest | public function closest(callable $callback) {
$matches = [];
foreach ($this->nodes as $node) {
if ($match = $node->closest($callback)) {
$matches[] = $match;
}
}
return new NodeCollection($matches);
} | php | public function closest(callable $callback) {
$matches = [];
foreach ($this->nodes as $node) {
if ($match = $node->closest($callback)) {
$matches[] = $match;
}
}
return new NodeCollection($matches);
} | [
"public",
"function",
"closest",
"(",
"callable",
"$",
"callback",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"match",
"=",
"$",
"node",
"->",
"closest",
... | For each node in the collection, get the first node matched by the
callback by testing this node and traversing up through its ancestors in
the tree.
@param callable $callback Callback to test for match.
@return Node | [
"For",
"each",
"node",
"in",
"the",
"collection",
"get",
"the",
"first",
"node",
"matched",
"by",
"the",
"callback",
"by",
"testing",
"this",
"node",
"and",
"traversing",
"up",
"through",
"its",
"ancestors",
"in",
"the",
"tree",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L298-L306 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.children | public function children(callable $callback = NULL) {
$matches = [];
foreach ($this->nodes as $node) {
if ($node instanceof ParentNode) {
$matches = array_merge($matches, $node->children($callback)->nodes);
}
}
return new NodeCollection($matches);
} | php | public function children(callable $callback = NULL) {
$matches = [];
foreach ($this->nodes as $node) {
if ($node instanceof ParentNode) {
$matches = array_merge($matches, $node->children($callback)->nodes);
}
}
return new NodeCollection($matches);
} | [
"public",
"function",
"children",
"(",
"callable",
"$",
"callback",
"=",
"NULL",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"ParentNode"... | Get the immediate children of each node in the set of matched nodes.
@param callable $callback An optional callback to filter by.
@return NodeCollection | [
"Get",
"the",
"immediate",
"children",
"of",
"each",
"node",
"in",
"the",
"set",
"of",
"matched",
"nodes",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L313-L321 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.clear | public function clear() {
foreach ($this->nodes as $node) {
if ($node instanceof ParentNode) {
$node->clear();
}
}
return $this;
} | php | public function clear() {
foreach ($this->nodes as $node) {
if ($node instanceof ParentNode) {
$node->clear();
}
}
return $this;
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"ParentNode",
")",
"{",
"$",
"node",
"->",
"clear",
"(",
")",
";",
"}",
"}",
"return",
"$... | Remove all child nodes of the set of matched elements.
@return $this | [
"Remove",
"all",
"child",
"nodes",
"of",
"the",
"set",
"of",
"matched",
"elements",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L328-L335 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.previous | public function previous(callable $callback = NULL) {
$matches = [];
foreach ($this->nodes as $node) {
if ($match = $node->previous($callback)) {
$matches[] = $match;
}
}
return new NodeCollection($matches);
} | php | public function previous(callable $callback = NULL) {
$matches = [];
foreach ($this->nodes as $node) {
if ($match = $node->previous($callback)) {
$matches[] = $match;
}
}
return new NodeCollection($matches);
} | [
"public",
"function",
"previous",
"(",
"callable",
"$",
"callback",
"=",
"NULL",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"match",
"=",
"$",
"node",
"->... | Get the immediately preceding sibling of each node in the set of matched
nodes. If a callback is provided, it retrieves the next sibling only if
the callback returns TRUE.
@param callable $callback An optional callback to filter by.
@return NodeCollection | [
"Get",
"the",
"immediately",
"preceding",
"sibling",
"of",
"each",
"node",
"in",
"the",
"set",
"of",
"matched",
"nodes",
".",
"If",
"a",
"callback",
"is",
"provided",
"it",
"retrieves",
"the",
"next",
"sibling",
"only",
"if",
"the",
"callback",
"returns",
... | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L344-L352 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.previousAll | public function previousAll(callable $callback = NULL) {
$matches = [];
foreach ($this->nodes as $node) {
$matches = array_merge($matches, $node->previousAll($callback)->nodes);
}
return new NodeCollection($matches);
} | php | public function previousAll(callable $callback = NULL) {
$matches = [];
foreach ($this->nodes as $node) {
$matches = array_merge($matches, $node->previousAll($callback)->nodes);
}
return new NodeCollection($matches);
} | [
"public",
"function",
"previousAll",
"(",
"callable",
"$",
"callback",
"=",
"NULL",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"matches",
"=",
"array_merge",
"(",
"$",
... | Get all preceding siblings of each node in the set of matched nodes,
optionally filtered by a callback.
@param callable $callback An optional callback to filter by.
@return NodeCollection | [
"Get",
"all",
"preceding",
"siblings",
"of",
"each",
"node",
"in",
"the",
"set",
"of",
"matched",
"nodes",
"optionally",
"filtered",
"by",
"a",
"callback",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L360-L366 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.previousUntil | public function previousUntil(callable $callback, $inclusive = FALSE) {
$matches = [];
foreach ($this->nodes as $node) {
$matches = array_merge($matches, $node->previousUntil($callback, $inclusive)->nodes);
}
return new NodeCollection($matches);
} | php | public function previousUntil(callable $callback, $inclusive = FALSE) {
$matches = [];
foreach ($this->nodes as $node) {
$matches = array_merge($matches, $node->previousUntil($callback, $inclusive)->nodes);
}
return new NodeCollection($matches);
} | [
"public",
"function",
"previousUntil",
"(",
"callable",
"$",
"callback",
",",
"$",
"inclusive",
"=",
"FALSE",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"matches",
"=",
... | Get all preceding siblings of each node up to the node matched by the
callback.
@param callable $callback Callback to test for match.
@param bool $inclusive TRUE to include the node matched by callback.
@return NodeCollection | [
"Get",
"all",
"preceding",
"siblings",
"of",
"each",
"node",
"up",
"to",
"the",
"node",
"matched",
"by",
"the",
"callback",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L375-L381 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.find | public function find(callable $callback) {
$matches = [];
foreach ($this->nodes as $node) {
if ($node instanceof ParentNode) {
$matches = array_merge($matches, $node->find($callback)->nodes);
}
}
return new NodeCollection($matches);
} | php | public function find(callable $callback) {
$matches = [];
foreach ($this->nodes as $node) {
if ($node instanceof ParentNode) {
$matches = array_merge($matches, $node->find($callback)->nodes);
}
}
return new NodeCollection($matches);
} | [
"public",
"function",
"find",
"(",
"callable",
"$",
"callback",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"ParentNode",
")",
"{",
"$"... | Get the descendants of each node in the current set of matched nodes,
filtered by callback.
@param callable $callback Callback to filter by.
@return NodeCollection | [
"Get",
"the",
"descendants",
"of",
"each",
"node",
"in",
"the",
"current",
"set",
"of",
"matched",
"nodes",
"filtered",
"by",
"callback",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L449-L457 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.filter | public function filter(callable $callback) {
$matches = [];
foreach ($this->nodes as $index => $node) {
if ($callback($node, $index)) {
$matches[] = $node;
}
}
return new NodeCollection($matches, FALSE);
} | php | public function filter(callable $callback) {
$matches = [];
foreach ($this->nodes as $index => $node) {
if ($callback($node, $index)) {
$matches[] = $node;
}
}
return new NodeCollection($matches, FALSE);
} | [
"public",
"function",
"filter",
"(",
"callable",
"$",
"callback",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"index",
"=>",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"callback",
"(",
"$",
"no... | Reduce the set of matched nodes to those that pass the callback filter.
@param callable $callback Callback to test for match.
@return NodeCollection | [
"Reduce",
"the",
"set",
"of",
"matched",
"nodes",
"to",
"those",
"that",
"pass",
"the",
"callback",
"filter",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L464-L472 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.has | public function has(callable $callback) {
$matches = [];
foreach ($this->nodes as $node) {
if ($node instanceof ParentNode && $node->has($callback)) {
$matches[] = $node;
}
}
return new NodeCollection($matches, FALSE);
} | php | public function has(callable $callback) {
$matches = [];
foreach ($this->nodes as $node) {
if ($node instanceof ParentNode && $node->has($callback)) {
$matches[] = $node;
}
}
return new NodeCollection($matches, FALSE);
} | [
"public",
"function",
"has",
"(",
"callable",
"$",
"callback",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"ParentNode",
"&&",
"$",
"no... | Reduce the set of matched nodes to those that have a descendant that
match.
@param callable $callback Callback to test for match.
@return NodeCollection | [
"Reduce",
"the",
"set",
"of",
"matched",
"nodes",
"to",
"those",
"that",
"have",
"a",
"descendant",
"that",
"match",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L495-L503 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.first | public function first() {
$matches = [];
if (!empty($this->nodes)) {
$matches[] = $this->nodes[0];
}
return new NodeCollection($matches, FALSE);
} | php | public function first() {
$matches = [];
if (!empty($this->nodes)) {
$matches[] = $this->nodes[0];
}
return new NodeCollection($matches, FALSE);
} | [
"public",
"function",
"first",
"(",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"nodes",
")",
")",
"{",
"$",
"matches",
"[",
"]",
"=",
"$",
"this",
"->",
"nodes",
"[",
"0",
"]",
";",
"}",
"... | Reduce the set of matched nodes to the first in the set. | [
"Reduce",
"the",
"set",
"of",
"matched",
"nodes",
"to",
"the",
"first",
"in",
"the",
"set",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L508-L514 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.last | public function last() {
$matches = [];
if (!empty($this->nodes)) {
$matches[] = $this->nodes[count($this->nodes) - 1];
}
return new NodeCollection($matches, FALSE);
} | php | public function last() {
$matches = [];
if (!empty($this->nodes)) {
$matches[] = $this->nodes[count($this->nodes) - 1];
}
return new NodeCollection($matches, FALSE);
} | [
"public",
"function",
"last",
"(",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"nodes",
")",
")",
"{",
"$",
"matches",
"[",
"]",
"=",
"$",
"this",
"->",
"nodes",
"[",
"count",
"(",
"$",
"this... | Reduce the set of matched nodes to the last in the set. | [
"Reduce",
"the",
"set",
"of",
"matched",
"nodes",
"to",
"the",
"last",
"in",
"the",
"set",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L519-L525 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.insertBefore | public function insertBefore($targets) {
foreach ($this->nodes as $node) {
$node->insertBefore($targets);
}
return $this;
} | php | public function insertBefore($targets) {
foreach ($this->nodes as $node) {
$node->insertBefore($targets);
}
return $this;
} | [
"public",
"function",
"insertBefore",
"(",
"$",
"targets",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"insertBefore",
"(",
"$",
"targets",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Insert every node in the set of matched nodes before the targets.
@param Node|Node[]|NodeCollection $targets Nodes to insert before.
@return $this | [
"Insert",
"every",
"node",
"in",
"the",
"set",
"of",
"matched",
"nodes",
"before",
"the",
"targets",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L532-L537 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.before | public function before($nodes) {
foreach ($this->nodes as $i => $node) {
$node->before($i === 0 ? $nodes : clone $nodes);
}
return $this;
} | php | public function before($nodes) {
foreach ($this->nodes as $i => $node) {
$node->before($i === 0 ? $nodes : clone $nodes);
}
return $this;
} | [
"public",
"function",
"before",
"(",
"$",
"nodes",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"i",
"=>",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"before",
"(",
"$",
"i",
"===",
"0",
"?",
"$",
"nodes",
":",
"clone",
"$",
... | Insert nodes before each node in the set of matched nodes.
@param Node|Node[]|NodeCollection $nodes Nodes to insert.
@return $this | [
"Insert",
"nodes",
"before",
"each",
"node",
"in",
"the",
"set",
"of",
"matched",
"nodes",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L544-L549 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.insertAfter | public function insertAfter($targets) {
foreach ($this->nodes as $node) {
$node->insertAfter($targets);
}
return $this;
} | php | public function insertAfter($targets) {
foreach ($this->nodes as $node) {
$node->insertAfter($targets);
}
return $this;
} | [
"public",
"function",
"insertAfter",
"(",
"$",
"targets",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"insertAfter",
"(",
"$",
"targets",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Insert every node in the set of matched nodes after the targets.
@param Node|Node[]|NodeCollection $targets Nodes to insert after.
@return $this | [
"Insert",
"every",
"node",
"in",
"the",
"set",
"of",
"matched",
"nodes",
"after",
"the",
"targets",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L556-L561 | train |
grom358/pharborist | src/NodeCollection.php | NodeCollection.after | public function after($nodes) {
foreach ($this->nodes as $i => $node) {
$node->after($i === 0 ? $nodes : clone $nodes);
}
return $this;
} | php | public function after($nodes) {
foreach ($this->nodes as $i => $node) {
$node->after($i === 0 ? $nodes : clone $nodes);
}
return $this;
} | [
"public",
"function",
"after",
"(",
"$",
"nodes",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"i",
"=>",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"after",
"(",
"$",
"i",
"===",
"0",
"?",
"$",
"nodes",
":",
"clone",
"$",
... | Insert nodes after each node in the set of matched nodes.
@param Node|Node[]|NodeCollection $nodes Nodes to insert.
@return $this | [
"Insert",
"nodes",
"after",
"each",
"node",
"in",
"the",
"set",
"of",
"matched",
"nodes",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/NodeCollection.php#L568-L573 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.