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
BoldGrid/library
src/Library/Key/Validate.php
Validate.isValid
public function isValid( $key = null ) { $key = $key ? $this->sanitizeKey( $key ) : $this->getKey(); return strlen( $key ) === 35; }
php
public function isValid( $key = null ) { $key = $key ? $this->sanitizeKey( $key ) : $this->getKey(); return strlen( $key ) === 35; }
[ "public", "function", "isValid", "(", "$", "key", "=", "null", ")", "{", "$", "key", "=", "$", "key", "?", "$", "this", "->", "sanitizeKey", "(", "$", "key", ")", ":", "$", "this", "->", "getKey", "(", ")", ";", "return", "strlen", "(", "$", "k...
Checks if key is valid length after format and sanitization is done. @since 1.0.0 @param string $key The API key to check. @return bool Is the key valid?
[ "Checks", "if", "key", "is", "valid", "length", "after", "format", "and", "sanitization", "is", "done", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Key/Validate.php#L132-L135
train
melisplatform/melis-cms
src/Controller/PageSeoController.php
PageSeoController.getSeoKeywordsByPageId
public function getSeoKeywordsByPageId($pageId) { $pageId = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', '')); $data = array(); $seoKeywords = $pageId->getSeoKeywords($pageId); $data = $seoKeywords; return $data; }
php
public function getSeoKeywordsByPageId($pageId) { $pageId = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', '')); $data = array(); $seoKeywords = $pageId->getSeoKeywords($pageId); $data = $seoKeywords; return $data; }
[ "public", "function", "getSeoKeywordsByPageId", "(", "$", "pageId", ")", "{", "$", "pageId", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'idPage'", ",", "$", "this", "->", "params", "(", ")", "->", "fromQuery", "(", "'idPage'", ...
Return seo keywords @param pageId integer
[ "Return", "seo", "keywords" ]
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/PageSeoController.php#L100-L109
train
melisplatform/melis-cms
src/Controller/PageSeoController.php
PageSeoController.cleanURL
private function cleanURL(string $url = '') { $url = str_replace(' ', '-', $url); // Replaces all spaces with hyphens $url = preg_replace('/[^A-Za-z0-9\/\-]+/', '-', $url); // Replaces special characters with hyphens // remove "/" prefix on generated URL if (substr($url, 0, 1) == '/') { return preg_replace('/\//', '', $url, 1); } return $url; }
php
private function cleanURL(string $url = '') { $url = str_replace(' ', '-', $url); // Replaces all spaces with hyphens $url = preg_replace('/[^A-Za-z0-9\/\-]+/', '-', $url); // Replaces special characters with hyphens // remove "/" prefix on generated URL if (substr($url, 0, 1) == '/') { return preg_replace('/\//', '', $url, 1); } return $url; }
[ "private", "function", "cleanURL", "(", "string", "$", "url", "=", "''", ")", "{", "$", "url", "=", "str_replace", "(", "' '", ",", "'-'", ",", "$", "url", ")", ";", "// Replaces all spaces with hyphens", "$", "url", "=", "preg_replace", "(", "'/[^A-Za-z0-...
Rids the URL from special characters @param string $url @return mixed
[ "Rids", "the", "URL", "from", "special", "characters" ]
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/PageSeoController.php#L302-L313
train
BoldGrid/library
src/Library/Menu/Reseller.php
Reseller.getAttribute
public function getAttribute( $attribute ) { $data = $this->getData(); return ! empty ( $data[$attribute] ) ? $data[$attribute] : ''; }
php
public function getAttribute( $attribute ) { $data = $this->getData(); return ! empty ( $data[$attribute] ) ? $data[$attribute] : ''; }
[ "public", "function", "getAttribute", "(", "$", "attribute", ")", "{", "$", "data", "=", "$", "this", "->", "getData", "(", ")", ";", "return", "!", "empty", "(", "$", "data", "[", "$", "attribute", "]", ")", "?", "$", "data", "[", "$", "attribute"...
Get a specific attribute of our reseller. @since 2.8.0 @param string $attribute The specific attribute to get. @return string
[ "Get", "a", "specific", "attribute", "of", "our", "reseller", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Menu/Reseller.php#L53-L57
train
BoldGrid/library
src/Library/Menu/Reseller.php
Reseller.getData
public function getData() { $data = $this->resellerOption; $data['reseller_identifier'] = ! empty( $data['reseller_identifier'] ) ? strtolower( $data['reseller_identifier'] ) : null; $data['reseller_website_url'] = ! empty( $data['reseller_website_url'] ) ? esc_url( $data['reseller_website_url'] ) : 'https://www.boldgrid.com/'; $data['reseller_title'] = ! empty( $data['reseller_title'] ) ? esc_html( $data['reseller_title'] ) : esc_html( 'BoldGrid.com' ); $data['reseller_support_url'] = ! empty( $data['reseller_support_url'] ) ? esc_url( $data['reseller_support_url'] ) : 'https://www.boldgrid.com/documentation'; $data['reseller_amp_url'] = ! empty( $data['reseller_amp_url'] ) ? esc_url( $data['reseller_amp_url'] ) : 'https://www.boldgrid.com/central'; return $data; }
php
public function getData() { $data = $this->resellerOption; $data['reseller_identifier'] = ! empty( $data['reseller_identifier'] ) ? strtolower( $data['reseller_identifier'] ) : null; $data['reseller_website_url'] = ! empty( $data['reseller_website_url'] ) ? esc_url( $data['reseller_website_url'] ) : 'https://www.boldgrid.com/'; $data['reseller_title'] = ! empty( $data['reseller_title'] ) ? esc_html( $data['reseller_title'] ) : esc_html( 'BoldGrid.com' ); $data['reseller_support_url'] = ! empty( $data['reseller_support_url'] ) ? esc_url( $data['reseller_support_url'] ) : 'https://www.boldgrid.com/documentation'; $data['reseller_amp_url'] = ! empty( $data['reseller_amp_url'] ) ? esc_url( $data['reseller_amp_url'] ) : 'https://www.boldgrid.com/central'; return $data; }
[ "public", "function", "getData", "(", ")", "{", "$", "data", "=", "$", "this", "->", "resellerOption", ";", "$", "data", "[", "'reseller_identifier'", "]", "=", "!", "empty", "(", "$", "data", "[", "'reseller_identifier'", "]", ")", "?", "strtolower", "(...
Get the reseller data. @since 2.4.0 @return array Reseller information.
[ "Get", "the", "reseller", "data", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Menu/Reseller.php#L66-L85
train
BoldGrid/library
src/Library/Menu/Reseller.php
Reseller.getMenuItems
protected function getMenuItems() { $data = $this->getData(); return array( 'topLevel' => array( 'id' => 'reseller-adminbar-icon', 'title' => '<span aria-hidden="true" class="' . $data['reseller_identifier'] . '-icon ab-icon"></span>', 'href' => $data['reseller_website_url'], 'meta' => array( 'class' => 'reseller-node-icon', ), ), 'items' => array( array( 'id' => 'reseller-site-url', 'parent' => 'reseller-adminbar-icon', 'title' => $data['reseller_title'], 'href' => $data['reseller_website_url'], 'meta' => array( 'class' => 'reseller-dropdown', 'target' => '_blank', 'title' => $data['reseller_title'], ), ), array( 'id' => 'reseller-support-center', 'parent' => 'reseller-adminbar-icon', 'title' => esc_html__( 'Support Center', 'boldgrid-library' ), 'href' => $data['reseller_support_url'], 'meta' => array( 'class' => 'reseller-dropdown', 'target' => '_blank', 'title' => __( 'Support Center', 'boldgrid-library' ), ), ), array( 'id' => 'reseller-amp-login', 'parent' => 'reseller-adminbar-icon', 'title' => esc_html__( 'AMP Login', 'boldgrid-library' ), 'href' => $data['reseller_amp_url'], 'meta' => array( 'class' => 'reseller-dropdown', 'target' => '_blank', 'title' => __( 'Account Management', 'boldgrid-library' ), ), ), ), ); }
php
protected function getMenuItems() { $data = $this->getData(); return array( 'topLevel' => array( 'id' => 'reseller-adminbar-icon', 'title' => '<span aria-hidden="true" class="' . $data['reseller_identifier'] . '-icon ab-icon"></span>', 'href' => $data['reseller_website_url'], 'meta' => array( 'class' => 'reseller-node-icon', ), ), 'items' => array( array( 'id' => 'reseller-site-url', 'parent' => 'reseller-adminbar-icon', 'title' => $data['reseller_title'], 'href' => $data['reseller_website_url'], 'meta' => array( 'class' => 'reseller-dropdown', 'target' => '_blank', 'title' => $data['reseller_title'], ), ), array( 'id' => 'reseller-support-center', 'parent' => 'reseller-adminbar-icon', 'title' => esc_html__( 'Support Center', 'boldgrid-library' ), 'href' => $data['reseller_support_url'], 'meta' => array( 'class' => 'reseller-dropdown', 'target' => '_blank', 'title' => __( 'Support Center', 'boldgrid-library' ), ), ), array( 'id' => 'reseller-amp-login', 'parent' => 'reseller-adminbar-icon', 'title' => esc_html__( 'AMP Login', 'boldgrid-library' ), 'href' => $data['reseller_amp_url'], 'meta' => array( 'class' => 'reseller-dropdown', 'target' => '_blank', 'title' => __( 'Account Management', 'boldgrid-library' ), ), ), ), ); }
[ "protected", "function", "getMenuItems", "(", ")", "{", "$", "data", "=", "$", "this", "->", "getData", "(", ")", ";", "return", "array", "(", "'topLevel'", "=>", "array", "(", "'id'", "=>", "'reseller-adminbar-icon'", ",", "'title'", "=>", "'<span aria-hidd...
Get the menu items for this location. @since 2.4.0 @return array Menu Items.
[ "Get", "the", "menu", "items", "for", "this", "location", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Menu/Reseller.php#L108-L157
train
thelia/core
lib/Thelia/Controller/Admin/FeatureController.php
FeatureController.addRemoveFromAllTemplates
protected function addRemoveFromAllTemplates($eventType) { // Check current user authorization if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) { return $response; } try { if (null !== $object = $this->getExistingObject()) { $event = new FeatureEvent($object); $this->dispatch($eventType, $event); } } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } return $this->redirectToListTemplate(); }
php
protected function addRemoveFromAllTemplates($eventType) { // Check current user authorization if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) { return $response; } try { if (null !== $object = $this->getExistingObject()) { $event = new FeatureEvent($object); $this->dispatch($eventType, $event); } } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } return $this->redirectToListTemplate(); }
[ "protected", "function", "addRemoveFromAllTemplates", "(", "$", "eventType", ")", "{", "// Check current user authorization", "if", "(", "null", "!==", "$", "response", "=", "$", "this", "->", "checkAuth", "(", "$", "this", "->", "resourceCode", ",", "array", "(...
Add or Remove from all product templates
[ "Add", "or", "Remove", "from", "all", "product", "templates" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/FeatureController.php#L230-L249
train
MetaModels/attribute_tags
src/EventListener/TreePickerManipulatingListener.php
TreePickerManipulatingListener.manipulateTreePrickerForSortOrder
public function manipulateTreePrickerForSortOrder(ManipulateWidgetEvent $event) { $widget = $event->getWidget(); if (!($widget instanceof TreePicker)) { return; } $options = (array) $widget->options; if (0 === \count($options)) { return; } $model = $event->getModel(); if (!($model instanceof Model)) { return; } $attribute = $model->getItem()->getAttribute($widget->strField); if (!($attribute instanceof AbstractTags)) { return; } $widget->orderField = $widget->orderField . '__ordered'; $ordered = \array_flip(\array_merge([], (array) $model->getProperty($widget->strField))); foreach ($options as $option) { $ordered[$option['value']] = $option['value']; } $widget->{$widget->orderField} = $ordered; }
php
public function manipulateTreePrickerForSortOrder(ManipulateWidgetEvent $event) { $widget = $event->getWidget(); if (!($widget instanceof TreePicker)) { return; } $options = (array) $widget->options; if (0 === \count($options)) { return; } $model = $event->getModel(); if (!($model instanceof Model)) { return; } $attribute = $model->getItem()->getAttribute($widget->strField); if (!($attribute instanceof AbstractTags)) { return; } $widget->orderField = $widget->orderField . '__ordered'; $ordered = \array_flip(\array_merge([], (array) $model->getProperty($widget->strField))); foreach ($options as $option) { $ordered[$option['value']] = $option['value']; } $widget->{$widget->orderField} = $ordered; }
[ "public", "function", "manipulateTreePrickerForSortOrder", "(", "ManipulateWidgetEvent", "$", "event", ")", "{", "$", "widget", "=", "$", "event", "->", "getWidget", "(", ")", ";", "if", "(", "!", "(", "$", "widget", "instanceof", "TreePicker", ")", ")", "{"...
Manipulate the tree picker for sort order. @param ManipulateWidgetEvent $event The event. @return void
[ "Manipulate", "the", "tree", "picker", "for", "sort", "order", "." ]
d09c2cd18b299a48532caa0de8c70b7944282a8e
https://github.com/MetaModels/attribute_tags/blob/d09c2cd18b299a48532caa0de8c70b7944282a8e/src/EventListener/TreePickerManipulatingListener.php#L42-L72
train
nattreid/cms
src/Control/BasePresenter.php
BasePresenter.ajaxRedirect
public function ajaxRedirect(string $destination, array $args = []): void { $this->payload->forceRedirect = $this->link($destination, $args); $this->sendPayload(); }
php
public function ajaxRedirect(string $destination, array $args = []): void { $this->payload->forceRedirect = $this->link($destination, $args); $this->sendPayload(); }
[ "public", "function", "ajaxRedirect", "(", "string", "$", "destination", ",", "array", "$", "args", "=", "[", "]", ")", ":", "void", "{", "$", "this", "->", "payload", "->", "forceRedirect", "=", "$", "this", "->", "link", "(", "$", "destination", ",",...
Presmerovani ajaxoveho pozadavku @param string $destination @param array $args @throws AbortException @throws \Nette\Application\UI\InvalidLinkException
[ "Presmerovani", "ajaxoveho", "pozadavku" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/BasePresenter.php#L163-L167
train
thelia/core
lib/Thelia/Condition/ConditionFactory.php
ConditionFactory.serializeConditionCollection
public function serializeConditionCollection(ConditionCollection $collection) { if ($collection->count() == 0) { /** @var ConditionInterface $conditionNone */ $conditionNone = $this->container->get( 'thelia.condition.match_for_everyone' ); $collection[] = $conditionNone; } $serializableConditions = []; /** @var $condition ConditionInterface */ foreach ($collection as $condition) { $serializableConditions[] = $condition->getSerializableCondition(); } return base64_encode(json_encode($serializableConditions)); }
php
public function serializeConditionCollection(ConditionCollection $collection) { if ($collection->count() == 0) { /** @var ConditionInterface $conditionNone */ $conditionNone = $this->container->get( 'thelia.condition.match_for_everyone' ); $collection[] = $conditionNone; } $serializableConditions = []; /** @var $condition ConditionInterface */ foreach ($collection as $condition) { $serializableConditions[] = $condition->getSerializableCondition(); } return base64_encode(json_encode($serializableConditions)); }
[ "public", "function", "serializeConditionCollection", "(", "ConditionCollection", "$", "collection", ")", "{", "if", "(", "$", "collection", "->", "count", "(", ")", "==", "0", ")", "{", "/** @var ConditionInterface $conditionNone */", "$", "conditionNone", "=", "$"...
Serialize a collection of conditions @param ConditionCollection $collection A collection of conditions @return string A ready to be stored Condition collection
[ "Serialize", "a", "collection", "of", "conditions" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/ConditionFactory.php#L55-L71
train
thelia/core
lib/Thelia/Condition/ConditionFactory.php
ConditionFactory.unserializeConditionCollection
public function unserializeConditionCollection($serializedConditions) { $unserializedConditions = json_decode(base64_decode($serializedConditions)); $collection = new ConditionCollection(); if (!empty($unserializedConditions)) { /** @var SerializableCondition $condition */ foreach ($unserializedConditions as $condition) { if ($this->container->has($condition->conditionServiceId)) { /** @var ConditionInterface $conditionManager */ $conditionManager = $this->build( $condition->conditionServiceId, (array) $condition->operators, (array) $condition->values ); $collection[] = clone $conditionManager; } } } return $collection; }
php
public function unserializeConditionCollection($serializedConditions) { $unserializedConditions = json_decode(base64_decode($serializedConditions)); $collection = new ConditionCollection(); if (!empty($unserializedConditions)) { /** @var SerializableCondition $condition */ foreach ($unserializedConditions as $condition) { if ($this->container->has($condition->conditionServiceId)) { /** @var ConditionInterface $conditionManager */ $conditionManager = $this->build( $condition->conditionServiceId, (array) $condition->operators, (array) $condition->values ); $collection[] = clone $conditionManager; } } } return $collection; }
[ "public", "function", "unserializeConditionCollection", "(", "$", "serializedConditions", ")", "{", "$", "unserializedConditions", "=", "json_decode", "(", "base64_decode", "(", "$", "serializedConditions", ")", ")", ";", "$", "collection", "=", "new", "ConditionColle...
Unserialize a collection of conditions @param string $serializedConditions Serialized Conditions @return ConditionCollection Conditions ready to be processed
[ "Unserialize", "a", "collection", "of", "conditions" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/ConditionFactory.php#L80-L102
train
thelia/core
lib/Thelia/Condition/ConditionFactory.php
ConditionFactory.build
public function build($conditionServiceId, array $operators, array $values) { if (!$this->container->has($conditionServiceId)) { return false; } /** @var ConditionInterface $condition */ $condition = $this->container->get($conditionServiceId); $condition->setValidatorsFromForm($operators, $values); return clone $condition; }
php
public function build($conditionServiceId, array $operators, array $values) { if (!$this->container->has($conditionServiceId)) { return false; } /** @var ConditionInterface $condition */ $condition = $this->container->get($conditionServiceId); $condition->setValidatorsFromForm($operators, $values); return clone $condition; }
[ "public", "function", "build", "(", "$", "conditionServiceId", ",", "array", "$", "operators", ",", "array", "$", "values", ")", "{", "if", "(", "!", "$", "this", "->", "container", "->", "has", "(", "$", "conditionServiceId", ")", ")", "{", "return", ...
Build a Condition from form @param string $conditionServiceId Condition class name @param array $operators Condition Operator (<, >, = ) @param array $values Values setting this Condition @throws \InvalidArgumentException @return ConditionInterface Ready to use Condition or false
[ "Build", "a", "Condition", "from", "form" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/ConditionFactory.php#L114-L125
train
thelia/core
lib/Thelia/Condition/ConditionFactory.php
ConditionFactory.getInputsFromServiceId
public function getInputsFromServiceId($conditionServiceId) { if (!$this->container->has($conditionServiceId)) { return false; } /** @var ConditionInterface $condition */ $condition = $this->container->get($conditionServiceId); return $this->getInputsFromConditionInterface($condition); }
php
public function getInputsFromServiceId($conditionServiceId) { if (!$this->container->has($conditionServiceId)) { return false; } /** @var ConditionInterface $condition */ $condition = $this->container->get($conditionServiceId); return $this->getInputsFromConditionInterface($condition); }
[ "public", "function", "getInputsFromServiceId", "(", "$", "conditionServiceId", ")", "{", "if", "(", "!", "$", "this", "->", "container", "->", "has", "(", "$", "conditionServiceId", ")", ")", "{", "return", "false", ";", "}", "/** @var ConditionInterface $condi...
Get Condition inputs from serviceId @param string $conditionServiceId ConditionManager class name @return array Ready to be drawn condition inputs
[ "Get", "Condition", "inputs", "from", "serviceId" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/ConditionFactory.php#L134-L144
train
thelia/core
lib/Thelia/Model/ModuleConfigQuery.php
ModuleConfigQuery.getConfigValue
public function getConfigValue($moduleId, $variableName, $defaultValue = null, $valueLocale = null) { $value = null; $configValue = self::create() ->filterByModuleId($moduleId) ->filterByName($variableName) ->findOne(); ; if (null !== $configValue) { if (null !== $valueLocale) { $configValue->setLocale($valueLocale); } $value = $configValue->getValue(); } return $value === null ? $defaultValue : $value; }
php
public function getConfigValue($moduleId, $variableName, $defaultValue = null, $valueLocale = null) { $value = null; $configValue = self::create() ->filterByModuleId($moduleId) ->filterByName($variableName) ->findOne(); ; if (null !== $configValue) { if (null !== $valueLocale) { $configValue->setLocale($valueLocale); } $value = $configValue->getValue(); } return $value === null ? $defaultValue : $value; }
[ "public", "function", "getConfigValue", "(", "$", "moduleId", ",", "$", "variableName", ",", "$", "defaultValue", "=", "null", ",", "$", "valueLocale", "=", "null", ")", "{", "$", "value", "=", "null", ";", "$", "configValue", "=", "self", "::", "create"...
Get a module's configuration variable @param int $moduleId the module id @param string $variableName the variable name @param string $defaultValue the default value, if variable is not defined @param null $valueLocale the required locale, or null to get default one @return string the variable value
[ "Get", "a", "module", "s", "configuration", "variable" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/ModuleConfigQuery.php#L28-L47
train
thelia/core
lib/Thelia/Model/ModuleConfigQuery.php
ModuleConfigQuery.setConfigValue
public function setConfigValue($moduleId, $variableName, $variableValue, $valueLocale = null, $createIfNotExists = true) { $configValue = self::create() ->filterByModuleId($moduleId) ->filterByName($variableName) ->findOne(); ; if (null === $configValue) { if (true === $createIfNotExists) { $configValue = new ModuleConfig(); $configValue ->setModuleId($moduleId) ->setName($variableName) ; } else { throw new \LogicException("Module configuration variable $variableName does not exists. Create it first."); } } if (null !== $valueLocale) { $configValue->setLocale($valueLocale); } $configValue ->setValue($variableValue) ->save(); ; return $this; }
php
public function setConfigValue($moduleId, $variableName, $variableValue, $valueLocale = null, $createIfNotExists = true) { $configValue = self::create() ->filterByModuleId($moduleId) ->filterByName($variableName) ->findOne(); ; if (null === $configValue) { if (true === $createIfNotExists) { $configValue = new ModuleConfig(); $configValue ->setModuleId($moduleId) ->setName($variableName) ; } else { throw new \LogicException("Module configuration variable $variableName does not exists. Create it first."); } } if (null !== $valueLocale) { $configValue->setLocale($valueLocale); } $configValue ->setValue($variableValue) ->save(); ; return $this; }
[ "public", "function", "setConfigValue", "(", "$", "moduleId", ",", "$", "variableName", ",", "$", "variableValue", ",", "$", "valueLocale", "=", "null", ",", "$", "createIfNotExists", "=", "true", ")", "{", "$", "configValue", "=", "self", "::", "create", ...
Set module configuration variable, creating it if required @param int $moduleId the module id @param string $variableName the variable name @param string $variableValue the variable value @param null $valueLocale the locale, or null if not required @param bool $createIfNotExists if true, the variable will be created if not already defined @throws \LogicException if variable does not exists and $createIfNotExists is false @return $this;
[ "Set", "module", "configuration", "variable", "creating", "it", "if", "required" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/ModuleConfigQuery.php#L60-L91
train
thelia/core
lib/Thelia/Model/ModuleConfigQuery.php
ModuleConfigQuery.deleteConfigValue
public function deleteConfigValue($moduleId, $variableName) { if (null !== $moduleConfig = self::create() ->filterByModuleId($moduleId) ->filterByName($variableName) ->findOne() ) { $moduleConfig->delete(); }; return $this; }
php
public function deleteConfigValue($moduleId, $variableName) { if (null !== $moduleConfig = self::create() ->filterByModuleId($moduleId) ->filterByName($variableName) ->findOne() ) { $moduleConfig->delete(); }; return $this; }
[ "public", "function", "deleteConfigValue", "(", "$", "moduleId", ",", "$", "variableName", ")", "{", "if", "(", "null", "!==", "$", "moduleConfig", "=", "self", "::", "create", "(", ")", "->", "filterByModuleId", "(", "$", "moduleId", ")", "->", "filterByN...
Delete a module's configuration variable @param int $moduleId the module id @param string $variableName the variable name @return $this;
[ "Delete", "a", "module", "s", "configuration", "variable" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/ModuleConfigQuery.php#L100-L111
train
BoldGrid/library
src/Library/Update.php
Update.auto_update_plugin
public function auto_update_plugin( $update, $item ) { if ( ! apply_filters( 'Boldgrid\Library\Update\isEnalbed', false ) ) { return $update; } // Old settings. $pluginAutoupdate = \Boldgrid\Library\Util\Option::get( 'plugin_autoupdate' ); // Update if global setting is on, individual settings is on, or not set and default is on. if ( ! empty( $pluginAutoupdate ) || ! empty( $this->settings['plugins'][ $item->plugin ] ) || ( ! isset( $this->settings['plugins'][ $item->plugin ] ) && ! empty( $this->settings['plugins']['default'] ) ) ) { $update = true; } return $update; }
php
public function auto_update_plugin( $update, $item ) { if ( ! apply_filters( 'Boldgrid\Library\Update\isEnalbed', false ) ) { return $update; } // Old settings. $pluginAutoupdate = \Boldgrid\Library\Util\Option::get( 'plugin_autoupdate' ); // Update if global setting is on, individual settings is on, or not set and default is on. if ( ! empty( $pluginAutoupdate ) || ! empty( $this->settings['plugins'][ $item->plugin ] ) || ( ! isset( $this->settings['plugins'][ $item->plugin ] ) && ! empty( $this->settings['plugins']['default'] ) ) ) { $update = true; } return $update; }
[ "public", "function", "auto_update_plugin", "(", "$", "update", ",", "$", "item", ")", "{", "if", "(", "!", "apply_filters", "(", "'Boldgrid\\Library\\Update\\isEnalbed'", ",", "false", ")", ")", "{", "return", "$", "update", ";", "}", "// Old settings.", "$",...
Auto update plugin. @since 2.3.0 @hook: auto_update_plugin @param bool $update Update API response. @param object $item Item being updated. @return bool
[ "Auto", "update", "plugin", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Update.php#L154-L171
train
BoldGrid/library
src/Library/Update.php
Update.auto_update_theme
public function auto_update_theme( $update, $item ) { if ( ! apply_filters( 'Boldgrid\Library\Update\isEnalbed', false ) ) { return $update; } // Old settings. $themeAutoupdate = \Boldgrid\Library\Util\Option::get( 'theme_autoupdate' ); // Update if global setting is on, individual settings is on, or not set and default is on. if ( ! empty( $themeAutoupdate ) || ! empty( $this->settings['themes'][ $item->theme ] ) || ( ! isset( $this->settings['themes'][ $item->theme ] ) && ! empty( $this->settings['themes']['default'] ) ) ) { $update = true; } return $update; }
php
public function auto_update_theme( $update, $item ) { if ( ! apply_filters( 'Boldgrid\Library\Update\isEnalbed', false ) ) { return $update; } // Old settings. $themeAutoupdate = \Boldgrid\Library\Util\Option::get( 'theme_autoupdate' ); // Update if global setting is on, individual settings is on, or not set and default is on. if ( ! empty( $themeAutoupdate ) || ! empty( $this->settings['themes'][ $item->theme ] ) || ( ! isset( $this->settings['themes'][ $item->theme ] ) && ! empty( $this->settings['themes']['default'] ) ) ) { $update = true; } return $update; }
[ "public", "function", "auto_update_theme", "(", "$", "update", ",", "$", "item", ")", "{", "if", "(", "!", "apply_filters", "(", "'Boldgrid\\Library\\Update\\isEnalbed'", ",", "false", ")", ")", "{", "return", "$", "update", ";", "}", "// Old settings.", "$", ...
Auto update theme. @since 2.3.0 @hook: auto_update_theme @param bool $update Update API response. @param object $item Item being updated. @return bool
[ "Auto", "update", "theme", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Update.php#L184-L201
train
grom358/pharborist
src/RootNode.php
RootNode.create
public static function create($ns = NULL) { $node = new RootNode(); $node->addChild(Token::openTag()); if (is_string($ns) && $ns) { NamespaceNode::create($ns)->appendTo($node)->after(Token::newline()); } return $node; }
php
public static function create($ns = NULL) { $node = new RootNode(); $node->addChild(Token::openTag()); if (is_string($ns) && $ns) { NamespaceNode::create($ns)->appendTo($node)->after(Token::newline()); } return $node; }
[ "public", "static", "function", "create", "(", "$", "ns", "=", "NULL", ")", "{", "$", "node", "=", "new", "RootNode", "(", ")", ";", "$", "node", "->", "addChild", "(", "Token", "::", "openTag", "(", ")", ")", ";", "if", "(", "is_string", "(", "$...
Creates a new, blank PHP source file. @param string|NULL $ns If provided, the new document will have this namespace added to it. @return static
[ "Creates", "a", "new", "blank", "PHP", "source", "file", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/RootNode.php#L18-L25
train
grom358/pharborist
src/RootNode.php
RootNode.getNamespace
public function getNamespace($ns) { $namespaces = $this ->getNamespaces() ->filter(function(NamespaceNode $node) use ($ns) { return $node->getName()->getPath() === $ns; }); return $namespaces->isEmpty() ? NULL : $namespaces[0]; }
php
public function getNamespace($ns) { $namespaces = $this ->getNamespaces() ->filter(function(NamespaceNode $node) use ($ns) { return $node->getName()->getPath() === $ns; }); return $namespaces->isEmpty() ? NULL : $namespaces[0]; }
[ "public", "function", "getNamespace", "(", "$", "ns", ")", "{", "$", "namespaces", "=", "$", "this", "->", "getNamespaces", "(", ")", "->", "filter", "(", "function", "(", "NamespaceNode", "$", "node", ")", "use", "(", "$", "ns", ")", "{", "return", ...
Returns a particular namespace, if it exists. @param string $ns The name of the namespace to look for. @return \Pharborist\Namespaces\NamespaceNode|NULL
[ "Returns", "a", "particular", "namespace", "if", "it", "exists", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/RootNode.php#L56-L64
train
grom358/pharborist
src/RootNode.php
RootNode.getNamespaceNames
public function getNamespaceNames($absolute = FALSE) { $iterator = function(NamespaceNode $ns) use ($absolute) { $name = $ns->getName(); return $absolute ? $name->getAbsolutePath() : $name->getPath(); }; return array_map($iterator, $this->getNamespaces()->toArray()); }
php
public function getNamespaceNames($absolute = FALSE) { $iterator = function(NamespaceNode $ns) use ($absolute) { $name = $ns->getName(); return $absolute ? $name->getAbsolutePath() : $name->getPath(); }; return array_map($iterator, $this->getNamespaces()->toArray()); }
[ "public", "function", "getNamespaceNames", "(", "$", "absolute", "=", "FALSE", ")", "{", "$", "iterator", "=", "function", "(", "NamespaceNode", "$", "ns", ")", "use", "(", "$", "absolute", ")", "{", "$", "name", "=", "$", "ns", "->", "getName", "(", ...
Returns the name of every namespace in this document. @param boolean $absolute @return string[]
[ "Returns", "the", "name", "of", "every", "namespace", "in", "this", "document", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/RootNode.php#L73-L79
train
melisplatform/melis-cms
src/Service/MelisCmsSiteService.php
MelisCmsSiteService.getSitePages
public function getSitePages($siteId) { $results = array(); // Event parameters prepare $arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args()); // Sending service start event $arrayParameters = $this->sendEvent('meliscmssite_service_get_site_pages_start', $arrayParameters); // Service implementation start $siteTable = $this->getServiceLocator()->get('MelisEngineTableSite'); $site = $siteTable->getEntryById($arrayParameters['siteId'])->current(); if (!empty($site)) { $pages = $siteTable->getSiteSavedPagesById($site->site_id)->toArray(); if (!empty($pages)) { $site->pages = $pages; } $results = $site; } // Service implementation end // Adding results to parameters for events treatment if needed $arrayParameters['results'] = $results; // Sending service end event $arrayParameters = $this->sendEvent('meliscmssite_service_get_site_pages_start', $arrayParameters); return $arrayParameters['results']; }
php
public function getSitePages($siteId) { $results = array(); // Event parameters prepare $arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args()); // Sending service start event $arrayParameters = $this->sendEvent('meliscmssite_service_get_site_pages_start', $arrayParameters); // Service implementation start $siteTable = $this->getServiceLocator()->get('MelisEngineTableSite'); $site = $siteTable->getEntryById($arrayParameters['siteId'])->current(); if (!empty($site)) { $pages = $siteTable->getSiteSavedPagesById($site->site_id)->toArray(); if (!empty($pages)) { $site->pages = $pages; } $results = $site; } // Service implementation end // Adding results to parameters for events treatment if needed $arrayParameters['results'] = $results; // Sending service end event $arrayParameters = $this->sendEvent('meliscmssite_service_get_site_pages_start', $arrayParameters); return $arrayParameters['results']; }
[ "public", "function", "getSitePages", "(", "$", "siteId", ")", "{", "$", "results", "=", "array", "(", ")", ";", "// Event parameters prepare", "$", "arrayParameters", "=", "$", "this", "->", "makeArrayFromParameters", "(", "__METHOD__", ",", "func_get_args", "(...
This method will return the page of a site @param Int $siteId @return mixed
[ "This", "method", "will", "return", "the", "page", "of", "a", "site" ]
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Service/MelisCmsSiteService.php#L14-L51
train
melisplatform/melis-cms
src/Service/MelisCmsSiteService.php
MelisCmsSiteService.createSitePage
private function createSitePage($siteName, $fatherId, $siteLangId, $pageType, $pageId, $templateId, $platformId) { // Event parameters prepare $arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args()); // Sending service start event $arrayParameters = $this->sendEvent('meliscmssite_service_save_site_page_start', $arrayParameters); // Service implementation start $pageTreeTable = $this->getServiceLocator()->get('MelisEngineTablePageTree'); $pageLangTable = $this->getServiceLocator()->get('MelisEngineTablePageLang'); $pageSavedTable = $this->getServiceLocator()->get('MelisEngineTablePageSaved'); $cmsPlatformTable = $this->getServiceLocator()->get('MelisEngineTablePlatformIds'); /** * Retrieving the Current Page tree * with Father Id of -1 "root node of the page tree" * to get the Order of the new entry */ $treePageOrder = $pageTreeTable->getTotalData('tree_father_page_id', $fatherId); // Saving Site page on Page tree $pageTreeTable->save(array( 'tree_page_id' => $arrayParameters['pageId'], 'tree_father_page_id' => $fatherId, 'tree_page_order' => $treePageOrder + 1, )); // Saving Site page Language $pageLangTable->save(array( 'plang_page_id' => $arrayParameters['pageId'], 'plang_lang_id' => $arrayParameters['siteLangId'], 'plang_page_id_initial' => $arrayParameters['pageId'] )); // Saving Site page in Save Version as new page entry $pageSavedTable->save(array( 'page_id' => $arrayParameters['pageId'], 'page_type' => $arrayParameters['pageType'], 'page_status' => 1, 'page_menu' => 'LINK', 'page_name' => $arrayParameters['siteName'], 'page_tpl_id' => $arrayParameters['templateId'], 'page_content' => '<?xml version="1.0" encoding="UTF-8"?><document type="MelisCMS" author="MelisTechnology" version="2.0"></document>', 'page_taxonomy' => '', 'page_creation_date' => date('Y-m-d H:i:s') )); // Updating platform ids after site pages creation $platform = array( 'pids_page_id_current' => ++$arrayParameters['pageId'] ); $cmsPlatformTable->save($platform, $arrayParameters['platformId']); // Service implementation end // Adding results to parameters for events treatment if needed $arrayParameters['results'] = $arrayParameters['pageId']; // Sending service end event $arrayParameters = $this->sendEvent('meliscmssite_service_save_site_page_end', $arrayParameters); return $arrayParameters['results']; }
php
private function createSitePage($siteName, $fatherId, $siteLangId, $pageType, $pageId, $templateId, $platformId) { // Event parameters prepare $arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args()); // Sending service start event $arrayParameters = $this->sendEvent('meliscmssite_service_save_site_page_start', $arrayParameters); // Service implementation start $pageTreeTable = $this->getServiceLocator()->get('MelisEngineTablePageTree'); $pageLangTable = $this->getServiceLocator()->get('MelisEngineTablePageLang'); $pageSavedTable = $this->getServiceLocator()->get('MelisEngineTablePageSaved'); $cmsPlatformTable = $this->getServiceLocator()->get('MelisEngineTablePlatformIds'); /** * Retrieving the Current Page tree * with Father Id of -1 "root node of the page tree" * to get the Order of the new entry */ $treePageOrder = $pageTreeTable->getTotalData('tree_father_page_id', $fatherId); // Saving Site page on Page tree $pageTreeTable->save(array( 'tree_page_id' => $arrayParameters['pageId'], 'tree_father_page_id' => $fatherId, 'tree_page_order' => $treePageOrder + 1, )); // Saving Site page Language $pageLangTable->save(array( 'plang_page_id' => $arrayParameters['pageId'], 'plang_lang_id' => $arrayParameters['siteLangId'], 'plang_page_id_initial' => $arrayParameters['pageId'] )); // Saving Site page in Save Version as new page entry $pageSavedTable->save(array( 'page_id' => $arrayParameters['pageId'], 'page_type' => $arrayParameters['pageType'], 'page_status' => 1, 'page_menu' => 'LINK', 'page_name' => $arrayParameters['siteName'], 'page_tpl_id' => $arrayParameters['templateId'], 'page_content' => '<?xml version="1.0" encoding="UTF-8"?><document type="MelisCMS" author="MelisTechnology" version="2.0"></document>', 'page_taxonomy' => '', 'page_creation_date' => date('Y-m-d H:i:s') )); // Updating platform ids after site pages creation $platform = array( 'pids_page_id_current' => ++$arrayParameters['pageId'] ); $cmsPlatformTable->save($platform, $arrayParameters['platformId']); // Service implementation end // Adding results to parameters for events treatment if needed $arrayParameters['results'] = $arrayParameters['pageId']; // Sending service end event $arrayParameters = $this->sendEvent('meliscmssite_service_save_site_page_end', $arrayParameters); return $arrayParameters['results']; }
[ "private", "function", "createSitePage", "(", "$", "siteName", ",", "$", "fatherId", ",", "$", "siteLangId", ",", "$", "pageType", ",", "$", "pageId", ",", "$", "templateId", ",", "$", "platformId", ")", "{", "// Event parameters prepare", "$", "arrayParameter...
This method creating Site page @param String $siteName @param Int $fatherId @param Int $siteLangId @param String $pageType @param Int $pageId @param Int $templateId @param Int $platformId @return Int
[ "This", "method", "creating", "Site", "page" ]
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Service/MelisCmsSiteService.php#L244-L306
train
melisplatform/melis-cms
src/Service/MelisCmsSiteService.php
MelisCmsSiteService.createSitePageTemplate
private function createSitePageTemplate($tplId, $siteId, $siteName, $tempName, $controler, $action, $platformId) { $cmsTemplateTbl = $this->getServiceLocator()->get('MelisEngineTableTemplate'); $cmsPlatformTable = $this->getServiceLocator()->get('MelisEngineTablePlatformIds'); // Template data $template = array( 'tpl_id' => $tplId, 'tpl_site_id' => $siteId, 'tpl_name' => $tempName, 'tpl_type' => 'ZF2', 'tpl_zf2_website_folder' => $siteName, 'tpl_zf2_layout' => 'defaultLayout', 'tpl_zf2_controller' => $controler, 'tpl_zf2_action' => $action, 'tpl_php_path' => '', 'tpl_creation_date' => date('Y-m-d H:i:s'), ); // Saving template $templateId = $cmsTemplateTbl->save($template); // Updating platform ids after site pages creation $platform = array( 'pids_tpl_id_current' => ++$tplId ); $cmsPlatformTable->save($platform, $platformId); return $templateId; }
php
private function createSitePageTemplate($tplId, $siteId, $siteName, $tempName, $controler, $action, $platformId) { $cmsTemplateTbl = $this->getServiceLocator()->get('MelisEngineTableTemplate'); $cmsPlatformTable = $this->getServiceLocator()->get('MelisEngineTablePlatformIds'); // Template data $template = array( 'tpl_id' => $tplId, 'tpl_site_id' => $siteId, 'tpl_name' => $tempName, 'tpl_type' => 'ZF2', 'tpl_zf2_website_folder' => $siteName, 'tpl_zf2_layout' => 'defaultLayout', 'tpl_zf2_controller' => $controler, 'tpl_zf2_action' => $action, 'tpl_php_path' => '', 'tpl_creation_date' => date('Y-m-d H:i:s'), ); // Saving template $templateId = $cmsTemplateTbl->save($template); // Updating platform ids after site pages creation $platform = array( 'pids_tpl_id_current' => ++$tplId ); $cmsPlatformTable->save($platform, $platformId); return $templateId; }
[ "private", "function", "createSitePageTemplate", "(", "$", "tplId", ",", "$", "siteId", ",", "$", "siteName", ",", "$", "tempName", ",", "$", "controler", ",", "$", "action", ",", "$", "platformId", ")", "{", "$", "cmsTemplateTbl", "=", "$", "this", "->"...
This method creating Site page template @param Int $tplId @param Int $siteId @param String $siteName @param String $tempName @param String $controler @param String $action @param Int $platformId @return Int
[ "This", "method", "creating", "Site", "page", "template" ]
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Service/MelisCmsSiteService.php#L320-L349
train
melisplatform/melis-cms
src/Service/MelisCmsSiteService.php
MelisCmsSiteService.mapDirectory
private function mapDirectory($dir, $targetModuleName, $newModuleName) { $result = array(); $cdir = scandir($dir); $fileName = ''; foreach ($cdir as $key => $value) { if (!in_array($value,array(".",".."))) { if (is_dir($dir . '/' . $value)) { if ($value == $targetModuleName) { rename($dir . '/' . $value, $dir . '/' . $newModuleName); $value = $newModuleName; } elseif ($value == $this->moduleNameToViewName($targetModuleName)) { $newModuleNameSnakeCase = $this->moduleNameToViewName($newModuleName); rename($dir . '/' . $value, $dir . '/' . $newModuleNameSnakeCase); $value = $newModuleNameSnakeCase; } $result[$dir . '/' .$value] = $this->mapDirectory($dir . '/' . $value, $targetModuleName, $newModuleName); } else { $newFileName = str_replace($targetModuleName, $newModuleName, $value); if ($value != $newFileName) { rename($dir . '/' . $value, $dir . '/' . $newFileName); $value = $newFileName; } $result[$dir . '/' .$value] = $value; $fileName = $dir . '/' .$value; $this->replaceFileTextContent($fileName, $fileName, $targetModuleName, $newModuleName); } } } return $result; }
php
private function mapDirectory($dir, $targetModuleName, $newModuleName) { $result = array(); $cdir = scandir($dir); $fileName = ''; foreach ($cdir as $key => $value) { if (!in_array($value,array(".",".."))) { if (is_dir($dir . '/' . $value)) { if ($value == $targetModuleName) { rename($dir . '/' . $value, $dir . '/' . $newModuleName); $value = $newModuleName; } elseif ($value == $this->moduleNameToViewName($targetModuleName)) { $newModuleNameSnakeCase = $this->moduleNameToViewName($newModuleName); rename($dir . '/' . $value, $dir . '/' . $newModuleNameSnakeCase); $value = $newModuleNameSnakeCase; } $result[$dir . '/' .$value] = $this->mapDirectory($dir . '/' . $value, $targetModuleName, $newModuleName); } else { $newFileName = str_replace($targetModuleName, $newModuleName, $value); if ($value != $newFileName) { rename($dir . '/' . $value, $dir . '/' . $newFileName); $value = $newFileName; } $result[$dir . '/' .$value] = $value; $fileName = $dir . '/' .$value; $this->replaceFileTextContent($fileName, $fileName, $targetModuleName, $newModuleName); } } } return $result; }
[ "private", "function", "mapDirectory", "(", "$", "dir", ",", "$", "targetModuleName", ",", "$", "newModuleName", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "cdir", "=", "scandir", "(", "$", "dir", ")", ";", "$", "fileName", "=", "''",...
This method will map a directory to change some specific word that match the target and replace by new word @param String $dir @param String $targetModuleName @param String $newModuleName @return Array
[ "This", "method", "will", "map", "a", "directory", "to", "change", "some", "specific", "word", "that", "match", "the", "target", "and", "replace", "by", "new", "word" ]
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Service/MelisCmsSiteService.php#L469-L513
train
melisplatform/melis-cms
src/Service/MelisCmsSiteService.php
MelisCmsSiteService.generateModuleNameCase
private function generateModuleNameCase($str) { $i = array("-","_"); $str = preg_replace('/([a-z])([A-Z])/', "$1 $2", $str); $str = str_replace($i, ' ', $str); $str = str_replace(' ', '', ucwords(strtolower($str))); $str = strtolower(substr($str,0,1)).substr($str,1); $str = ucfirst($str); return $str; }
php
private function generateModuleNameCase($str) { $i = array("-","_"); $str = preg_replace('/([a-z])([A-Z])/', "$1 $2", $str); $str = str_replace($i, ' ', $str); $str = str_replace(' ', '', ucwords(strtolower($str))); $str = strtolower(substr($str,0,1)).substr($str,1); $str = ucfirst($str); return $str; }
[ "private", "function", "generateModuleNameCase", "(", "$", "str", ")", "{", "$", "i", "=", "array", "(", "\"-\"", ",", "\"_\"", ")", ";", "$", "str", "=", "preg_replace", "(", "'/([a-z])([A-Z])/'", ",", "\"$1 $2\"", ",", "$", "str", ")", ";", "$", "str...
This will modified a string to valid zf2 module name @param string $str @return string
[ "This", "will", "modified", "a", "string", "to", "valid", "zf2", "module", "name" ]
ed470338f4c7653fd93e530013ab934eb7a52b6f
https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Service/MelisCmsSiteService.php#L520-L528
train
grom358/pharborist
src/Functions/FunctionTrait.php
FunctionTrait.hasReturnTypes
public function hasReturnTypes() { $doc_comment = $this->getDocComment(); if (!$doc_comment) { return FALSE; } $return_tag = $doc_comment->getReturn(); if (!$return_tag) { return FALSE; } $types = $return_tag->getTypes(); return !empty($types); }
php
public function hasReturnTypes() { $doc_comment = $this->getDocComment(); if (!$doc_comment) { return FALSE; } $return_tag = $doc_comment->getReturn(); if (!$return_tag) { return FALSE; } $types = $return_tag->getTypes(); return !empty($types); }
[ "public", "function", "hasReturnTypes", "(", ")", "{", "$", "doc_comment", "=", "$", "this", "->", "getDocComment", "(", ")", ";", "if", "(", "!", "$", "doc_comment", ")", "{", "return", "FALSE", ";", "}", "$", "return_tag", "=", "$", "doc_comment", "-...
Return TRUE if function has phpDoc return type. @return bool
[ "Return", "TRUE", "if", "function", "has", "phpDoc", "return", "type", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Functions/FunctionTrait.php#L52-L63
train
grom358/pharborist
src/Functions/FunctionTrait.php
FunctionTrait.getReturnTypes
public function getReturnTypes() { $types = ['void']; $doc_comment = $this->getDocComment(); if (!$doc_comment) { return $types; } $return_tag = $doc_comment->getReturn(); if (!$return_tag) { return $types; } $types = Types::normalize($return_tag->getTypes()); if (empty($types)) { $types[] = 'void'; } return $types; }
php
public function getReturnTypes() { $types = ['void']; $doc_comment = $this->getDocComment(); if (!$doc_comment) { return $types; } $return_tag = $doc_comment->getReturn(); if (!$return_tag) { return $types; } $types = Types::normalize($return_tag->getTypes()); if (empty($types)) { $types[] = 'void'; } return $types; }
[ "public", "function", "getReturnTypes", "(", ")", "{", "$", "types", "=", "[", "'void'", "]", ";", "$", "doc_comment", "=", "$", "this", "->", "getDocComment", "(", ")", ";", "if", "(", "!", "$", "doc_comment", ")", "{", "return", "$", "types", ";", ...
Get the return type of the function as defined by the doc comment. @return string[] The types as defined by phpdoc standard. Default is ['void'].
[ "Get", "the", "return", "type", "of", "the", "function", "as", "defined", "by", "the", "doc", "comment", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Functions/FunctionTrait.php#L71-L86
train
mglaman/platform-docker
src/Application.php
Application.setDefaultTimezone
protected function setDefaultTimezone() { $timezone = 'UTC'; if (is_link('/etc/localtime')) { // Mac OS X (and older Linuxes) // /etc/localtime is a symlink to the timezone in /usr/share/zoneinfo. $filename = readlink('/etc/localtime'); if (strpos($filename, '/usr/share/zoneinfo/') === 0) { $timezone = substr($filename, 20); } } elseif (file_exists('/etc/timezone')) { // Ubuntu / Debian. $data = file_get_contents('/etc/timezone'); if ($data) { $timezone = trim($data); } } elseif (file_exists('/etc/sysconfig/clock')) { // RHEL/CentOS $data = parse_ini_file('/etc/sysconfig/clock'); if (!empty($data['ZONE'])) { $timezone = trim($data['ZONE']); } } date_default_timezone_set($timezone); }
php
protected function setDefaultTimezone() { $timezone = 'UTC'; if (is_link('/etc/localtime')) { // Mac OS X (and older Linuxes) // /etc/localtime is a symlink to the timezone in /usr/share/zoneinfo. $filename = readlink('/etc/localtime'); if (strpos($filename, '/usr/share/zoneinfo/') === 0) { $timezone = substr($filename, 20); } } elseif (file_exists('/etc/timezone')) { // Ubuntu / Debian. $data = file_get_contents('/etc/timezone'); if ($data) { $timezone = trim($data); } } elseif (file_exists('/etc/sysconfig/clock')) { // RHEL/CentOS $data = parse_ini_file('/etc/sysconfig/clock'); if (!empty($data['ZONE'])) { $timezone = trim($data['ZONE']); } } date_default_timezone_set($timezone); }
[ "protected", "function", "setDefaultTimezone", "(", ")", "{", "$", "timezone", "=", "'UTC'", ";", "if", "(", "is_link", "(", "'/etc/localtime'", ")", ")", "{", "// Mac OS X (and older Linuxes)", "// /etc/localtime is a symlink to the timezone in /usr/share/zoneinfo.", "$", ...
Set the default timezone. PHP 5.4 has removed the autodetection of the system timezone, so it needs to be done manually. UTC is the fallback in case autodetection fails.
[ "Set", "the", "default", "timezone", "." ]
217be131f70454a0f2c62a7ae0553c432731bfdf
https://github.com/mglaman/platform-docker/blob/217be131f70454a0f2c62a7ae0553c432731bfdf/src/Application.php#L84-L108
train
thelia/core
lib/Thelia/Model/Tools/UrlRewritingTrait.php
UrlRewritingTrait.getUrl
public function getUrl($locale = null) { if (null === $locale) { $locale = $this->getLocale(); } return URL::getInstance()->retrieve($this->getRewrittenUrlViewName(), $this->getId(), $locale)->toString(); }
php
public function getUrl($locale = null) { if (null === $locale) { $locale = $this->getLocale(); } return URL::getInstance()->retrieve($this->getRewrittenUrlViewName(), $this->getId(), $locale)->toString(); }
[ "public", "function", "getUrl", "(", "$", "locale", "=", "null", ")", "{", "if", "(", "null", "===", "$", "locale", ")", "{", "$", "locale", "=", "$", "this", "->", "getLocale", "(", ")", ";", "}", "return", "URL", "::", "getInstance", "(", ")", ...
Get the object URL for the given locale, rewritten if rewriting is enabled. @param string $locale a valid locale (e.g. en_US)
[ "Get", "the", "object", "URL", "for", "the", "given", "locale", "rewritten", "if", "rewriting", "is", "enabled", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Tools/UrlRewritingTrait.php#L41-L48
train
thelia/core
lib/Thelia/Model/Tools/UrlRewritingTrait.php
UrlRewritingTrait.generateRewrittenUrl
public function generateRewrittenUrl($locale) { if ($this->isNew()) { throw new \RuntimeException(sprintf('Object %s must be saved before generating url', $this->getRewrittenUrlViewName())); } // Borrowed from http://stackoverflow.com/questions/2668854/sanitizing-strings-to-make-them-url-and-filename-safe $this->setLocale($locale); $generateEvent = new GenerateRewrittenUrlEvent($this, $locale); $this->dispatchEvent(TheliaEvents::GENERATE_REWRITTENURL, $generateEvent); if ($generateEvent->isRewritten()) { return $generateEvent->getUrl(); } $title = $this->getTitle(); if (null == $title) { throw new \RuntimeException('Impossible to create an url if title is null'); } // Replace all weird characters with dashes $string = preg_replace('/[^\w\-~_\.]+/u', '-', $title); // Only allow one dash separator at a time (and make string lowercase) $cleanString = mb_strtolower(preg_replace('/--+/u', '-', $string), 'UTF-8'); $urlFilePart = rtrim($cleanString, '.-~_') . ".html"; try { $i=0; while (URL::getInstance()->resolve($urlFilePart)) { $i++; $urlFilePart = sprintf("%s-%d.html", $cleanString, $i); } } catch (UrlRewritingException $e) { $rewritingUrl = new RewritingUrl(); $rewritingUrl->setUrl($urlFilePart) ->setView($this->getRewrittenUrlViewName()) ->setViewId($this->getId()) ->setViewLocale($locale) ->save() ; } return $urlFilePart; }
php
public function generateRewrittenUrl($locale) { if ($this->isNew()) { throw new \RuntimeException(sprintf('Object %s must be saved before generating url', $this->getRewrittenUrlViewName())); } // Borrowed from http://stackoverflow.com/questions/2668854/sanitizing-strings-to-make-them-url-and-filename-safe $this->setLocale($locale); $generateEvent = new GenerateRewrittenUrlEvent($this, $locale); $this->dispatchEvent(TheliaEvents::GENERATE_REWRITTENURL, $generateEvent); if ($generateEvent->isRewritten()) { return $generateEvent->getUrl(); } $title = $this->getTitle(); if (null == $title) { throw new \RuntimeException('Impossible to create an url if title is null'); } // Replace all weird characters with dashes $string = preg_replace('/[^\w\-~_\.]+/u', '-', $title); // Only allow one dash separator at a time (and make string lowercase) $cleanString = mb_strtolower(preg_replace('/--+/u', '-', $string), 'UTF-8'); $urlFilePart = rtrim($cleanString, '.-~_') . ".html"; try { $i=0; while (URL::getInstance()->resolve($urlFilePart)) { $i++; $urlFilePart = sprintf("%s-%d.html", $cleanString, $i); } } catch (UrlRewritingException $e) { $rewritingUrl = new RewritingUrl(); $rewritingUrl->setUrl($urlFilePart) ->setView($this->getRewrittenUrlViewName()) ->setViewId($this->getId()) ->setViewLocale($locale) ->save() ; } return $urlFilePart; }
[ "public", "function", "generateRewrittenUrl", "(", "$", "locale", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Object %s must be saved before generating url'", ",", "$", "...
Generate a rewritten URL from the object title, and store it in the rewriting table @param string $locale a valid locale (e.g. en_US)
[ "Generate", "a", "rewritten", "URL", "from", "the", "object", "title", "and", "store", "it", "in", "the", "rewriting", "table" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Tools/UrlRewritingTrait.php#L55-L102
train
thelia/core
lib/Thelia/Model/Tools/UrlRewritingTrait.php
UrlRewritingTrait.getRewrittenUrl
public function getRewrittenUrl($locale) { $rewritingUrl = RewritingUrlQuery::create() ->filterByViewLocale($locale) ->filterByView($this->getRewrittenUrlViewName()) ->filterByViewId($this->getId()) ->filterByRedirected(null) ->findOne() ; if ($rewritingUrl) { $url = $rewritingUrl->getUrl(); } else { $url = null; } return $url; }
php
public function getRewrittenUrl($locale) { $rewritingUrl = RewritingUrlQuery::create() ->filterByViewLocale($locale) ->filterByView($this->getRewrittenUrlViewName()) ->filterByViewId($this->getId()) ->filterByRedirected(null) ->findOne() ; if ($rewritingUrl) { $url = $rewritingUrl->getUrl(); } else { $url = null; } return $url; }
[ "public", "function", "getRewrittenUrl", "(", "$", "locale", ")", "{", "$", "rewritingUrl", "=", "RewritingUrlQuery", "::", "create", "(", ")", "->", "filterByViewLocale", "(", "$", "locale", ")", "->", "filterByView", "(", "$", "this", "->", "getRewrittenUrlV...
return the rewritten URL for the given locale @param string $locale a valid locale (e.g. en_US) @return null
[ "return", "the", "rewritten", "URL", "for", "the", "given", "locale" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Tools/UrlRewritingTrait.php#L110-L127
train
thelia/core
lib/Thelia/Model/Tools/UrlRewritingTrait.php
UrlRewritingTrait.markRewrittenUrlObsolete
public function markRewrittenUrlObsolete() { RewritingUrlQuery::create() ->filterByView($this->getRewrittenUrlViewName()) ->filterByViewId($this->getId()) ->update(array( "View" => ConfigQuery::getObsoleteRewrittenUrlView() )); }
php
public function markRewrittenUrlObsolete() { RewritingUrlQuery::create() ->filterByView($this->getRewrittenUrlViewName()) ->filterByViewId($this->getId()) ->update(array( "View" => ConfigQuery::getObsoleteRewrittenUrlView() )); }
[ "public", "function", "markRewrittenUrlObsolete", "(", ")", "{", "RewritingUrlQuery", "::", "create", "(", ")", "->", "filterByView", "(", "$", "this", "->", "getRewrittenUrlViewName", "(", ")", ")", "->", "filterByViewId", "(", "$", "this", "->", "getId", "("...
Mark the current URL as obseolete
[ "Mark", "the", "current", "URL", "as", "obseolete" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Tools/UrlRewritingTrait.php#L132-L140
train
thelia/core
lib/Thelia/Model/Tools/UrlRewritingTrait.php
UrlRewritingTrait.setRewrittenUrl
public function setRewrittenUrl($locale, $url) { $currentUrl = $this->getRewrittenUrl($locale); if ($currentUrl == $url || null === $url) { /* no url update */ return $this; } try { $resolver = new RewritingResolver($url); /* we can reassign old url */ if (null === $resolver->redirectedToUrl) { /* else ... */ if ($resolver->view == $this->getRewrittenUrlViewName() && $resolver->viewId == $this->getId()) { /* it's an url related to the current object */ if ($resolver->locale != $locale) { /* it is an url related to this product for another locale */ throw new UrlRewritingException(Translator::getInstance()->trans('URL_ALREADY_EXISTS'), UrlRewritingException::URL_ALREADY_EXISTS); } if (\count($resolver->otherParameters) > 0) { /* it is an url related to this product but with more arguments */ throw new UrlRewritingException(Translator::getInstance()->trans('URL_ALREADY_EXISTS'), UrlRewritingException::URL_ALREADY_EXISTS); } /* here it must be a deprecated url */ } else { /* already related to another object */ throw new UrlRewritingException(Translator::getInstance()->trans('URL_ALREADY_EXISTS'), UrlRewritingException::URL_ALREADY_EXISTS); } } } catch (UrlRewritingException $e) { /* It's all good if URL is not found */ if ($e->getCode() !== UrlRewritingException::URL_NOT_FOUND) { throw $e; } } /* set the new URL */ if (isset($resolver)) { /* erase the old one */ $rewritingUrl = RewritingUrlQuery::create()->findOneByUrl($url); $rewritingUrl->setView($this->getRewrittenUrlViewName()) ->setViewId($this->getId()) ->setViewLocale($locale) ->setRedirected(null) ->save() ; /* erase additional arguments if any : only happens in case it erases a deprecated url */ RewritingArgumentQuery::create()->filterByRewritingUrl($rewritingUrl)->deleteAll(); } else { /* just create it */ $rewritingUrl = new RewritingUrl(); $rewritingUrl->setUrl($url) ->setView($this->getRewrittenUrlViewName()) ->setViewId($this->getId()) ->setViewLocale($locale) ->save() ; } /* deprecate the old one if needed */ if (null !== $oldRewritingUrl = RewritingUrlQuery::create()->findOneByUrl($currentUrl)) { $oldRewritingUrl->setRedirected($rewritingUrl->getId())->save(); } return $this; }
php
public function setRewrittenUrl($locale, $url) { $currentUrl = $this->getRewrittenUrl($locale); if ($currentUrl == $url || null === $url) { /* no url update */ return $this; } try { $resolver = new RewritingResolver($url); /* we can reassign old url */ if (null === $resolver->redirectedToUrl) { /* else ... */ if ($resolver->view == $this->getRewrittenUrlViewName() && $resolver->viewId == $this->getId()) { /* it's an url related to the current object */ if ($resolver->locale != $locale) { /* it is an url related to this product for another locale */ throw new UrlRewritingException(Translator::getInstance()->trans('URL_ALREADY_EXISTS'), UrlRewritingException::URL_ALREADY_EXISTS); } if (\count($resolver->otherParameters) > 0) { /* it is an url related to this product but with more arguments */ throw new UrlRewritingException(Translator::getInstance()->trans('URL_ALREADY_EXISTS'), UrlRewritingException::URL_ALREADY_EXISTS); } /* here it must be a deprecated url */ } else { /* already related to another object */ throw new UrlRewritingException(Translator::getInstance()->trans('URL_ALREADY_EXISTS'), UrlRewritingException::URL_ALREADY_EXISTS); } } } catch (UrlRewritingException $e) { /* It's all good if URL is not found */ if ($e->getCode() !== UrlRewritingException::URL_NOT_FOUND) { throw $e; } } /* set the new URL */ if (isset($resolver)) { /* erase the old one */ $rewritingUrl = RewritingUrlQuery::create()->findOneByUrl($url); $rewritingUrl->setView($this->getRewrittenUrlViewName()) ->setViewId($this->getId()) ->setViewLocale($locale) ->setRedirected(null) ->save() ; /* erase additional arguments if any : only happens in case it erases a deprecated url */ RewritingArgumentQuery::create()->filterByRewritingUrl($rewritingUrl)->deleteAll(); } else { /* just create it */ $rewritingUrl = new RewritingUrl(); $rewritingUrl->setUrl($url) ->setView($this->getRewrittenUrlViewName()) ->setViewId($this->getId()) ->setViewLocale($locale) ->save() ; } /* deprecate the old one if needed */ if (null !== $oldRewritingUrl = RewritingUrlQuery::create()->findOneByUrl($currentUrl)) { $oldRewritingUrl->setRedirected($rewritingUrl->getId())->save(); } return $this; }
[ "public", "function", "setRewrittenUrl", "(", "$", "locale", ",", "$", "url", ")", "{", "$", "currentUrl", "=", "$", "this", "->", "getRewrittenUrl", "(", "$", "locale", ")", ";", "if", "(", "$", "currentUrl", "==", "$", "url", "||", "null", "===", "...
Set the rewritten URL for the given locale @param string $locale a valid locale (e.g. en_US) @param $url @return $this @throws UrlRewritingException @throws \Thelia\Exception\UrlRewritingException
[ "Set", "the", "rewritten", "URL", "for", "the", "given", "locale" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Tools/UrlRewritingTrait.php#L151-L222
train
grom358/pharborist
src/Objects/ClassMemberNode.php
ClassMemberNode.create
public static function create($name, ExpressionNode $value = NULL, $visibility = 'public') { $code = $visibility . ' $' . ltrim($name, '$'); if ($value instanceof ExpressionNode) { $code .= ' = ' . $value->getText(); } /** @var ClassNode $class_node */ $class_node = Parser::parseSnippet('class Foo { ' . $code . '; }'); return $class_node->getStatements()[0]->remove(); }
php
public static function create($name, ExpressionNode $value = NULL, $visibility = 'public') { $code = $visibility . ' $' . ltrim($name, '$'); if ($value instanceof ExpressionNode) { $code .= ' = ' . $value->getText(); } /** @var ClassNode $class_node */ $class_node = Parser::parseSnippet('class Foo { ' . $code . '; }'); return $class_node->getStatements()[0]->remove(); }
[ "public", "static", "function", "create", "(", "$", "name", ",", "ExpressionNode", "$", "value", "=", "NULL", ",", "$", "visibility", "=", "'public'", ")", "{", "$", "code", "=", "$", "visibility", ".", "' $'", ".", "ltrim", "(", "$", "name", ",", "'...
Creates a new class member. @param string $name The name of the member, with or without the leading $. @param \Pharborist\ExpressionNode $value The default value of the member, if any. @param string $visibility The member's visibility. Can be public, private, or protected. Defaults to public. @return ClassMemberListNode @todo Not all expressions can be default values, but I forget what sorts of expressions are valid for this. Will need better sanity checking here.
[ "Creates", "a", "new", "class", "member", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Objects/ClassMemberNode.php#L58-L66
train
BoldGrid/library
src/Library/Menu/Render.php
Render.adminBarNode
public static function adminBarNode( $wpAdminBar, $configs ) { $wpAdminBar->add_node( $configs['topLevel'] ); foreach ( $configs['items'] as $item ) { $wpAdminBar->add_menu( $item ); } }
php
public static function adminBarNode( $wpAdminBar, $configs ) { $wpAdminBar->add_node( $configs['topLevel'] ); foreach ( $configs['items'] as $item ) { $wpAdminBar->add_menu( $item ); } }
[ "public", "static", "function", "adminBarNode", "(", "$", "wpAdminBar", ",", "$", "configs", ")", "{", "$", "wpAdminBar", "->", "add_node", "(", "$", "configs", "[", "'topLevel'", "]", ")", ";", "foreach", "(", "$", "configs", "[", "'items'", "]", "as", ...
Given a configuration of menu items to be added on @since 2.4.0 @param WP_Admin_Bar $wpAdminBar Admin Bar. @param array $configs Configurations for the menu.
[ "Given", "a", "configuration", "of", "menu", "items", "to", "be", "added", "on" ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Menu/Render.php#L29-L34
train
thelia/core
lib/Thelia/Model/MetaDataQuery.php
MetaDataQuery.setVal
public static function setVal($metaKey, $elementKey, $elementId, $value) { $data = self::create() ->filterByMetaKey($metaKey) ->filterByElementKey($elementKey) ->filterByElementId($elementId) ->findOne() ; if (null === $data) { $data = new MetaData(); $data->setMetaKey($metaKey); $data->setElementKey($elementKey); $data->setElementId($elementId); } $data->setValue($value); $data->save(); }
php
public static function setVal($metaKey, $elementKey, $elementId, $value) { $data = self::create() ->filterByMetaKey($metaKey) ->filterByElementKey($elementKey) ->filterByElementId($elementId) ->findOne() ; if (null === $data) { $data = new MetaData(); $data->setMetaKey($metaKey); $data->setElementKey($elementKey); $data->setElementId($elementId); } $data->setValue($value); $data->save(); }
[ "public", "static", "function", "setVal", "(", "$", "metaKey", ",", "$", "elementKey", ",", "$", "elementId", ",", "$", "value", ")", "{", "$", "data", "=", "self", "::", "create", "(", ")", "->", "filterByMetaKey", "(", "$", "metaKey", ")", "->", "f...
Add or update the MetaData element @param string $metaKey the meta Key @param string $elementKey the element Key : product, category, ... @param int $elementId the element id
[ "Add", "or", "update", "the", "MetaData", "element" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/MetaDataQuery.php#L81-L100
train
grom358/pharborist
src/Namespaces/IdentifierNameTrait.php
IdentifierNameTrait.setName
public function setName($name) { /** @var TokenNode $identifier */ $identifier = $this->name->firstChild(); $identifier->setText($name); return $this; }
php
public function setName($name) { /** @var TokenNode $identifier */ $identifier = $this->name->firstChild(); $identifier->setText($name); return $this; }
[ "public", "function", "setName", "(", "$", "name", ")", "{", "/** @var TokenNode $identifier */", "$", "identifier", "=", "$", "this", "->", "name", "->", "firstChild", "(", ")", ";", "$", "identifier", "->", "setText", "(", "$", "name", ")", ";", "return"...
Set the identifier name of this node. @param string $name New name. @return $this
[ "Set", "the", "identifier", "name", "of", "this", "node", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Namespaces/IdentifierNameTrait.php#L38-L43
train
grom358/pharborist
src/Namespaces/IdentifierNameTrait.php
IdentifierNameTrait.inNamespace
public function inNamespace($ns) { if (is_string($ns)) { $namespace_node = $this->name->getNamespace(); $namespace = $namespace_node === NULL ? '' : $namespace_node->getName()->getAbsolutePath(); return $ns === $namespace; } elseif ($ns instanceof NamespaceNode) { return $this->name->getNamespace() === $ns; } else { throw new \InvalidArgumentException(); } }
php
public function inNamespace($ns) { if (is_string($ns)) { $namespace_node = $this->name->getNamespace(); $namespace = $namespace_node === NULL ? '' : $namespace_node->getName()->getAbsolutePath(); return $ns === $namespace; } elseif ($ns instanceof NamespaceNode) { return $this->name->getNamespace() === $ns; } else { throw new \InvalidArgumentException(); } }
[ "public", "function", "inNamespace", "(", "$", "ns", ")", "{", "if", "(", "is_string", "(", "$", "ns", ")", ")", "{", "$", "namespace_node", "=", "$", "this", "->", "name", "->", "getNamespace", "(", ")", ";", "$", "namespace", "=", "$", "namespace_n...
Determine if this node belongs to namespace. @param string|NamespaceNode $ns Either the absolute namespace path or a NamespaceNode. @return boolean TRUE if the node belongs to the given namespace.
[ "Determine", "if", "this", "node", "belongs", "to", "namespace", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Namespaces/IdentifierNameTrait.php#L54-L66
train
nattreid/cms
src/Control/presenters/InfoPresenter.php
InfoPresenter.renderServer
public function renderServer(): void { $this->addBreadcrumbLink('dockbar.info.server'); $this->template->refresh = $this->refresh; $this->template->system = $this->app->info->system; $this->template->fileSystem = $this->app->info->fileSystem; $this->template->hardware = $this->app->info->hardware; $this->template->memory = $this->app->info->memory; $this->template->network = $this->app->info->network; }
php
public function renderServer(): void { $this->addBreadcrumbLink('dockbar.info.server'); $this->template->refresh = $this->refresh; $this->template->system = $this->app->info->system; $this->template->fileSystem = $this->app->info->fileSystem; $this->template->hardware = $this->app->info->hardware; $this->template->memory = $this->app->info->memory; $this->template->network = $this->app->info->network; }
[ "public", "function", "renderServer", "(", ")", ":", "void", "{", "$", "this", "->", "addBreadcrumbLink", "(", "'dockbar.info.server'", ")", ";", "$", "this", "->", "template", "->", "refresh", "=", "$", "this", "->", "refresh", ";", "$", "this", "->", "...
Zobrazeni informaci o serveru
[ "Zobrazeni", "informaci", "o", "serveru" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/InfoPresenter.php#L59-L68
train
nattreid/cms
src/Control/presenters/InfoPresenter.php
InfoPresenter.renderPhp
public function renderPhp(): void { $this->addBreadcrumbLink('dockbar.info.php'); $this->template->php = $this->app->info->phpInfo; }
php
public function renderPhp(): void { $this->addBreadcrumbLink('dockbar.info.php'); $this->template->php = $this->app->info->phpInfo; }
[ "public", "function", "renderPhp", "(", ")", ":", "void", "{", "$", "this", "->", "addBreadcrumbLink", "(", "'dockbar.info.php'", ")", ";", "$", "this", "->", "template", "->", "php", "=", "$", "this", "->", "app", "->", "info", "->", "phpInfo", ";", "...
Zobrazeni informaci o PHP
[ "Zobrazeni", "informaci", "o", "PHP" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/InfoPresenter.php#L73-L77
train
nattreid/cms
src/Control/presenters/UsersPresenter.php
UsersPresenter.setState
public function setState(int $id, bool $value): void { if ($this->isAjax()) { $user = $this->orm->users->getById($id); $user->active = $value; $this->orm->persistAndFlush($user); $this['userList']->redrawItem($id); } else { $this->terminate(); } }
php
public function setState(int $id, bool $value): void { if ($this->isAjax()) { $user = $this->orm->users->getById($id); $user->active = $value; $this->orm->persistAndFlush($user); $this['userList']->redrawItem($id); } else { $this->terminate(); } }
[ "public", "function", "setState", "(", "int", "$", "id", ",", "bool", "$", "value", ")", ":", "void", "{", "if", "(", "$", "this", "->", "isAjax", "(", ")", ")", "{", "$", "user", "=", "$", "this", "->", "orm", "->", "users", "->", "getById", "...
Ulozi stav uzivatele @param int $id @param bool $value @throws AbortException
[ "Ulozi", "stav", "uzivatele" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/UsersPresenter.php#L162-L172
train
nattreid/cms
src/Control/presenters/UsersPresenter.php
UsersPresenter.createComponentAddForm
protected function createComponentAddForm(): Form { $form = $this->formFactory->create(); $form->addProtection(); $form->addText('username', 'cms.user.username') ->setRequired(); $form->addText('firstName', 'cms.user.firstName'); $form->addText('surname', 'cms.user.surname'); $form->addText('email', 'cms.user.email') ->setRequired() ->addRule(Form::EMAIL); $form->addPhone('phone', 'cms.user.phone'); $form->addSelectUntranslated('language', 'cms.user.language', $this->localeService->allowed, 'form.none'); $form->addMultiSelectUntranslated('roles', 'cms.permissions.roles', $this->orm->aclRoles->fetchPairs($this->user->isAllowed('dockbar.settings.permissions.superadmin', 'view'))) ->setRequired(); if ($this->configurator->sendNewUserPassword) { $form->addCheckbox('generatePassword', 'cms.user.generatePassword') ->addCondition($form::EQUAL, false) ->toggle('password') ->toggle('passwordVerify'); } else { $form->addHidden('generatePassword', false); } $form->addPassword('password', 'cms.user.newPassword') ->setOption('id', 'password') ->addConditionOn($form['generatePassword'], Form::EQUAL, false) ->setRequired() ->addRule(Form::MIN_LENGTH, null, $this->minPasswordLength) ->endCondition(); $form->addPassword('passwordVerify', 'cms.user.passwordVerify') ->setOption('id', 'passwordVerify') ->addConditionOn($form['generatePassword'], Form::EQUAL, false) ->setRequired() ->addRule(Form::EQUAL, null, $form['password']) ->endCondition(); $form->addSubmit('save', 'form.save'); $form->addLink('back', 'form.back', $this->getBacklink()); $form->onSuccess[] = [$this, 'addFormSucceeded']; return $form; }
php
protected function createComponentAddForm(): Form { $form = $this->formFactory->create(); $form->addProtection(); $form->addText('username', 'cms.user.username') ->setRequired(); $form->addText('firstName', 'cms.user.firstName'); $form->addText('surname', 'cms.user.surname'); $form->addText('email', 'cms.user.email') ->setRequired() ->addRule(Form::EMAIL); $form->addPhone('phone', 'cms.user.phone'); $form->addSelectUntranslated('language', 'cms.user.language', $this->localeService->allowed, 'form.none'); $form->addMultiSelectUntranslated('roles', 'cms.permissions.roles', $this->orm->aclRoles->fetchPairs($this->user->isAllowed('dockbar.settings.permissions.superadmin', 'view'))) ->setRequired(); if ($this->configurator->sendNewUserPassword) { $form->addCheckbox('generatePassword', 'cms.user.generatePassword') ->addCondition($form::EQUAL, false) ->toggle('password') ->toggle('passwordVerify'); } else { $form->addHidden('generatePassword', false); } $form->addPassword('password', 'cms.user.newPassword') ->setOption('id', 'password') ->addConditionOn($form['generatePassword'], Form::EQUAL, false) ->setRequired() ->addRule(Form::MIN_LENGTH, null, $this->minPasswordLength) ->endCondition(); $form->addPassword('passwordVerify', 'cms.user.passwordVerify') ->setOption('id', 'passwordVerify') ->addConditionOn($form['generatePassword'], Form::EQUAL, false) ->setRequired() ->addRule(Form::EQUAL, null, $form['password']) ->endCondition(); $form->addSubmit('save', 'form.save'); $form->addLink('back', 'form.back', $this->getBacklink()); $form->onSuccess[] = [$this, 'addFormSucceeded']; return $form; }
[ "protected", "function", "createComponentAddForm", "(", ")", ":", "Form", "{", "$", "form", "=", "$", "this", "->", "formFactory", "->", "create", "(", ")", ";", "$", "form", "->", "addProtection", "(", ")", ";", "$", "form", "->", "addText", "(", "'us...
Formular pridani uzivatele @return Form
[ "Formular", "pridani", "uzivatele" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/UsersPresenter.php#L237-L282
train
nattreid/cms
src/Control/presenters/UsersPresenter.php
UsersPresenter.addFormSucceeded
public function addFormSucceeded(Form $form, ArrayHash $values): void { if ($values->generatePassword) { $password = Random::generate($this->minPasswordLength, $this->passwordChars); } else { $password = $values->password; } $user = new User; $this->orm->users->attach($user); try { $user->setUsername($values->username); } catch (UniqueConstraintViolationException $ex) { $form->addError('cms.user.duplicityUsername'); return; } catch (InvalidArgumentException $ex) { $form->addError('cms.user.invalidUsername'); return; } try { $user->setEmail($values->email); } catch (UniqueConstraintViolationException $ex) { $form->addError('cms.user.duplicityEmail'); return; } catch (InvalidArgumentException $ex) { $form->addError('cms.user.invalidUsername'); return; } try { $user->setPhone($values->phone ?: null); } catch (InvalidArgumentException $ex) { $form->addError('cms.user.invalidPhone'); return; } $user->firstName = $values->firstName; $user->surname = $values->surname; $language = $this->localeService->getById($values->language); $user->language = $language === null ? null : $language->name; $user->roles->set($values->roles); $user->setPassword($password); $this->orm->persistAndFlush($user); if ($this->configurator->sendNewUserPassword) { $this->mailer->sendNewUser($user->email, $user->username, $password); } $this->flashNotifier->success('cms.user.dataSaved'); $this->restoreBacklink(); }
php
public function addFormSucceeded(Form $form, ArrayHash $values): void { if ($values->generatePassword) { $password = Random::generate($this->minPasswordLength, $this->passwordChars); } else { $password = $values->password; } $user = new User; $this->orm->users->attach($user); try { $user->setUsername($values->username); } catch (UniqueConstraintViolationException $ex) { $form->addError('cms.user.duplicityUsername'); return; } catch (InvalidArgumentException $ex) { $form->addError('cms.user.invalidUsername'); return; } try { $user->setEmail($values->email); } catch (UniqueConstraintViolationException $ex) { $form->addError('cms.user.duplicityEmail'); return; } catch (InvalidArgumentException $ex) { $form->addError('cms.user.invalidUsername'); return; } try { $user->setPhone($values->phone ?: null); } catch (InvalidArgumentException $ex) { $form->addError('cms.user.invalidPhone'); return; } $user->firstName = $values->firstName; $user->surname = $values->surname; $language = $this->localeService->getById($values->language); $user->language = $language === null ? null : $language->name; $user->roles->set($values->roles); $user->setPassword($password); $this->orm->persistAndFlush($user); if ($this->configurator->sendNewUserPassword) { $this->mailer->sendNewUser($user->email, $user->username, $password); } $this->flashNotifier->success('cms.user.dataSaved'); $this->restoreBacklink(); }
[ "public", "function", "addFormSucceeded", "(", "Form", "$", "form", ",", "ArrayHash", "$", "values", ")", ":", "void", "{", "if", "(", "$", "values", "->", "generatePassword", ")", "{", "$", "password", "=", "Random", "::", "generate", "(", "$", "this", ...
Zpracovani noveho uzivatele @param Form $form @param ArrayHash $values @throws AuthenticationException @throws InvalidLinkException
[ "Zpracovani", "noveho", "uzivatele" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/UsersPresenter.php#L291-L345
train
nattreid/cms
src/Control/presenters/UsersPresenter.php
UsersPresenter.createComponentEditForm
protected function createComponentEditForm(): Form { $form = $this->formFactory->create(); $form->addProtection(); $form->addText('username', 'cms.user.username') ->setDefaultValue($this->currentUser->username) ->setRequired(); $form->addText('firstName', 'cms.user.firstName') ->setDefaultValue($this->currentUser->firstName); $form->addText('surname', 'cms.user.surname') ->setDefaultValue($this->currentUser->surname); $form->addText('email', 'cms.user.email') ->setDefaultValue($this->currentUser->email) ->setRequired() ->addRule(Form::EMAIL); $form->addPhone('phone', 'cms.user.phone') ->setDefaultValue($this->currentUser->phone); $language = $form->addSelectUntranslated('language', 'cms.user.language', $this->localeService->allowed, 'form.none'); if (!empty($this->currentUser->language)) { $locale = $this->localeService->get($this->currentUser->language); if ($locale) { $language->setDefaultValue($locale->id); } } $roles = $form->addMultiSelectUntranslated('roles', 'cms.permissions.roles', $this->orm->aclRoles->fetchPairs($this->user->isAllowed('dockbar.settings.permissions.superadmin', 'view'))) ->setRequired(); try { $roles->setDefaultValue($this->currentUser->roles->getRawValue()); } catch (InvalidArgumentException $ex) { } $form->addSubmit('save', 'form.save'); $form->addLink('back', 'form.back', $this->getBacklink()); $form->onSuccess[] = [$this, 'editFormSucceeded']; return $form; }
php
protected function createComponentEditForm(): Form { $form = $this->formFactory->create(); $form->addProtection(); $form->addText('username', 'cms.user.username') ->setDefaultValue($this->currentUser->username) ->setRequired(); $form->addText('firstName', 'cms.user.firstName') ->setDefaultValue($this->currentUser->firstName); $form->addText('surname', 'cms.user.surname') ->setDefaultValue($this->currentUser->surname); $form->addText('email', 'cms.user.email') ->setDefaultValue($this->currentUser->email) ->setRequired() ->addRule(Form::EMAIL); $form->addPhone('phone', 'cms.user.phone') ->setDefaultValue($this->currentUser->phone); $language = $form->addSelectUntranslated('language', 'cms.user.language', $this->localeService->allowed, 'form.none'); if (!empty($this->currentUser->language)) { $locale = $this->localeService->get($this->currentUser->language); if ($locale) { $language->setDefaultValue($locale->id); } } $roles = $form->addMultiSelectUntranslated('roles', 'cms.permissions.roles', $this->orm->aclRoles->fetchPairs($this->user->isAllowed('dockbar.settings.permissions.superadmin', 'view'))) ->setRequired(); try { $roles->setDefaultValue($this->currentUser->roles->getRawValue()); } catch (InvalidArgumentException $ex) { } $form->addSubmit('save', 'form.save'); $form->addLink('back', 'form.back', $this->getBacklink()); $form->onSuccess[] = [$this, 'editFormSucceeded']; return $form; }
[ "protected", "function", "createComponentEditForm", "(", ")", ":", "Form", "{", "$", "form", "=", "$", "this", "->", "formFactory", "->", "create", "(", ")", ";", "$", "form", "->", "addProtection", "(", ")", ";", "$", "form", "->", "addText", "(", "'u...
Formular editace uzivatele @return Form
[ "Formular", "editace", "uzivatele" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/UsersPresenter.php#L351-L392
train
nattreid/cms
src/Control/presenters/UsersPresenter.php
UsersPresenter.editFormSucceeded
public function editFormSucceeded(Form $form, ArrayHash $values): void { try { $this->currentUser->setUsername($values->username); } catch (UniqueConstraintViolationException $ex) { $form->addError('cms.user.duplicityUsername'); return; } catch (InvalidArgumentException $ex) { $form->addError('cms.user.invalidUsername'); return; } try { $this->currentUser->setEmail($values->email); } catch (UniqueConstraintViolationException $ex) { $form->addError('cms.user.duplicityEmail'); return; } catch (InvalidArgumentException $ex) { $form->addError('cms.user.invalidUsername'); return; } try { $this->currentUser->setPhone($values->phone ?: null); } catch (InvalidArgumentException $ex) { $form->addError('cms.user.invalidPhone'); return; } $this->currentUser->firstName = $values->firstName; $this->currentUser->surname = $values->surname; $this->currentUser->roles->set($values->roles); $language = $this->localeService->getById($values->language); $this->currentUser->language = $language === null ? null : $language->name; $this->orm->persistAndFlush($this->currentUser); $this->flashNotifier->success('cms.user.dataSaved'); $this->restoreBacklink(); }
php
public function editFormSucceeded(Form $form, ArrayHash $values): void { try { $this->currentUser->setUsername($values->username); } catch (UniqueConstraintViolationException $ex) { $form->addError('cms.user.duplicityUsername'); return; } catch (InvalidArgumentException $ex) { $form->addError('cms.user.invalidUsername'); return; } try { $this->currentUser->setEmail($values->email); } catch (UniqueConstraintViolationException $ex) { $form->addError('cms.user.duplicityEmail'); return; } catch (InvalidArgumentException $ex) { $form->addError('cms.user.invalidUsername'); return; } try { $this->currentUser->setPhone($values->phone ?: null); } catch (InvalidArgumentException $ex) { $form->addError('cms.user.invalidPhone'); return; } $this->currentUser->firstName = $values->firstName; $this->currentUser->surname = $values->surname; $this->currentUser->roles->set($values->roles); $language = $this->localeService->getById($values->language); $this->currentUser->language = $language === null ? null : $language->name; $this->orm->persistAndFlush($this->currentUser); $this->flashNotifier->success('cms.user.dataSaved'); $this->restoreBacklink(); }
[ "public", "function", "editFormSucceeded", "(", "Form", "$", "form", ",", "ArrayHash", "$", "values", ")", ":", "void", "{", "try", "{", "$", "this", "->", "currentUser", "->", "setUsername", "(", "$", "values", "->", "username", ")", ";", "}", "catch", ...
Zpracovani editace uzivatele @param Form $form @param ArrayHash $values
[ "Zpracovani", "editace", "uzivatele" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/UsersPresenter.php#L399-L439
train
nattreid/cms
src/Control/presenters/UsersPresenter.php
UsersPresenter.passwordFormSucceeded
public function passwordFormSucceeded(Form $form, ArrayHash $values): void { if ($values->generatePassword) { $password = Random::generate($this->minPasswordLength, $this->passwordChars); } else { $password = $values->password; } $this->currentUser->setPassword($password); $this->orm->persistAndFlush($this->currentUser); if ($this->configurator->sendChangePassword) { $this->mailer->sendNewPassword($this->currentUser->email, $this->currentUser->username, $password); } $this->flashNotifier->success('cms.user.passwordChanged'); $this->restoreBacklink(); }
php
public function passwordFormSucceeded(Form $form, ArrayHash $values): void { if ($values->generatePassword) { $password = Random::generate($this->minPasswordLength, $this->passwordChars); } else { $password = $values->password; } $this->currentUser->setPassword($password); $this->orm->persistAndFlush($this->currentUser); if ($this->configurator->sendChangePassword) { $this->mailer->sendNewPassword($this->currentUser->email, $this->currentUser->username, $password); } $this->flashNotifier->success('cms.user.passwordChanged'); $this->restoreBacklink(); }
[ "public", "function", "passwordFormSucceeded", "(", "Form", "$", "form", ",", "ArrayHash", "$", "values", ")", ":", "void", "{", "if", "(", "$", "values", "->", "generatePassword", ")", "{", "$", "password", "=", "Random", "::", "generate", "(", "$", "th...
Zpracovani zmeny hesla @param Form $form @param ArrayHash $values @throws AuthenticationException @throws InvalidLinkException
[ "Zpracovani", "zmeny", "hesla" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/UsersPresenter.php#L490-L508
train
thelia/core
lib/Thelia/Model/FolderQuery.php
FolderQuery.findAllChild
public static function findAllChild($folderId, $depth = 0, $currentPosition = 0) { $result = array(); if (\is_array($folderId)) { foreach ($folderId as $folderSingleId) { $result = array_merge($result, (array) self::findAllChild($folderSingleId, $depth, $currentPosition)); } } else { $currentPosition++; if ($depth == $currentPosition && $depth != 0) { return[]; } $categories = self::create() ->filterByParent($folderId) ->find(); foreach ($categories as $folder) { array_push($result, $folder); $result = array_merge($result, (array) self::findAllChild($folder->getId(), $depth, $currentPosition)); } } return $result; }
php
public static function findAllChild($folderId, $depth = 0, $currentPosition = 0) { $result = array(); if (\is_array($folderId)) { foreach ($folderId as $folderSingleId) { $result = array_merge($result, (array) self::findAllChild($folderSingleId, $depth, $currentPosition)); } } else { $currentPosition++; if ($depth == $currentPosition && $depth != 0) { return[]; } $categories = self::create() ->filterByParent($folderId) ->find(); foreach ($categories as $folder) { array_push($result, $folder); $result = array_merge($result, (array) self::findAllChild($folder->getId(), $depth, $currentPosition)); } } return $result; }
[ "public", "static", "function", "findAllChild", "(", "$", "folderId", ",", "$", "depth", "=", "0", ",", "$", "currentPosition", "=", "0", ")", "{", "$", "result", "=", "array", "(", ")", ";", "if", "(", "\\", "is_array", "(", "$", "folderId", ")", ...
find all contents for a given folder. @param int $folderId the folder id or an array of id @param int $depth max depth you want to search @param int $currentPosition don't change this param, it is used for recursion @return \Thelia\Model\Folder[]
[ "find", "all", "contents", "for", "a", "given", "folder", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/FolderQuery.php#L40-L66
train
thelia/core
lib/Thelia/Tools/TokenProvider.php
TokenProvider.generateToken
public static function generateToken() { $raw = self::getOpenSSLRandom(); if (false === $raw) { $raw = self::getComplexRandom(); } return md5($raw); }
php
public static function generateToken() { $raw = self::getOpenSSLRandom(); if (false === $raw) { $raw = self::getComplexRandom(); } return md5($raw); }
[ "public", "static", "function", "generateToken", "(", ")", "{", "$", "raw", "=", "self", "::", "getOpenSSLRandom", "(", ")", ";", "if", "(", "false", "===", "$", "raw", ")", "{", "$", "raw", "=", "self", "::", "getComplexRandom", "(", ")", ";", "}", ...
Same method as getToken but can be called statically @alias getToken @return string
[ "Same", "method", "as", "getToken", "but", "can", "be", "called", "statically" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Tools/TokenProvider.php#L124-L131
train
thelia/core
lib/Thelia/Controller/Admin/ImportController.php
ImportController.indexAction
public function indexAction($_view = 'import') { $authResponse = $this->checkAuth([AdminResources::IMPORT], [], [AccessManager::VIEW]); if ($authResponse !== null) { return $authResponse; } $this->getParserContext() ->set('category_order', $this->getRequest()->query->get('category_order', 'manual')) ->set('import_order', $this->getRequest()->query->get('import_order', 'manual')) ; return $this->render($_view); }
php
public function indexAction($_view = 'import') { $authResponse = $this->checkAuth([AdminResources::IMPORT], [], [AccessManager::VIEW]); if ($authResponse !== null) { return $authResponse; } $this->getParserContext() ->set('category_order', $this->getRequest()->query->get('category_order', 'manual')) ->set('import_order', $this->getRequest()->query->get('import_order', 'manual')) ; return $this->render($_view); }
[ "public", "function", "indexAction", "(", "$", "_view", "=", "'import'", ")", "{", "$", "authResponse", "=", "$", "this", "->", "checkAuth", "(", "[", "AdminResources", "::", "IMPORT", "]", ",", "[", "]", ",", "[", "AccessManager", "::", "VIEW", "]", "...
Handle default action, that is, list available imports @param string $_view View to render @return \Thelia\Core\HttpFoundation\Response
[ "Handle", "default", "action", "that", "is", "list", "available", "imports" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/ImportController.php#L39-L52
train
thelia/core
lib/Thelia/Controller/Admin/ImportController.php
ImportController.changeImportPositionAction
public function changeImportPositionAction() { $authResponse = $this->checkAuth([AdminResources::IMPORT], [], [AccessManager::UPDATE]); if ($authResponse !== null) { return $authResponse; } $query = $this->getRequest()->query; $this->dispatch( TheliaEvents::IMPORT_CHANGE_POSITION, new UpdatePositionEvent( $query->get('id'), $this->matchPositionMode($query->get('mode')), $query->get('value') ) ); return $this->generateRedirectFromRoute('import.list'); }
php
public function changeImportPositionAction() { $authResponse = $this->checkAuth([AdminResources::IMPORT], [], [AccessManager::UPDATE]); if ($authResponse !== null) { return $authResponse; } $query = $this->getRequest()->query; $this->dispatch( TheliaEvents::IMPORT_CHANGE_POSITION, new UpdatePositionEvent( $query->get('id'), $this->matchPositionMode($query->get('mode')), $query->get('value') ) ); return $this->generateRedirectFromRoute('import.list'); }
[ "public", "function", "changeImportPositionAction", "(", ")", "{", "$", "authResponse", "=", "$", "this", "->", "checkAuth", "(", "[", "AdminResources", "::", "IMPORT", "]", ",", "[", "]", ",", "[", "AccessManager", "::", "UPDATE", "]", ")", ";", "if", "...
Handle import position change action @return \Thelia\Core\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse
[ "Handle", "import", "position", "change", "action" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/ImportController.php#L59-L78
train
thelia/core
lib/Thelia/Controller/Admin/ImportController.php
ImportController.matchPositionMode
protected function matchPositionMode($mode) { if ($mode === 'up') { return UpdatePositionEvent::POSITION_UP; } if ($mode === 'down') { return UpdatePositionEvent::POSITION_DOWN; } return UpdatePositionEvent::POSITION_ABSOLUTE; }
php
protected function matchPositionMode($mode) { if ($mode === 'up') { return UpdatePositionEvent::POSITION_UP; } if ($mode === 'down') { return UpdatePositionEvent::POSITION_DOWN; } return UpdatePositionEvent::POSITION_ABSOLUTE; }
[ "protected", "function", "matchPositionMode", "(", "$", "mode", ")", "{", "if", "(", "$", "mode", "===", "'up'", ")", "{", "return", "UpdatePositionEvent", "::", "POSITION_UP", ";", "}", "if", "(", "$", "mode", "===", "'down'", ")", "{", "return", "Updat...
Match position mode string against position mode constant value @param null|string $mode Position mode string @return integer Position mode constant value
[ "Match", "position", "mode", "string", "against", "position", "mode", "constant", "value" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/ImportController.php#L113-L124
train
thelia/core
lib/Thelia/Controller/Admin/ImportController.php
ImportController.configureAction
public function configureAction($id) { /** @var \Thelia\Handler\ImportHandler $importHandler */ $importHandler = $this->container->get('thelia.import.handler'); $import = $importHandler->getImport($id); if ($import === null) { return $this->pageNotFound(); } $extensions = []; $mimeTypes = []; /** @var \Thelia\Core\Serializer\AbstractSerializer $serializer */ foreach ($this->container->get(RegisterSerializerPass::MANAGER_SERVICE_ID)->getSerializers() as $serializer) { $extensions[] = $serializer->getExtension(); $mimeTypes[] = $serializer->getMimeType(); } /** @var \Thelia\Core\Archiver\AbstractArchiver $archiver */ foreach ($this->container->get(RegisterArchiverPass::MANAGER_SERVICE_ID)->getArchivers(true) as $archiver) { $extensions[] = $archiver->getExtension(); $mimeTypes[] = $archiver->getMimeType(); } // Render standard view or ajax one $templateName = 'import-page'; if ($this->getRequest()->isXmlHttpRequest()) { $templateName = 'ajax/import-modal'; } return $this->render( $templateName, [ 'importId' => $id, 'ALLOWED_MIME_TYPES' => implode(', ', $mimeTypes), 'ALLOWED_EXTENSIONS' => implode(', ', $extensions), ] ); }
php
public function configureAction($id) { /** @var \Thelia\Handler\ImportHandler $importHandler */ $importHandler = $this->container->get('thelia.import.handler'); $import = $importHandler->getImport($id); if ($import === null) { return $this->pageNotFound(); } $extensions = []; $mimeTypes = []; /** @var \Thelia\Core\Serializer\AbstractSerializer $serializer */ foreach ($this->container->get(RegisterSerializerPass::MANAGER_SERVICE_ID)->getSerializers() as $serializer) { $extensions[] = $serializer->getExtension(); $mimeTypes[] = $serializer->getMimeType(); } /** @var \Thelia\Core\Archiver\AbstractArchiver $archiver */ foreach ($this->container->get(RegisterArchiverPass::MANAGER_SERVICE_ID)->getArchivers(true) as $archiver) { $extensions[] = $archiver->getExtension(); $mimeTypes[] = $archiver->getMimeType(); } // Render standard view or ajax one $templateName = 'import-page'; if ($this->getRequest()->isXmlHttpRequest()) { $templateName = 'ajax/import-modal'; } return $this->render( $templateName, [ 'importId' => $id, 'ALLOWED_MIME_TYPES' => implode(', ', $mimeTypes), 'ALLOWED_EXTENSIONS' => implode(', ', $extensions), ] ); }
[ "public", "function", "configureAction", "(", "$", "id", ")", "{", "/** @var \\Thelia\\Handler\\ImportHandler $importHandler */", "$", "importHandler", "=", "$", "this", "->", "container", "->", "get", "(", "'thelia.import.handler'", ")", ";", "$", "import", "=", "$...
Display import configuration view @param integer $id An import identifier @return \Thelia\Core\HttpFoundation\Response
[ "Display", "import", "configuration", "view" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/ImportController.php#L133-L172
train
thelia/core
lib/Thelia/Controller/Admin/ImportController.php
ImportController.importAction
public function importAction($id) { /** @var \Thelia\Handler\Importhandler $importHandler */ $importHandler = $this->container->get('thelia.import.handler'); $import = $importHandler->getImport($id); if ($import === null) { return $this->pageNotFound(); } $form = $this->createForm(AdminForm::IMPORT); try { $validatedForm = $this->validateForm($form); /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $file */ $file = $validatedForm->get('file_upload')->getData(); $file = $file->move( THELIA_CACHE_DIR . 'import' . DS . (new\DateTime)->format('Ymd'), uniqid() . '-' . $file->getClientOriginalName() ); $lang = (new LangQuery)->findPk($validatedForm->get('language')->getData()); $importEvent = $importHandler->import($import, $file, $lang); if (\count($importEvent->getErrors()) > 0) { $this->getSession()->getFlashBag()->add( 'thelia.import.error', $this->getTranslator()->trans( 'Error(s) in import&nbsp;:<br />%errors', [ '%errors' => implode('<br />', $importEvent->getErrors()) ] ) ); } $this->getSession()->getFlashBag()->add( 'thelia.import.success', $this->getTranslator()->trans( 'Import successfully done, %count row(s) have been changed', [ '%count' => $importEvent->getImport()->getImportedRows() ] ) ); return $this->generateRedirectFromRoute('import.view', [], ['id' => $id]); } catch (FormValidationException $e) { $form->setErrorMessage($this->createStandardFormValidationErrorMessage($e)); } catch (\Exception $e) { $this->getParserContext()->setGeneralError($e->getMessage()); } $this->getParserContext() ->addForm($form) ; return $this->configureAction($id); }
php
public function importAction($id) { /** @var \Thelia\Handler\Importhandler $importHandler */ $importHandler = $this->container->get('thelia.import.handler'); $import = $importHandler->getImport($id); if ($import === null) { return $this->pageNotFound(); } $form = $this->createForm(AdminForm::IMPORT); try { $validatedForm = $this->validateForm($form); /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $file */ $file = $validatedForm->get('file_upload')->getData(); $file = $file->move( THELIA_CACHE_DIR . 'import' . DS . (new\DateTime)->format('Ymd'), uniqid() . '-' . $file->getClientOriginalName() ); $lang = (new LangQuery)->findPk($validatedForm->get('language')->getData()); $importEvent = $importHandler->import($import, $file, $lang); if (\count($importEvent->getErrors()) > 0) { $this->getSession()->getFlashBag()->add( 'thelia.import.error', $this->getTranslator()->trans( 'Error(s) in import&nbsp;:<br />%errors', [ '%errors' => implode('<br />', $importEvent->getErrors()) ] ) ); } $this->getSession()->getFlashBag()->add( 'thelia.import.success', $this->getTranslator()->trans( 'Import successfully done, %count row(s) have been changed', [ '%count' => $importEvent->getImport()->getImportedRows() ] ) ); return $this->generateRedirectFromRoute('import.view', [], ['id' => $id]); } catch (FormValidationException $e) { $form->setErrorMessage($this->createStandardFormValidationErrorMessage($e)); } catch (\Exception $e) { $this->getParserContext()->setGeneralError($e->getMessage()); } $this->getParserContext() ->addForm($form) ; return $this->configureAction($id); }
[ "public", "function", "importAction", "(", "$", "id", ")", "{", "/** @var \\Thelia\\Handler\\Importhandler $importHandler */", "$", "importHandler", "=", "$", "this", "->", "container", "->", "get", "(", "'thelia.import.handler'", ")", ";", "$", "import", "=", "$", ...
Handle import action @param integer $id An import identifier @return \Thelia\Core\HttpFoundation\Response|\Symfony\Component\HttpFoundation\Response
[ "Handle", "import", "action" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/ImportController.php#L181-L241
train
perimeter/rate-limiter-php
Storage/Cache.php
Cache.getMeter
public function getMeter($meterIdentifier) { // create cache key $item_key = $this->getCacheKey($meterIdentifier); // if not cached, go get it if (!($meter = $this->cacheService->retrieve($item_key))) { try { // find specific meter for company and login $meter = $this->meterStorage->getMeter($meterIdentifier); } catch (\Exception $e) { $meter = array(); } // cache meter $this->cacheService->store($item_key, $meter, $this->cacheExpires); } return $meter; }
php
public function getMeter($meterIdentifier) { // create cache key $item_key = $this->getCacheKey($meterIdentifier); // if not cached, go get it if (!($meter = $this->cacheService->retrieve($item_key))) { try { // find specific meter for company and login $meter = $this->meterStorage->getMeter($meterIdentifier); } catch (\Exception $e) { $meter = array(); } // cache meter $this->cacheService->store($item_key, $meter, $this->cacheExpires); } return $meter; }
[ "public", "function", "getMeter", "(", "$", "meterIdentifier", ")", "{", "// create cache key", "$", "item_key", "=", "$", "this", "->", "getCacheKey", "(", "$", "meterIdentifier", ")", ";", "// if not cached, go get it", "if", "(", "!", "(", "$", "meter", "="...
Gets the pulsar meter from cache or db
[ "Gets", "the", "pulsar", "meter", "from", "cache", "or", "db" ]
121ba37284dd701afc2f546c4f49d1954564a24a
https://github.com/perimeter/rate-limiter-php/blob/121ba37284dd701afc2f546c4f49d1954564a24a/Storage/Cache.php#L32-L51
train
grom358/pharborist
src/Types.php
Types.normalize
public static function normalize($types) { $normalized_types = []; foreach ($types as $type) { switch ($type) { case 'boolean': $normalized_types[] = 'bool'; break; case 'integer': $normalized_types[] = 'int'; break; case 'double': $normalized_types[] = 'float'; break; case 'callback': $normalized_types[] = 'callable'; break; case 'scalar': $normalized_types[] = 'bool'; $normalized_types[] = 'int'; $normalized_types[] = 'float'; $normalized_types[] = 'string'; break; default: $normalized_types[] = $type; break; } } return $normalized_types; }
php
public static function normalize($types) { $normalized_types = []; foreach ($types as $type) { switch ($type) { case 'boolean': $normalized_types[] = 'bool'; break; case 'integer': $normalized_types[] = 'int'; break; case 'double': $normalized_types[] = 'float'; break; case 'callback': $normalized_types[] = 'callable'; break; case 'scalar': $normalized_types[] = 'bool'; $normalized_types[] = 'int'; $normalized_types[] = 'float'; $normalized_types[] = 'string'; break; default: $normalized_types[] = $type; break; } } return $normalized_types; }
[ "public", "static", "function", "normalize", "(", "$", "types", ")", "{", "$", "normalized_types", "=", "[", "]", ";", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'boolean'", ":", "$", "...
Normalize phpDoc type keywords as per PSR-5. Converts: - boolean to bool - integer to int - double to float - callback to callable - scalar shorthand for bool|int|float|string @param string[] $types Types as returned by DocBlock library. @return string[] Normalize types.
[ "Normalize", "phpDoc", "type", "keywords", "as", "per", "PSR", "-", "5", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Types.php#L27-L55
train
grom358/pharborist
src/Objects/ClassMemberListNode.php
ClassMemberListNode.getTypes
public function getTypes() { // No type specified means type is mixed. $types = ['mixed']; // Use types from the doc comment if available. $doc_comment = $this->getDocComment(); if (!$doc_comment) { return $types; } $doc_block = $doc_comment->getDocBlock(); $var_tags = $doc_block->getTagsByName('var'); if (empty($var_tags)) { return $types; } /** @var \phpDocumentor\Reflection\DocBlock\Tag\VarTag $var_tag */ $var_tag = reset($var_tags); return Types::normalize($var_tag->getTypes()); }
php
public function getTypes() { // No type specified means type is mixed. $types = ['mixed']; // Use types from the doc comment if available. $doc_comment = $this->getDocComment(); if (!$doc_comment) { return $types; } $doc_block = $doc_comment->getDocBlock(); $var_tags = $doc_block->getTagsByName('var'); if (empty($var_tags)) { return $types; } /** @var \phpDocumentor\Reflection\DocBlock\Tag\VarTag $var_tag */ $var_tag = reset($var_tags); return Types::normalize($var_tag->getTypes()); }
[ "public", "function", "getTypes", "(", ")", "{", "// No type specified means type is mixed.", "$", "types", "=", "[", "'mixed'", "]", ";", "// Use types from the doc comment if available.", "$", "doc_comment", "=", "$", "this", "->", "getDocComment", "(", ")", ";", ...
Get the type of the members as defined by doc comment. @return string[] The types as defined by phpdoc standard. Default is ['mixed'].
[ "Get", "the", "type", "of", "the", "members", "as", "defined", "by", "doc", "comment", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Objects/ClassMemberListNode.php#L135-L151
train
grom358/pharborist
src/CommaListNode.php
CommaListNode.prependItem
public function prependItem(Node $item) { if ($this->getItems()->isEmpty()) { $this->append($item); } else { $this->prepend([ $item, Token::comma(), Token::space(), ]); } return $this; }
php
public function prependItem(Node $item) { if ($this->getItems()->isEmpty()) { $this->append($item); } else { $this->prepend([ $item, Token::comma(), Token::space(), ]); } return $this; }
[ "public", "function", "prependItem", "(", "Node", "$", "item", ")", "{", "if", "(", "$", "this", "->", "getItems", "(", ")", "->", "isEmpty", "(", ")", ")", "{", "$", "this", "->", "append", "(", "$", "item", ")", ";", "}", "else", "{", "$", "t...
Prepend item. @param Node $item @return $this
[ "Prepend", "item", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/CommaListNode.php#L68-L80
train
grom358/pharborist
src/CommaListNode.php
CommaListNode.appendItem
public function appendItem(Node $item) { if ($this->getItems()->isEmpty()) { $this->append($item); } else { $this->append([ Token::comma(), Token::space(), $item, ]); } return $this; }
php
public function appendItem(Node $item) { if ($this->getItems()->isEmpty()) { $this->append($item); } else { $this->append([ Token::comma(), Token::space(), $item, ]); } return $this; }
[ "public", "function", "appendItem", "(", "Node", "$", "item", ")", "{", "if", "(", "$", "this", "->", "getItems", "(", ")", "->", "isEmpty", "(", ")", ")", "{", "$", "this", "->", "append", "(", "$", "item", ")", ";", "}", "else", "{", "$", "th...
Append item. @param Node $item @return $this
[ "Append", "item", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/CommaListNode.php#L88-L100
train
grom358/pharborist
src/CommaListNode.php
CommaListNode.insertItem
public function insertItem(Node $item, $index) { $items = $this->getItems(); if ($items->isEmpty()) { if ($index !== 0) { throw new \OutOfBoundsException('index out of bounds'); } $this->append($item); } else { $max_index = count($items) - 1; if ($index < 0 || $index > $max_index) { throw new \OutOfBoundsException('index out of bounds'); } $items[$index]->before([ $item, Token::comma(), Token::space(), ]); } return $this; }
php
public function insertItem(Node $item, $index) { $items = $this->getItems(); if ($items->isEmpty()) { if ($index !== 0) { throw new \OutOfBoundsException('index out of bounds'); } $this->append($item); } else { $max_index = count($items) - 1; if ($index < 0 || $index > $max_index) { throw new \OutOfBoundsException('index out of bounds'); } $items[$index]->before([ $item, Token::comma(), Token::space(), ]); } return $this; }
[ "public", "function", "insertItem", "(", "Node", "$", "item", ",", "$", "index", ")", "{", "$", "items", "=", "$", "this", "->", "getItems", "(", ")", ";", "if", "(", "$", "items", "->", "isEmpty", "(", ")", ")", "{", "if", "(", "$", "index", "...
Insert item before index. @param Node $item @param int $index @throws \OutOfBoundsException Index out of bounds. @return $this
[ "Insert", "item", "before", "index", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/CommaListNode.php#L111-L131
train
grom358/pharborist
src/CommaListNode.php
CommaListNode.pop
public function pop() { $items = $this->getItems(); if ($items->isEmpty()) { return NULL; } if (count($items) === 1) { $pop_item = $items[0]; $pop_item->remove(); return $pop_item; } $pop_item = $items[count($items) - 1]; $pop_item->previousUntil(function ($node) { if ($node instanceof HiddenNode) { return FALSE; } if ($node instanceof TokenNode && $node->getType() === ',') { return FALSE; } return TRUE; })->remove(); $pop_item->remove(); return $pop_item; }
php
public function pop() { $items = $this->getItems(); if ($items->isEmpty()) { return NULL; } if (count($items) === 1) { $pop_item = $items[0]; $pop_item->remove(); return $pop_item; } $pop_item = $items[count($items) - 1]; $pop_item->previousUntil(function ($node) { if ($node instanceof HiddenNode) { return FALSE; } if ($node instanceof TokenNode && $node->getType() === ',') { return FALSE; } return TRUE; })->remove(); $pop_item->remove(); return $pop_item; }
[ "public", "function", "pop", "(", ")", "{", "$", "items", "=", "$", "this", "->", "getItems", "(", ")", ";", "if", "(", "$", "items", "->", "isEmpty", "(", ")", ")", "{", "return", "NULL", ";", "}", "if", "(", "count", "(", "$", "items", ")", ...
Pop an item off end of the list. @return Node The removed item. NULL if item list is empty.
[ "Pop", "an", "item", "off", "end", "of", "the", "list", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/CommaListNode.php#L201-L223
train
grom358/pharborist
src/CommaListNode.php
CommaListNode.shift
public function shift() { $items = $this->getItems(); if ($items->isEmpty()) { return NULL; } if (count($items) === 1) { $pop_item = $items[0]; $pop_item->remove(); return $pop_item; } $pop_item = $items[0]; $pop_item->nextUntil(function ($node) { if ($node instanceof HiddenNode) { return FALSE; } if ($node instanceof TokenNode && $node->getType() === ',') { return FALSE; } return TRUE; })->remove(); $pop_item->remove(); return $pop_item; }
php
public function shift() { $items = $this->getItems(); if ($items->isEmpty()) { return NULL; } if (count($items) === 1) { $pop_item = $items[0]; $pop_item->remove(); return $pop_item; } $pop_item = $items[0]; $pop_item->nextUntil(function ($node) { if ($node instanceof HiddenNode) { return FALSE; } if ($node instanceof TokenNode && $node->getType() === ',') { return FALSE; } return TRUE; })->remove(); $pop_item->remove(); return $pop_item; }
[ "public", "function", "shift", "(", ")", "{", "$", "items", "=", "$", "this", "->", "getItems", "(", ")", ";", "if", "(", "$", "items", "->", "isEmpty", "(", ")", ")", "{", "return", "NULL", ";", "}", "if", "(", "count", "(", "$", "items", ")",...
Shift an item off start of the list. @return Node The removed item. NULL if item list is empty.
[ "Shift", "an", "item", "off", "start", "of", "the", "list", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/CommaListNode.php#L231-L253
train
grom358/pharborist
src/CommaListNode.php
CommaListNode.toArrayNode
public function toArrayNode() { return ($this->parent instanceof ArrayNode) ? clone $this->parent : Parser::parseExpression('[' . $this->getText() . ']'); }
php
public function toArrayNode() { return ($this->parent instanceof ArrayNode) ? clone $this->parent : Parser::parseExpression('[' . $this->getText() . ']'); }
[ "public", "function", "toArrayNode", "(", ")", "{", "return", "(", "$", "this", "->", "parent", "instanceof", "ArrayNode", ")", "?", "clone", "$", "this", "->", "parent", ":", "Parser", "::", "parseExpression", "(", "'['", ".", "$", "this", "->", "getTex...
Returns this comma list as an ArrayNode. @return ArrayNode
[ "Returns", "this", "comma", "list", "as", "an", "ArrayNode", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/CommaListNode.php#L260-L262
train
thelia/core
lib/Thelia/Module/AbstractPaymentModule.php
AbstractPaymentModule.generateGatewayFormResponse
public function generateGatewayFormResponse($order, $gateway_url, $form_data) { /** @var ParserInterface $parser */ $parser = $this->getContainer()->get("thelia.parser"); $parser->setTemplateDefinition( $parser->getTemplateHelper()->getActiveFrontTemplate() ); $renderedTemplate = $parser->render( "order-payment-gateway.html", array( "order_id" => $order->getId(), "cart_count" => $this->getRequest()->getSession()->getSessionCart($this->getDispatcher())->getCartItems()->count(), "gateway_url" => $gateway_url, "payment_form_data" => $form_data ) ); return Response::create($renderedTemplate); }
php
public function generateGatewayFormResponse($order, $gateway_url, $form_data) { /** @var ParserInterface $parser */ $parser = $this->getContainer()->get("thelia.parser"); $parser->setTemplateDefinition( $parser->getTemplateHelper()->getActiveFrontTemplate() ); $renderedTemplate = $parser->render( "order-payment-gateway.html", array( "order_id" => $order->getId(), "cart_count" => $this->getRequest()->getSession()->getSessionCart($this->getDispatcher())->getCartItems()->count(), "gateway_url" => $gateway_url, "payment_form_data" => $form_data ) ); return Response::create($renderedTemplate); }
[ "public", "function", "generateGatewayFormResponse", "(", "$", "order", ",", "$", "gateway_url", ",", "$", "form_data", ")", "{", "/** @var ParserInterface $parser */", "$", "parser", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "\"thelia....
Render the payment gateway template. The module should provide the gateway URL and the form fields names and values. @param Order $order the order @param string $gateway_url the payment gateway URL @param array $form_data an associative array of form data, that will be rendered as hiddent fields @return Response the HTTP response.
[ "Render", "the", "payment", "gateway", "template", ".", "The", "module", "should", "provide", "the", "gateway", "URL", "and", "the", "form", "fields", "names", "and", "values", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Module/AbstractPaymentModule.php#L33-L53
train
thelia/core
lib/Thelia/Module/AbstractPaymentModule.php
AbstractPaymentModule.getPaymentSuccessPageUrl
public function getPaymentSuccessPageUrl($order_id) { $frontOfficeRouter = $this->getContainer()->get('router.front'); return URL::getInstance()->absoluteUrl( $frontOfficeRouter->generate( "order.placed", array("order_id" => $order_id), Router::ABSOLUTE_URL ) ); }
php
public function getPaymentSuccessPageUrl($order_id) { $frontOfficeRouter = $this->getContainer()->get('router.front'); return URL::getInstance()->absoluteUrl( $frontOfficeRouter->generate( "order.placed", array("order_id" => $order_id), Router::ABSOLUTE_URL ) ); }
[ "public", "function", "getPaymentSuccessPageUrl", "(", "$", "order_id", ")", "{", "$", "frontOfficeRouter", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'router.front'", ")", ";", "return", "URL", "::", "getInstance", "(", ")", "->", ...
Return the order payment success page URL @param int $order_id the order ID @return string the order payment success page URL
[ "Return", "the", "order", "payment", "success", "page", "URL" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Module/AbstractPaymentModule.php#L61-L72
train
nattreid/cms
src/Control/presenters/PermissionsPresenter.php
PermissionsPresenter.handleClearCacheACL
public function handleClearCacheACL(): void { if ($this->isAjax()) { $this->authorizatorFactory->cleanCache(); $this->flashNotifier->success('cms.permissions.aclCacheCleared'); } else { $this->terminate(); } }
php
public function handleClearCacheACL(): void { if ($this->isAjax()) { $this->authorizatorFactory->cleanCache(); $this->flashNotifier->success('cms.permissions.aclCacheCleared'); } else { $this->terminate(); } }
[ "public", "function", "handleClearCacheACL", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "isAjax", "(", ")", ")", "{", "$", "this", "->", "authorizatorFactory", "->", "cleanCache", "(", ")", ";", "$", "this", "->", "flashNotifier", "->", ...
Smazani cache ACL @secured @throws AbortException
[ "Smazani", "cache", "ACL" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/PermissionsPresenter.php#L194-L202
train
nattreid/cms
src/Control/presenters/PermissionsPresenter.php
PermissionsPresenter.setRoleName
public function setRoleName(int $id, string $value): void { if ($this->isAjax()) { $grid = $this['rolesList']; try { $role = $this->orm->aclRoles->getById($id); $role->setName($value); $this->orm->persistAndFlush($role); $this->flashNotifier->success('default.dataSaved'); } catch (UniqueConstraintViolationException $ex) { $this->flashNotifier->error('cms.permissions.duplicityName'); $grid->redrawItem($id); } catch (InvalidArgumentException $ex) { $this->flashNotifier->error('cms.permissions.invalidName'); $grid->redrawItem($id); } } else { $this->terminate(); } }
php
public function setRoleName(int $id, string $value): void { if ($this->isAjax()) { $grid = $this['rolesList']; try { $role = $this->orm->aclRoles->getById($id); $role->setName($value); $this->orm->persistAndFlush($role); $this->flashNotifier->success('default.dataSaved'); } catch (UniqueConstraintViolationException $ex) { $this->flashNotifier->error('cms.permissions.duplicityName'); $grid->redrawItem($id); } catch (InvalidArgumentException $ex) { $this->flashNotifier->error('cms.permissions.invalidName'); $grid->redrawItem($id); } } else { $this->terminate(); } }
[ "public", "function", "setRoleName", "(", "int", "$", "id", ",", "string", "$", "value", ")", ":", "void", "{", "if", "(", "$", "this", "->", "isAjax", "(", ")", ")", "{", "$", "grid", "=", "$", "this", "[", "'rolesList'", "]", ";", "try", "{", ...
Ulozi jmeno role @param int $id @param string $value @throws AbortException
[ "Ulozi", "jmeno", "role" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/PermissionsPresenter.php#L319-L338
train
nattreid/cms
src/Control/presenters/PermissionsPresenter.php
PermissionsPresenter.setRoleParent
public function setRoleParent(int $id, string $value): void { if ($this->isAjax()) { $role = $this->orm->aclRoles->getById($id); $role->parent = $value; $this->orm->persistAndFlush($role); $this->flashNotifier->success('default.dataSaved'); $this['rolesList']->redrawItem($id); } else { $this->terminate(); } }
php
public function setRoleParent(int $id, string $value): void { if ($this->isAjax()) { $role = $this->orm->aclRoles->getById($id); $role->parent = $value; $this->orm->persistAndFlush($role); $this->flashNotifier->success('default.dataSaved'); $this['rolesList']->redrawItem($id); } else { $this->terminate(); } }
[ "public", "function", "setRoleParent", "(", "int", "$", "id", ",", "string", "$", "value", ")", ":", "void", "{", "if", "(", "$", "this", "->", "isAjax", "(", ")", ")", "{", "$", "role", "=", "$", "this", "->", "orm", "->", "aclRoles", "->", "get...
Ulozi rodice role @param int $id @param string $value @throws AbortException
[ "Ulozi", "rodice", "role" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/PermissionsPresenter.php#L346-L358
train
nattreid/cms
src/Control/presenters/PermissionsPresenter.php
PermissionsPresenter.setPermissionRole
public function setPermissionRole(int $id, int $value): void { if ($this->isAjax()) { $acl = $this->orm->acl->getById($id); $acl->role = $value; $this->orm->persistAndFlush($acl); $this->flashNotifier->success('default.dataSaved'); $this['permissionsList']->redrawItem($id); } else { $this->terminate(); } }
php
public function setPermissionRole(int $id, int $value): void { if ($this->isAjax()) { $acl = $this->orm->acl->getById($id); $acl->role = $value; $this->orm->persistAndFlush($acl); $this->flashNotifier->success('default.dataSaved'); $this['permissionsList']->redrawItem($id); } else { $this->terminate(); } }
[ "public", "function", "setPermissionRole", "(", "int", "$", "id", ",", "int", "$", "value", ")", ":", "void", "{", "if", "(", "$", "this", "->", "isAjax", "(", ")", ")", "{", "$", "acl", "=", "$", "this", "->", "orm", "->", "acl", "->", "getById"...
Nastavi roli pravidlu @param int $id @param int $value @throws AbortException
[ "Nastavi", "roli", "pravidlu" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/PermissionsPresenter.php#L366-L379
train
nattreid/cms
src/Control/presenters/PermissionsPresenter.php
PermissionsPresenter.setPermissionResource
public function setPermissionResource(int $id, int $value): void { if ($this->isAjax()) { $acl = $this->orm->acl->getById($id); $acl->resource = $value; $this->orm->persistAndFlush($acl); $this->flashNotifier->success('default.dataSaved'); $this['permissionsList']->redrawItem($id); } else { $this->terminate(); } }
php
public function setPermissionResource(int $id, int $value): void { if ($this->isAjax()) { $acl = $this->orm->acl->getById($id); $acl->resource = $value; $this->orm->persistAndFlush($acl); $this->flashNotifier->success('default.dataSaved'); $this['permissionsList']->redrawItem($id); } else { $this->terminate(); } }
[ "public", "function", "setPermissionResource", "(", "int", "$", "id", ",", "int", "$", "value", ")", ":", "void", "{", "if", "(", "$", "this", "->", "isAjax", "(", ")", ")", "{", "$", "acl", "=", "$", "this", "->", "orm", "->", "acl", "->", "getB...
Nastavi zdroj pravidlu @param int $id @param int $value @throws AbortException
[ "Nastavi", "zdroj", "pravidlu" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/PermissionsPresenter.php#L387-L400
train
nattreid/cms
src/Control/presenters/PermissionsPresenter.php
PermissionsPresenter.setPermissionPrivilege
public function setPermissionPrivilege(int $id, string $value): void { if ($this->isAjax()) { $permission = $this->orm->acl->getById($id); $permission->privilege = $value; $this->orm->persistAndFlush($permission); $this->flashNotifier->success('default.dataSaved'); $this['permissionsList']->redrawItem($id); } else { $this->terminate(); } }
php
public function setPermissionPrivilege(int $id, string $value): void { if ($this->isAjax()) { $permission = $this->orm->acl->getById($id); $permission->privilege = $value; $this->orm->persistAndFlush($permission); $this->flashNotifier->success('default.dataSaved'); $this['permissionsList']->redrawItem($id); } else { $this->terminate(); } }
[ "public", "function", "setPermissionPrivilege", "(", "int", "$", "id", ",", "string", "$", "value", ")", ":", "void", "{", "if", "(", "$", "this", "->", "isAjax", "(", ")", ")", "{", "$", "permission", "=", "$", "this", "->", "orm", "->", "acl", "-...
Ulozi operaci pravidla @param int $id @param string $value @throws AbortException
[ "Ulozi", "operaci", "pravidla" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/PermissionsPresenter.php#L408-L421
train
nattreid/cms
src/Control/presenters/PermissionsPresenter.php
PermissionsPresenter.setPermissionState
public function setPermissionState(int $id, bool $value): void { if ($this->isAjax()) { $permission = $this->orm->acl->getById($id); $permission->allowed = $value; $this->orm->persistAndFlush($permission); $this->flashNotifier->success('default.dataSaved'); $this['permissionsList']->redrawItem($id); } else { $this->terminate(); } }
php
public function setPermissionState(int $id, bool $value): void { if ($this->isAjax()) { $permission = $this->orm->acl->getById($id); $permission->allowed = $value; $this->orm->persistAndFlush($permission); $this->flashNotifier->success('default.dataSaved'); $this['permissionsList']->redrawItem($id); } else { $this->terminate(); } }
[ "public", "function", "setPermissionState", "(", "int", "$", "id", ",", "bool", "$", "value", ")", ":", "void", "{", "if", "(", "$", "this", "->", "isAjax", "(", ")", ")", "{", "$", "permission", "=", "$", "this", "->", "orm", "->", "acl", "->", ...
Ulozi stav pravidla @param int $id @param bool $value @throws AbortException
[ "Ulozi", "stav", "pravidla" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/PermissionsPresenter.php#L429-L442
train
grom358/pharborist
src/Functions/FunctionDeclarationNode.php
FunctionDeclarationNode.create
public static function create($function_name, $parameters = NULL) { /** @var FunctionDeclarationNode $function */ $function = Parser::parseSnippet("function $function_name() {}"); if (is_array($parameters)) { foreach ($parameters as $parameter) { if (is_string($parameter)) { $parameter = ParameterNode::create($parameter); } $function->appendParameter($parameter); } } return $function; }
php
public static function create($function_name, $parameters = NULL) { /** @var FunctionDeclarationNode $function */ $function = Parser::parseSnippet("function $function_name() {}"); if (is_array($parameters)) { foreach ($parameters as $parameter) { if (is_string($parameter)) { $parameter = ParameterNode::create($parameter); } $function->appendParameter($parameter); } } return $function; }
[ "public", "static", "function", "create", "(", "$", "function_name", ",", "$", "parameters", "=", "NULL", ")", "{", "/** @var FunctionDeclarationNode $function */", "$", "function", "=", "Parser", "::", "parseSnippet", "(", "\"function $function_name() {}\"", ")", ";"...
Create a function declaration. @param NameNode|string $function_name The function name. @param array $parameters (Optional) List of parameters. @return FunctionDeclarationNode
[ "Create", "a", "function", "declaration", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Functions/FunctionDeclarationNode.php#L30-L42
train
grom358/pharborist
src/Functions/FunctionDeclarationNode.php
FunctionDeclarationNode.setName
public function setName($name) { /** @var TokenNode $function_name */ $function_name = $this->getName()->firstChild(); $function_name->setText($name); return $this; }
php
public function setName($name) { /** @var TokenNode $function_name */ $function_name = $this->getName()->firstChild(); $function_name->setText($name); return $this; }
[ "public", "function", "setName", "(", "$", "name", ")", "{", "/** @var TokenNode $function_name */", "$", "function_name", "=", "$", "this", "->", "getName", "(", ")", "->", "firstChild", "(", ")", ";", "$", "function_name", "->", "setText", "(", "$", "name"...
Set the name of the declared function. @param string $name New function name. @return $this
[ "Set", "the", "name", "of", "the", "declared", "function", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Functions/FunctionDeclarationNode.php#L56-L61
train
thelia/core
lib/Thelia/Controller/Admin/CurrencyController.php
CurrencyController.updateRatesAction
public function updateRatesAction() { // Check current user authorization if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) { return $response; } try { $event = new CurrencyUpdateRateEvent(); $this->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES, $event); if ($event->hasUndefinedRates()) { return $this->render('currencies', [ 'undefined_rates' => $event->getUndefinedRates() ]); } } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } return $this->redirectToListTemplate(); }
php
public function updateRatesAction() { // Check current user authorization if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) { return $response; } try { $event = new CurrencyUpdateRateEvent(); $this->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES, $event); if ($event->hasUndefinedRates()) { return $this->render('currencies', [ 'undefined_rates' => $event->getUndefinedRates() ]); } } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } return $this->redirectToListTemplate(); }
[ "public", "function", "updateRatesAction", "(", ")", "{", "// Check current user authorization", "if", "(", "null", "!==", "$", "response", "=", "$", "this", "->", "checkAuth", "(", "$", "this", "->", "resourceCode", ",", "array", "(", ")", ",", "AccessManager...
Update currencies rates
[ "Update", "currencies", "rates" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/CurrencyController.php#L191-L214
train
thelia/core
lib/Thelia/Controller/Admin/CurrencyController.php
CurrencyController.setVisibleAction
public function setVisibleAction() { // Check current user authorization if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) { return $response; } $changeEvent = new CurrencyUpdateEvent((int) $this->getRequest()->get('currency_id', 0)); // Create and dispatch the change event $changeEvent->setVisible((int) $this->getRequest()->get('visible', 0)); try { $this->dispatch(TheliaEvents::CURRENCY_SET_VISIBLE, $changeEvent); } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } return $this->redirectToListTemplate(); }
php
public function setVisibleAction() { // Check current user authorization if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) { return $response; } $changeEvent = new CurrencyUpdateEvent((int) $this->getRequest()->get('currency_id', 0)); // Create and dispatch the change event $changeEvent->setVisible((int) $this->getRequest()->get('visible', 0)); try { $this->dispatch(TheliaEvents::CURRENCY_SET_VISIBLE, $changeEvent); } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } return $this->redirectToListTemplate(); }
[ "public", "function", "setVisibleAction", "(", ")", "{", "// Check current user authorization", "if", "(", "null", "!==", "$", "response", "=", "$", "this", "->", "checkAuth", "(", "$", "this", "->", "resourceCode", ",", "array", "(", ")", ",", "AccessManager"...
Sets if the currency is visible for Front
[ "Sets", "if", "the", "currency", "is", "visible", "for", "Front" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/CurrencyController.php#L244-L264
train
NotifyMeHQ/notifyme
src/Adapters/Twilio/TwilioFactory.php
TwilioFactory.make
public function make(array $config) { Arr::requires($config, ['from', 'client', 'token']); $client = new Client(); return new TwilioGateway($client, $config); }
php
public function make(array $config) { Arr::requires($config, ['from', 'client', 'token']); $client = new Client(); return new TwilioGateway($client, $config); }
[ "public", "function", "make", "(", "array", "$", "config", ")", "{", "Arr", "::", "requires", "(", "$", "config", ",", "[", "'from'", ",", "'client'", ",", "'token'", "]", ")", ";", "$", "client", "=", "new", "Client", "(", ")", ";", "return", "new...
Create a new twilio gateway instance. @param string[] $config @return \NotifyMeHQ\Adapters\Twilio\TwilioGateway
[ "Create", "a", "new", "twilio", "gateway", "instance", "." ]
2af4bdcfe9df6db7ea79e2dce90b106ccb285b06
https://github.com/NotifyMeHQ/notifyme/blob/2af4bdcfe9df6db7ea79e2dce90b106ccb285b06/src/Adapters/Twilio/TwilioFactory.php#L27-L34
train
grom358/pharborist
src/Objects/ClassMethodNode.php
ClassMethodNode.fromFunction
public static function fromFunction(FunctionDeclarationNode $function_node) { $method_name = $function_node->getName()->getText(); $parameters = $function_node->getParameterList()->getText(); $body = $function_node->getBody()->getText(); /** @var ClassNode $class_node */ $class_node = Parser::parseSnippet("class Method {public function {$method_name}($parameters) $body}"); FormatterFactory::format($class_node); $method_node = $class_node->getStatements()[0]->remove(); return $method_node; }
php
public static function fromFunction(FunctionDeclarationNode $function_node) { $method_name = $function_node->getName()->getText(); $parameters = $function_node->getParameterList()->getText(); $body = $function_node->getBody()->getText(); /** @var ClassNode $class_node */ $class_node = Parser::parseSnippet("class Method {public function {$method_name}($parameters) $body}"); FormatterFactory::format($class_node); $method_node = $class_node->getStatements()[0]->remove(); return $method_node; }
[ "public", "static", "function", "fromFunction", "(", "FunctionDeclarationNode", "$", "function_node", ")", "{", "$", "method_name", "=", "$", "function_node", "->", "getName", "(", ")", "->", "getText", "(", ")", ";", "$", "parameters", "=", "$", "function_nod...
Create method from function declaration. @param FunctionDeclarationNode $function_node @return ClassMethodNode
[ "Create", "method", "from", "function", "declaration", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Objects/ClassMethodNode.php#L50-L59
train
grom358/pharborist
src/Objects/InterfaceNode.php
InterfaceNode.getMethod
public function getMethod($name) { $methods = $this ->getMethods() ->filter(function (InterfaceMethodNode $method) use ($name) { return $method->getName()->getText() === $name; }); return $methods->isEmpty() ? NULL : $methods[0]; }
php
public function getMethod($name) { $methods = $this ->getMethods() ->filter(function (InterfaceMethodNode $method) use ($name) { return $method->getName()->getText() === $name; }); return $methods->isEmpty() ? NULL : $methods[0]; }
[ "public", "function", "getMethod", "(", "$", "name", ")", "{", "$", "methods", "=", "$", "this", "->", "getMethods", "(", ")", "->", "filter", "(", "function", "(", "InterfaceMethodNode", "$", "method", ")", "use", "(", "$", "name", ")", "{", "return",...
Returns a method by name, if it exists. @param string $name The method name. @return InterfaceMethodNode|NULL
[ "Returns", "a", "method", "by", "name", "if", "it", "exists", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Objects/InterfaceNode.php#L153-L160
train
grom358/pharborist
src/Objects/InterfaceNode.php
InterfaceNode.appendMethod
public function appendMethod($method) { if (is_string($method)) { $method = InterfaceMethodNode::create($method); } $this->statements->lastChild()->before($method); FormatterFactory::format($this); return $this; }
php
public function appendMethod($method) { if (is_string($method)) { $method = InterfaceMethodNode::create($method); } $this->statements->lastChild()->before($method); FormatterFactory::format($this); return $this; }
[ "public", "function", "appendMethod", "(", "$", "method", ")", "{", "if", "(", "is_string", "(", "$", "method", ")", ")", "{", "$", "method", "=", "InterfaceMethodNode", "::", "create", "(", "$", "method", ")", ";", "}", "$", "this", "->", "statements"...
Adds a method to interface. @param InterfaceMethodNode|string $method The method to append. Can either be an existing method, or a string (a new public method will be created with that name). @return $this
[ "Adds", "a", "method", "to", "interface", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Objects/InterfaceNode.php#L195-L202
train
thelia/core
lib/Thelia/Model/Address.php
Address.makeItDefault
public function makeItDefault() { AddressQuery::create()->filterByCustomerId($this->getCustomerId()) ->update(array('IsDefault' => '0')); $this->setIsDefault(1); $this->save(); }
php
public function makeItDefault() { AddressQuery::create()->filterByCustomerId($this->getCustomerId()) ->update(array('IsDefault' => '0')); $this->setIsDefault(1); $this->save(); }
[ "public", "function", "makeItDefault", "(", ")", "{", "AddressQuery", "::", "create", "(", ")", "->", "filterByCustomerId", "(", "$", "this", "->", "getCustomerId", "(", ")", ")", "->", "update", "(", "array", "(", "'IsDefault'", "=>", "'0'", ")", ")", "...
put the the current address as default one
[ "put", "the", "the", "current", "address", "as", "default", "one" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Address.php#L17-L24
train
thelia/core
lib/Thelia/Model/Address.php
Address.preInsert
public function preInsert(ConnectionInterface $con = null) { parent::preInsert($con); $this->dispatchEvent(TheliaEvents::BEFORE_CREATEADDRESS, new AddressEvent($this)); return true; }
php
public function preInsert(ConnectionInterface $con = null) { parent::preInsert($con); $this->dispatchEvent(TheliaEvents::BEFORE_CREATEADDRESS, new AddressEvent($this)); return true; }
[ "public", "function", "preInsert", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "parent", "::", "preInsert", "(", "$", "con", ")", ";", "$", "this", "->", "dispatchEvent", "(", "TheliaEvents", "::", "BEFORE_CREATEADDRESS", ",", "new", "Addr...
Code to be run before inserting to database @param ConnectionInterface $con @return boolean
[ "Code", "to", "be", "run", "before", "inserting", "to", "database" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Address.php#L31-L38
train
thelia/core
lib/Thelia/Model/Address.php
Address.postInsert
public function postInsert(ConnectionInterface $con = null) { parent::postInsert($con); $this->dispatchEvent(TheliaEvents::AFTER_CREATEADDRESS, new AddressEvent($this)); }
php
public function postInsert(ConnectionInterface $con = null) { parent::postInsert($con); $this->dispatchEvent(TheliaEvents::AFTER_CREATEADDRESS, new AddressEvent($this)); }
[ "public", "function", "postInsert", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "parent", "::", "postInsert", "(", "$", "con", ")", ";", "$", "this", "->", "dispatchEvent", "(", "TheliaEvents", "::", "AFTER_CREATEADDRESS", ",", "new", "Add...
Code to be run after inserting to database @param ConnectionInterface $con
[ "Code", "to", "be", "run", "after", "inserting", "to", "database" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Address.php#L44-L49
train
thelia/core
lib/Thelia/Model/Address.php
Address.preUpdate
public function preUpdate(ConnectionInterface $con = null) { parent::preUpdate($con); $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEADDRESS, new AddressEvent($this)); return true; }
php
public function preUpdate(ConnectionInterface $con = null) { parent::preUpdate($con); $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEADDRESS, new AddressEvent($this)); return true; }
[ "public", "function", "preUpdate", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "parent", "::", "preUpdate", "(", "$", "con", ")", ";", "$", "this", "->", "dispatchEvent", "(", "TheliaEvents", "::", "BEFORE_UPDATEADDRESS", ",", "new", "Addr...
Code to be run before updating the object in database @param ConnectionInterface $con @return boolean
[ "Code", "to", "be", "run", "before", "updating", "the", "object", "in", "database" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Address.php#L56-L63
train
thelia/core
lib/Thelia/Model/Address.php
Address.postUpdate
public function postUpdate(ConnectionInterface $con = null) { parent::postUpdate($con); $this->dispatchEvent(TheliaEvents::AFTER_UPDATEADDRESS, new AddressEvent($this)); }
php
public function postUpdate(ConnectionInterface $con = null) { parent::postUpdate($con); $this->dispatchEvent(TheliaEvents::AFTER_UPDATEADDRESS, new AddressEvent($this)); }
[ "public", "function", "postUpdate", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "parent", "::", "postUpdate", "(", "$", "con", ")", ";", "$", "this", "->", "dispatchEvent", "(", "TheliaEvents", "::", "AFTER_UPDATEADDRESS", ",", "new", "Add...
Code to be run after updating the object in database @param ConnectionInterface $con
[ "Code", "to", "be", "run", "after", "updating", "the", "object", "in", "database" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Address.php#L69-L74
train
thelia/core
lib/Thelia/Model/Address.php
Address.preDelete
public function preDelete(ConnectionInterface $con = null) { parent::preDelete($con); if ($this->getIsDefault()) { return false; } $this->dispatchEvent(TheliaEvents::BEFORE_DELETEADDRESS, new AddressEvent($this)); return true; }
php
public function preDelete(ConnectionInterface $con = null) { parent::preDelete($con); if ($this->getIsDefault()) { return false; } $this->dispatchEvent(TheliaEvents::BEFORE_DELETEADDRESS, new AddressEvent($this)); return true; }
[ "public", "function", "preDelete", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "parent", "::", "preDelete", "(", "$", "con", ")", ";", "if", "(", "$", "this", "->", "getIsDefault", "(", ")", ")", "{", "return", "false", ";", "}", "...
Code to be run before deleting the object in database @param ConnectionInterface $con @return boolean
[ "Code", "to", "be", "run", "before", "deleting", "the", "object", "in", "database" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Address.php#L81-L92
train
thelia/core
lib/Thelia/Model/Address.php
Address.postDelete
public function postDelete(ConnectionInterface $con = null) { parent::postDelete($con); $this->dispatchEvent(TheliaEvents::AFTER_DELETEADDRESS, new AddressEvent($this)); }
php
public function postDelete(ConnectionInterface $con = null) { parent::postDelete($con); $this->dispatchEvent(TheliaEvents::AFTER_DELETEADDRESS, new AddressEvent($this)); }
[ "public", "function", "postDelete", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "parent", "::", "postDelete", "(", "$", "con", ")", ";", "$", "this", "->", "dispatchEvent", "(", "TheliaEvents", "::", "AFTER_DELETEADDRESS", ",", "new", "Add...
Code to be run after deleting the object in database @param ConnectionInterface $con
[ "Code", "to", "be", "run", "after", "deleting", "the", "object", "in", "database" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Address.php#L98-L103
train
BoldGrid/library
src/Library/Start.php
Start.loadPluginTextdomain
private function loadPluginTextdomain() { load_textdomain( $this->textdomain, $this->configs->get( 'libraryDir' ) . 'languages/' . $this->textdomain . '-' . get_locale() . '.mo' ); }
php
private function loadPluginTextdomain() { load_textdomain( $this->textdomain, $this->configs->get( 'libraryDir' ) . 'languages/' . $this->textdomain . '-' . get_locale() . '.mo' ); }
[ "private", "function", "loadPluginTextdomain", "(", ")", "{", "load_textdomain", "(", "$", "this", "->", "textdomain", ",", "$", "this", "->", "configs", "->", "get", "(", "'libraryDir'", ")", ".", "'languages/'", ".", "$", "this", "->", "textdomain", ".", ...
Load the library's text domain. @since 2.8.0
[ "Load", "the", "library", "s", "text", "domain", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Start.php#L139-L141
train
BoldGrid/library
src/Library/Start.php
Start.loadPluginInstaller
public function loadPluginInstaller() { if ( ! did_action( 'Boldgrid\Library\Library\Start::loadPluginInstaller' ) ) { do_action( 'Boldgrid\Library\Library\Start::loadPluginInstaller' ); if ( class_exists( '\Boldgrid\Library\Plugin\Installer' ) ) { $this->pluginInstaller = new \Boldgrid\Library\Plugin\Installer( Configs::get( 'pluginInstaller' ), $this->getReleaseChannel() ); } } }
php
public function loadPluginInstaller() { if ( ! did_action( 'Boldgrid\Library\Library\Start::loadPluginInstaller' ) ) { do_action( 'Boldgrid\Library\Library\Start::loadPluginInstaller' ); if ( class_exists( '\Boldgrid\Library\Plugin\Installer' ) ) { $this->pluginInstaller = new \Boldgrid\Library\Plugin\Installer( Configs::get( 'pluginInstaller' ), $this->getReleaseChannel() ); } } }
[ "public", "function", "loadPluginInstaller", "(", ")", "{", "if", "(", "!", "did_action", "(", "'Boldgrid\\Library\\Library\\Start::loadPluginInstaller'", ")", ")", "{", "do_action", "(", "'Boldgrid\\Library\\Library\\Start::loadPluginInstaller'", ")", ";", "if", "(", "cl...
Load the Plugin\Installer class, if exists. @since 1.1.7
[ "Load", "the", "Plugin", "\\", "Installer", "class", "if", "exists", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Start.php#L148-L159
train
BoldGrid/library
src/Library/Start.php
Start.filterConfigs
public function filterConfigs( $configs ) { if ( ! empty( $configs['libraryDir'] ) ) { $configs['libraryUrl'] = str_replace( ABSPATH, get_site_url() . '/', $configs['libraryDir'] ); } return $configs; }
php
public function filterConfigs( $configs ) { if ( ! empty( $configs['libraryDir'] ) ) { $configs['libraryUrl'] = str_replace( ABSPATH, get_site_url() . '/', $configs['libraryDir'] ); } return $configs; }
[ "public", "function", "filterConfigs", "(", "$", "configs", ")", "{", "if", "(", "!", "empty", "(", "$", "configs", "[", "'libraryDir'", "]", ")", ")", "{", "$", "configs", "[", "'libraryUrl'", "]", "=", "str_replace", "(", "ABSPATH", ",", "get_site_url"...
Filter the configuration array. @since 2.2.1 @param array $configs Configuration array. @return array
[ "Filter", "the", "configuration", "array", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Start.php#L169-L179
train
thelia/core
lib/Thelia/Command/ImportCommand.php
ImportCommand.listImport
protected function listImport(OutputInterface $output) { $table = new Table($output); foreach ((new ImportQuery)->find() as $import) { $table->addRow([ $import->getRef(), $import->getTitle(), $import->getDescription() ]); } $table ->setHeaders([ 'Reference', 'Title', 'Description' ]) ->render() ; }
php
protected function listImport(OutputInterface $output) { $table = new Table($output); foreach ((new ImportQuery)->find() as $import) { $table->addRow([ $import->getRef(), $import->getTitle(), $import->getDescription() ]); } $table ->setHeaders([ 'Reference', 'Title', 'Description' ]) ->render() ; }
[ "protected", "function", "listImport", "(", "OutputInterface", "$", "output", ")", "{", "$", "table", "=", "new", "Table", "(", "$", "output", ")", ";", "foreach", "(", "(", "new", "ImportQuery", ")", "->", "find", "(", ")", "as", "$", "import", ")", ...
Output available imports @param \Symfony\Component\Console\Output\OutputInterface $output An output interface
[ "Output", "available", "imports" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Command/ImportCommand.php#L120-L140
train
jbroadway/phpactiveresource
lib/ActiveResource/ActiveResource.php
ActiveResource._build_xml
public function _build_xml ($k, $v) { if (is_object ($v) && strtolower (get_class ($v)) == 'simplexmlelement') { return preg_replace ('/<\?xml(.*?)\?>\n*/', '', $v->asXML ()); } $res = ''; $attrs = ''; if (! is_numeric ($k)) { $res = '<' . $k . '{{attributes}}>'; } if (is_object ($v)) { $v = (array) $v; } if (is_array ($v)) { foreach ($v as $key => $value) { // handle attributes of repeating tags if (is_numeric ($key) && is_array ($value)) { foreach ($value as $sub_key => $sub_value) { if (strpos ($sub_key, '@') === 0) { $attrs .= ' ' . substr ($sub_key, 1) . '="' . $this->_xml_entities ($sub_value) . '"'; unset ($value[$sub_key]); continue; } } } if (strpos ($key, '@') === 0) { $attrs .= ' ' . substr ($key, 1) . '="' . $this->_xml_entities ($value) . '"'; continue; } $res .= $this->_build_xml ($key, $value); $keys = array_keys ($v); if (is_numeric ($key) && $key !== array_pop ($keys)) { // reset attributes on repeating tags if (is_array ($value)) { $res = str_replace ('<' . $k . '{{attributes}}>', '<' . $k . $attrs . '>', $res); $attrs = ''; } $res .= '</' . $k . ">\n<" . $k . '{{attributes}}>'; } } } else { $res .= $this->_xml_entities ($v); } if (! is_numeric ($k)) { $res .= '</' . $k . ">\n"; } $res = str_replace ('<' . $k . '{{attributes}}>', '<' . $k . $attrs . '>', $res); return $res; }
php
public function _build_xml ($k, $v) { if (is_object ($v) && strtolower (get_class ($v)) == 'simplexmlelement') { return preg_replace ('/<\?xml(.*?)\?>\n*/', '', $v->asXML ()); } $res = ''; $attrs = ''; if (! is_numeric ($k)) { $res = '<' . $k . '{{attributes}}>'; } if (is_object ($v)) { $v = (array) $v; } if (is_array ($v)) { foreach ($v as $key => $value) { // handle attributes of repeating tags if (is_numeric ($key) && is_array ($value)) { foreach ($value as $sub_key => $sub_value) { if (strpos ($sub_key, '@') === 0) { $attrs .= ' ' . substr ($sub_key, 1) . '="' . $this->_xml_entities ($sub_value) . '"'; unset ($value[$sub_key]); continue; } } } if (strpos ($key, '@') === 0) { $attrs .= ' ' . substr ($key, 1) . '="' . $this->_xml_entities ($value) . '"'; continue; } $res .= $this->_build_xml ($key, $value); $keys = array_keys ($v); if (is_numeric ($key) && $key !== array_pop ($keys)) { // reset attributes on repeating tags if (is_array ($value)) { $res = str_replace ('<' . $k . '{{attributes}}>', '<' . $k . $attrs . '>', $res); $attrs = ''; } $res .= '</' . $k . ">\n<" . $k . '{{attributes}}>'; } } } else { $res .= $this->_xml_entities ($v); } if (! is_numeric ($k)) { $res .= '</' . $k . ">\n"; } $res = str_replace ('<' . $k . '{{attributes}}>', '<' . $k . $attrs . '>', $res); return $res; }
[ "public", "function", "_build_xml", "(", "$", "k", ",", "$", "v", ")", "{", "if", "(", "is_object", "(", "$", "v", ")", "&&", "strtolower", "(", "get_class", "(", "$", "v", ")", ")", "==", "'simplexmlelement'", ")", "{", "return", "preg_replace", "("...
Simple recursive function to build an XML response.
[ "Simple", "recursive", "function", "to", "build", "an", "XML", "response", "." ]
6e10c5bacdbe355687ca1296782f647607cc9215
https://github.com/jbroadway/phpactiveresource/blob/6e10c5bacdbe355687ca1296782f647607cc9215/lib/ActiveResource/ActiveResource.php#L315-L363
train
jbroadway/phpactiveresource
lib/ActiveResource/ActiveResource.php
ActiveResource._unicode_ord
public function _unicode_ord (&$c, &$i = 0) { // get the character length $l = strlen($c); // copy the offset $index = $i; // check it's a valid offset if ($index >= $l) { return false; } // check the value $o = ord($c[$index]); // if it's ascii if ($o <= 0x7F) { return $o; // not sure what it is... } elseif ($o < 0xC2) { return false; // if it's a two-byte character } elseif ($o <= 0xDF && $index < $l - 1) { $i += 1; return ($o & 0x1F) << 6 | (ord($c[$index + 1]) & 0x3F); // three-byte } elseif ($o <= 0xEF && $index < $l - 2) { $i += 2; return ($o & 0x0F) << 12 | (ord($c[$index + 1]) & 0x3F) << 6 | (ord($c[$index + 2]) & 0x3F); // four-byte } elseif ($o <= 0xF4 && $index < $l - 3) { $i += 3; return ($o & 0x0F) << 18 | (ord($c[$index + 1]) & 0x3F) << 12 | (ord($c[$index + 2]) & 0x3F) << 6 | (ord($c[$index + 3]) & 0x3F); // not sure what it is... } else { return false; } }
php
public function _unicode_ord (&$c, &$i = 0) { // get the character length $l = strlen($c); // copy the offset $index = $i; // check it's a valid offset if ($index >= $l) { return false; } // check the value $o = ord($c[$index]); // if it's ascii if ($o <= 0x7F) { return $o; // not sure what it is... } elseif ($o < 0xC2) { return false; // if it's a two-byte character } elseif ($o <= 0xDF && $index < $l - 1) { $i += 1; return ($o & 0x1F) << 6 | (ord($c[$index + 1]) & 0x3F); // three-byte } elseif ($o <= 0xEF && $index < $l - 2) { $i += 2; return ($o & 0x0F) << 12 | (ord($c[$index + 1]) & 0x3F) << 6 | (ord($c[$index + 2]) & 0x3F); // four-byte } elseif ($o <= 0xF4 && $index < $l - 3) { $i += 3; return ($o & 0x0F) << 18 | (ord($c[$index + 1]) & 0x3F) << 12 | (ord($c[$index + 2]) & 0x3F) << 6 | (ord($c[$index + 3]) & 0x3F); // not sure what it is... } else { return false; } }
[ "public", "function", "_unicode_ord", "(", "&", "$", "c", ",", "&", "$", "i", "=", "0", ")", "{", "// get the character length", "$", "l", "=", "strlen", "(", "$", "c", ")", ";", "// copy the offset", "$", "index", "=", "$", "i", ";", "// check it's a ...
Returns the unicode value of the string @param string $c The source string @param integer $i The index to get the char from (passed by reference for use in a loop) @return integer The value of the char at $c[$i] @author kerry at shetline dot com @author Dom Hastings - modified to suit my needs @see http://www.php.net/manual/en/function.ord.php#78032
[ "Returns", "the", "unicode", "value", "of", "the", "string" ]
6e10c5bacdbe355687ca1296782f647607cc9215
https://github.com/jbroadway/phpactiveresource/blob/6e10c5bacdbe355687ca1296782f647607cc9215/lib/ActiveResource/ActiveResource.php#L375-L416
train
jbroadway/phpactiveresource
lib/ActiveResource/ActiveResource.php
ActiveResource._xml_entities
public function _xml_entities ($s, $hex = true) { // if the string is empty if (empty($s)) { // just return it return $s; } $s = (string) $s; // create the return string $r = ''; // get the length $l = strlen($s); // iterate the string for ($i = 0; $i < $l; $i++) { // get the value of the character $o = $this->_unicode_ord($s, $i); // valid characters $v = ( // \t \n <vertical tab> <form feed> \r ($o >= 9 && $o <= 13) || // <space> ! ($o == 32) || ($o == 33) || // # $ % ($o >= 35 && $o <= 37) || // ( ) * + , - . / ($o >= 40 && $o <= 47) || // numbers ($o >= 48 && $o <= 57) || // : ; ($o == 58) || ($o == 59) || // = ? ($o == 61) || ($o == 63) || // @ ($o == 64) || // uppercase ($o >= 65 && $o <= 90) || // [ \ ] ^ _ ` ($o >= 91 && $o <= 96) || // lowercase ($o >= 97 && $o <= 122) || // { | } ~ ($o >= 123 && $o <= 126) ); // if it's valid, just keep it if ($v) { $r .= $s[$i]; // & } elseif ($o == 38) { $r .= '&amp;'; // < } elseif ($o == 60) { $r .= '&lt;'; // > } elseif ($o == 62) { $r .= '&gt;'; // ' } elseif ($o == 39) { $r .= '&apos;'; // " } elseif ($o == 34) { $r .= '&quot;'; // unknown, add it as a reference } elseif ($o > 0) { if ($hex) { $r .= '&#x'.strtoupper(dechex($o)).';'; } else { $r .= '&#'.$o.';'; } } } return $r; }
php
public function _xml_entities ($s, $hex = true) { // if the string is empty if (empty($s)) { // just return it return $s; } $s = (string) $s; // create the return string $r = ''; // get the length $l = strlen($s); // iterate the string for ($i = 0; $i < $l; $i++) { // get the value of the character $o = $this->_unicode_ord($s, $i); // valid characters $v = ( // \t \n <vertical tab> <form feed> \r ($o >= 9 && $o <= 13) || // <space> ! ($o == 32) || ($o == 33) || // # $ % ($o >= 35 && $o <= 37) || // ( ) * + , - . / ($o >= 40 && $o <= 47) || // numbers ($o >= 48 && $o <= 57) || // : ; ($o == 58) || ($o == 59) || // = ? ($o == 61) || ($o == 63) || // @ ($o == 64) || // uppercase ($o >= 65 && $o <= 90) || // [ \ ] ^ _ ` ($o >= 91 && $o <= 96) || // lowercase ($o >= 97 && $o <= 122) || // { | } ~ ($o >= 123 && $o <= 126) ); // if it's valid, just keep it if ($v) { $r .= $s[$i]; // & } elseif ($o == 38) { $r .= '&amp;'; // < } elseif ($o == 60) { $r .= '&lt;'; // > } elseif ($o == 62) { $r .= '&gt;'; // ' } elseif ($o == 39) { $r .= '&apos;'; // " } elseif ($o == 34) { $r .= '&quot;'; // unknown, add it as a reference } elseif ($o > 0) { if ($hex) { $r .= '&#x'.strtoupper(dechex($o)).';'; } else { $r .= '&#'.$o.';'; } } } return $r; }
[ "public", "function", "_xml_entities", "(", "$", "s", ",", "$", "hex", "=", "true", ")", "{", "// if the string is empty", "if", "(", "empty", "(", "$", "s", ")", ")", "{", "// just return it", "return", "$", "s", ";", "}", "$", "s", "=", "(", "strin...
Makes the specified string XML-safe @param string $s @param boolean $hex Whether or not to make hexadecimal entities (as opposed to decimal) @return string The XML-safe result @author Dom Hastings @see http://www.w3.org/TR/REC-xml/#sec-predefined-ent
[ "Makes", "the", "specified", "string", "XML", "-", "safe" ]
6e10c5bacdbe355687ca1296782f647607cc9215
https://github.com/jbroadway/phpactiveresource/blob/6e10c5bacdbe355687ca1296782f647607cc9215/lib/ActiveResource/ActiveResource.php#L427-L509
train
jbroadway/phpactiveresource
lib/ActiveResource/ActiveResource.php
ActiveResource._fetch
public function _fetch ($url, $method, $params) { if (! extension_loaded ('curl')) { $this->error = 'cURL extension not loaded.'; return false; } $ch = curl_init (); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_MAXREDIRS, 3); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_VERBOSE, 0); curl_setopt ($ch, CURLOPT_HEADER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); /* HTTP Basic Authentication */ if ($this->user && $this->password) { curl_setopt ($ch, CURLOPT_USERPWD, $this->user . ":" . $this->password); } if ($this->request_format == 'xml') { $this->request_headers = array_merge ($this->request_headers, array ("Expect:", "Content-Type: text/xml", "Length: " . strlen ($params))); } switch ($method) { case 'POST': curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, $params); break; case 'DELETE': curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); break; case 'PUT': curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt ($ch, CURLOPT_POSTFIELDS, $params); break; case 'GET': default: break; } if (count ($this->request_headers)) { curl_setopt ($ch, CURLOPT_HTTPHEADER, $this->request_headers); } $res = curl_exec ($ch); $http_code = curl_getinfo ($ch, CURLINFO_HTTP_CODE); // Check HTTP status code for denied access if ($http_code == 401) { $this->errno = $http_code; $this->error = "HTTP Basic: Access denied."; curl_close ($ch); return false; } // Check HTTP status code for rate limit if ($http_code == 429) { if (preg_match ('/Retry-After: ([0-9]+)/', $res, $retry_after)) { sleep(intval($retry_after[1])); return $this->_fetch ($url, $method, $params); } $this->errno = $http_code; $this->error = "Too Many Requests"; curl_close ($ch); return false; } if (! $res) { $this->errno = curl_errno ($ch); $this->error = curl_error ($ch); curl_close ($ch); return false; } curl_close ($ch); return $res; }
php
public function _fetch ($url, $method, $params) { if (! extension_loaded ('curl')) { $this->error = 'cURL extension not loaded.'; return false; } $ch = curl_init (); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_MAXREDIRS, 3); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_VERBOSE, 0); curl_setopt ($ch, CURLOPT_HEADER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); /* HTTP Basic Authentication */ if ($this->user && $this->password) { curl_setopt ($ch, CURLOPT_USERPWD, $this->user . ":" . $this->password); } if ($this->request_format == 'xml') { $this->request_headers = array_merge ($this->request_headers, array ("Expect:", "Content-Type: text/xml", "Length: " . strlen ($params))); } switch ($method) { case 'POST': curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, $params); break; case 'DELETE': curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); break; case 'PUT': curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt ($ch, CURLOPT_POSTFIELDS, $params); break; case 'GET': default: break; } if (count ($this->request_headers)) { curl_setopt ($ch, CURLOPT_HTTPHEADER, $this->request_headers); } $res = curl_exec ($ch); $http_code = curl_getinfo ($ch, CURLINFO_HTTP_CODE); // Check HTTP status code for denied access if ($http_code == 401) { $this->errno = $http_code; $this->error = "HTTP Basic: Access denied."; curl_close ($ch); return false; } // Check HTTP status code for rate limit if ($http_code == 429) { if (preg_match ('/Retry-After: ([0-9]+)/', $res, $retry_after)) { sleep(intval($retry_after[1])); return $this->_fetch ($url, $method, $params); } $this->errno = $http_code; $this->error = "Too Many Requests"; curl_close ($ch); return false; } if (! $res) { $this->errno = curl_errno ($ch); $this->error = curl_error ($ch); curl_close ($ch); return false; } curl_close ($ch); return $res; }
[ "public", "function", "_fetch", "(", "$", "url", ",", "$", "method", ",", "$", "params", ")", "{", "if", "(", "!", "extension_loaded", "(", "'curl'", ")", ")", "{", "$", "this", "->", "error", "=", "'cURL extension not loaded.'", ";", "return", "false", ...
Fetch the specified request via cURL.
[ "Fetch", "the", "specified", "request", "via", "cURL", "." ]
6e10c5bacdbe355687ca1296782f647607cc9215
https://github.com/jbroadway/phpactiveresource/blob/6e10c5bacdbe355687ca1296782f647607cc9215/lib/ActiveResource/ActiveResource.php#L609-L688
train
jbroadway/phpactiveresource
lib/ActiveResource/ActiveResource.php
ActiveResource.set
public function set ($k, $v = false) { if (! $v && is_array ($k)) { foreach ($k as $key => $value) { $this->_data[$key] = $value; } } else { $this->_data[$k] = $v; } return $this; }
php
public function set ($k, $v = false) { if (! $v && is_array ($k)) { foreach ($k as $key => $value) { $this->_data[$key] = $value; } } else { $this->_data[$k] = $v; } return $this; }
[ "public", "function", "set", "(", "$", "k", ",", "$", "v", "=", "false", ")", "{", "if", "(", "!", "$", "v", "&&", "is_array", "(", "$", "k", ")", ")", "{", "foreach", "(", "$", "k", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "t...
Quick setter for chaining methods.
[ "Quick", "setter", "for", "chaining", "methods", "." ]
6e10c5bacdbe355687ca1296782f647607cc9215
https://github.com/jbroadway/phpactiveresource/blob/6e10c5bacdbe355687ca1296782f647607cc9215/lib/ActiveResource/ActiveResource.php#L714-L723
train
thelia/core
lib/Thelia/Module/BasePaymentModuleController.php
BasePaymentModuleController.getLog
protected function getLog() { if ($this->log == null) { $this->log = Tlog::getNewInstance(); $logFilePath = $this->getLogFilePath(); $this->log->setPrefix("#LEVEL: #DATE #HOUR: "); $this->log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationFile"); $this->log->setConfig("\\Thelia\\Log\\Destination\\TlogDestinationFile", 0, $logFilePath); $this->log->setLevel(Tlog::INFO); } return $this->log; }
php
protected function getLog() { if ($this->log == null) { $this->log = Tlog::getNewInstance(); $logFilePath = $this->getLogFilePath(); $this->log->setPrefix("#LEVEL: #DATE #HOUR: "); $this->log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationFile"); $this->log->setConfig("\\Thelia\\Log\\Destination\\TlogDestinationFile", 0, $logFilePath); $this->log->setLevel(Tlog::INFO); } return $this->log; }
[ "protected", "function", "getLog", "(", ")", "{", "if", "(", "$", "this", "->", "log", "==", "null", ")", "{", "$", "this", "->", "log", "=", "Tlog", "::", "getNewInstance", "(", ")", ";", "$", "logFilePath", "=", "$", "this", "->", "getLogFilePath",...
Returns the module-specific logger, initializing it if required. @return Tlog a Tlog instance
[ "Returns", "the", "module", "-", "specific", "logger", "initializing", "it", "if", "required", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Module/BasePaymentModuleController.php#L47-L61
train
thelia/core
lib/Thelia/Module/BasePaymentModuleController.php
BasePaymentModuleController.confirmPayment
public function confirmPayment($orderId) { try { $orderId = \intval($orderId); if (null !== $order = $this->getOrder($orderId)) { $this->getLog()->addInfo( $this->getTranslator()->trans( "Processing confirmation of order ref. %ref, ID %id", array('%ref' => $order->getRef(), '%id' => $order->getId()) ) ); $event = new OrderEvent($order); $event->setStatus(OrderStatusQuery::getPaidStatus()->getId()); $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); $this->getLog()->addInfo( $this->getTranslator()->trans( "Order ref. %ref, ID %id has been successfully paid.", array('%ref' => $order->getRef(), '%id' => $order->getId()) ) ); } } catch (\Exception $ex) { $this->getLog()->addError( $this->getTranslator()->trans( "Error occured while processing order ref. %ref, ID %id: %err", array( '%err' => $ex->getMessage(), '%ref' => !isset($order) ? "?" : $order->getRef(), '%id' => !isset($order) ? "?" : $order->getId() ) ) ); throw $ex; } }
php
public function confirmPayment($orderId) { try { $orderId = \intval($orderId); if (null !== $order = $this->getOrder($orderId)) { $this->getLog()->addInfo( $this->getTranslator()->trans( "Processing confirmation of order ref. %ref, ID %id", array('%ref' => $order->getRef(), '%id' => $order->getId()) ) ); $event = new OrderEvent($order); $event->setStatus(OrderStatusQuery::getPaidStatus()->getId()); $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); $this->getLog()->addInfo( $this->getTranslator()->trans( "Order ref. %ref, ID %id has been successfully paid.", array('%ref' => $order->getRef(), '%id' => $order->getId()) ) ); } } catch (\Exception $ex) { $this->getLog()->addError( $this->getTranslator()->trans( "Error occured while processing order ref. %ref, ID %id: %err", array( '%err' => $ex->getMessage(), '%ref' => !isset($order) ? "?" : $order->getRef(), '%id' => !isset($order) ? "?" : $order->getId() ) ) ); throw $ex; } }
[ "public", "function", "confirmPayment", "(", "$", "orderId", ")", "{", "try", "{", "$", "orderId", "=", "\\", "intval", "(", "$", "orderId", ")", ";", "if", "(", "null", "!==", "$", "order", "=", "$", "this", "->", "getOrder", "(", "$", "orderId", ...
Process the confirmation of an order. This method should be called once the module has performed the required checks to confirm a valid payment. @param int $orderId the order ID @throws \Exception
[ "Process", "the", "confirmation", "of", "an", "order", ".", "This", "method", "should", "be", "called", "once", "the", "module", "has", "performed", "the", "required", "checks", "to", "confirm", "a", "valid", "payment", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Module/BasePaymentModuleController.php#L78-L118
train
thelia/core
lib/Thelia/Module/BasePaymentModuleController.php
BasePaymentModuleController.getOrder
protected function getOrder($orderId) { if (null == $order = OrderQuery::create()->findPk($orderId)) { $this->getLog()->addError( $this->getTranslator()->trans("Unknown order ID: %id", array('%id' => $orderId)) ); } return $order; }
php
protected function getOrder($orderId) { if (null == $order = OrderQuery::create()->findPk($orderId)) { $this->getLog()->addError( $this->getTranslator()->trans("Unknown order ID: %id", array('%id' => $orderId)) ); } return $order; }
[ "protected", "function", "getOrder", "(", "$", "orderId", ")", "{", "if", "(", "null", "==", "$", "order", "=", "OrderQuery", "::", "create", "(", ")", "->", "findPk", "(", "$", "orderId", ")", ")", "{", "$", "this", "->", "getLog", "(", ")", "->",...
Get an order and issue a log message if not found. @param $orderId @return null|\Thelia\Model\Order
[ "Get", "an", "order", "and", "issue", "a", "log", "message", "if", "not", "found", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Module/BasePaymentModuleController.php#L220-L229
train
thelia/core
lib/Thelia/Module/BasePaymentModuleController.php
BasePaymentModuleController.redirectToSuccessPage
public function redirectToSuccessPage($orderId) { $this->getLog()->addInfo("Redirecting customer to payment success page"); throw new RedirectException( $this->retrieveUrlFromRouteId( 'order.placed', [], [ 'order_id' => $orderId ], Router::ABSOLUTE_PATH ) ); }
php
public function redirectToSuccessPage($orderId) { $this->getLog()->addInfo("Redirecting customer to payment success page"); throw new RedirectException( $this->retrieveUrlFromRouteId( 'order.placed', [], [ 'order_id' => $orderId ], Router::ABSOLUTE_PATH ) ); }
[ "public", "function", "redirectToSuccessPage", "(", "$", "orderId", ")", "{", "$", "this", "->", "getLog", "(", ")", "->", "addInfo", "(", "\"Redirecting customer to payment success page\"", ")", ";", "throw", "new", "RedirectException", "(", "$", "this", "->", ...
Redirect the customer to the successful payment page. @param int $orderId the order ID
[ "Redirect", "the", "customer", "to", "the", "successful", "payment", "page", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Module/BasePaymentModuleController.php#L236-L250
train