repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
thelia/core | lib/Thelia/Action/Message.php | Message.modify | public function modify(MessageUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $message = MessageQuery::create()->findPk($event->getMessageId())) {
$message
->setDispatcher($dispatcher)
->setName($event->getMessageName())
->setSecured($event->getSecured())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setSubject($event->getSubject())
->setHtmlMessage($event->getHtmlMessage())
->setTextMessage($event->getTextMessage())
->setHtmlLayoutFileName($event->getHtmlLayoutFileName())
->setHtmlTemplateFileName($event->getHtmlTemplateFileName())
->setTextLayoutFileName($event->getTextLayoutFileName())
->setTextTemplateFileName($event->getTextTemplateFileName())
->save();
$event->setMessage($message);
}
} | php | public function modify(MessageUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $message = MessageQuery::create()->findPk($event->getMessageId())) {
$message
->setDispatcher($dispatcher)
->setName($event->getMessageName())
->setSecured($event->getSecured())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setSubject($event->getSubject())
->setHtmlMessage($event->getHtmlMessage())
->setTextMessage($event->getTextMessage())
->setHtmlLayoutFileName($event->getHtmlLayoutFileName())
->setHtmlTemplateFileName($event->getHtmlTemplateFileName())
->setTextLayoutFileName($event->getTextLayoutFileName())
->setTextTemplateFileName($event->getTextTemplateFileName())
->save();
$event->setMessage($message);
}
} | [
"public",
"function",
"modify",
"(",
"MessageUpdateEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"message",
"=",
"MessageQuery",
"::",
"create",
"(",
")",
"->",
"find... | Change a message
@param \Thelia\Core\Event\Message\MessageUpdateEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Change",
"a",
"message"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Message.php#L58-L84 | train |
thelia/core | lib/Thelia/Action/Message.php | Message.delete | public function delete(MessageDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== ($message = MessageQuery::create()->findPk($event->getMessageId()))) {
$message
->setDispatcher($dispatcher)
->delete()
;
$event->setMessage($message);
}
} | php | public function delete(MessageDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== ($message = MessageQuery::create()->findPk($event->getMessageId()))) {
$message
->setDispatcher($dispatcher)
->delete()
;
$event->setMessage($message);
}
} | [
"public",
"function",
"delete",
"(",
"MessageDeleteEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"message",
"=",
"MessageQuery",
"::",
"create",
"(",
")",
"->",
... | Delete a messageuration entry
@param \Thelia\Core\Event\Message\MessageDeleteEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Delete",
"a",
"messageuration",
"entry"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Message.php#L93-L103 | train |
thelia/core | lib/Thelia/Condition/Implementation/ConditionAbstract.php | ConditionAbstract.getValidators | public function getValidators()
{
$this->validators = $this->generateInputs();
$translatedInputs = [];
foreach ($this->validators as $key => $validator) {
$translatedOperators = [];
foreach ($validator['availableOperators'] as $availableOperators) {
$translatedOperators[$availableOperators] = Operators::getI18n(
$this->translator,
$availableOperators
);
}
$validator['availableOperators'] = $translatedOperators;
$translatedInputs[$key] = $validator;
}
$validators = [
'inputs' => $translatedInputs,
'setOperators' => $this->operators,
'setValues' => $this->values
];
return $validators;
} | php | public function getValidators()
{
$this->validators = $this->generateInputs();
$translatedInputs = [];
foreach ($this->validators as $key => $validator) {
$translatedOperators = [];
foreach ($validator['availableOperators'] as $availableOperators) {
$translatedOperators[$availableOperators] = Operators::getI18n(
$this->translator,
$availableOperators
);
}
$validator['availableOperators'] = $translatedOperators;
$translatedInputs[$key] = $validator;
}
$validators = [
'inputs' => $translatedInputs,
'setOperators' => $this->operators,
'setValues' => $this->values
];
return $validators;
} | [
"public",
"function",
"getValidators",
"(",
")",
"{",
"$",
"this",
"->",
"validators",
"=",
"$",
"this",
"->",
"generateInputs",
"(",
")",
";",
"$",
"translatedInputs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"validators",
"as",
"$",
"ke... | Return all validators
@return array | [
"Return",
"all",
"validators"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/Implementation/ConditionAbstract.php#L98-L126 | train |
thelia/core | lib/Thelia/Condition/Implementation/ConditionAbstract.php | ConditionAbstract.getSerializableCondition | public function getSerializableCondition()
{
$serializableCondition = new SerializableCondition();
$serializableCondition->conditionServiceId = $this->getServiceId();
$serializableCondition->operators = $this->operators;
$serializableCondition->values = $this->values;
return $serializableCondition;
} | php | public function getSerializableCondition()
{
$serializableCondition = new SerializableCondition();
$serializableCondition->conditionServiceId = $this->getServiceId();
$serializableCondition->operators = $this->operators;
$serializableCondition->values = $this->values;
return $serializableCondition;
} | [
"public",
"function",
"getSerializableCondition",
"(",
")",
"{",
"$",
"serializableCondition",
"=",
"new",
"SerializableCondition",
"(",
")",
";",
"$",
"serializableCondition",
"->",
"conditionServiceId",
"=",
"$",
"this",
"->",
"getServiceId",
"(",
")",
";",
"$",... | Return a serializable Condition
@return SerializableCondition | [
"Return",
"a",
"serializable",
"Condition"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/Implementation/ConditionAbstract.php#L173-L182 | train |
thelia/core | lib/Thelia/Condition/Implementation/ConditionAbstract.php | ConditionAbstract.isCurrencyValid | protected function isCurrencyValid($currencyValue)
{
$availableCurrencies = $this->facade->getAvailableCurrencies();
/** @var Currency $currency */
$currencyFound = false;
foreach ($availableCurrencies as $currency) {
if ($currencyValue == $currency->getCode()) {
$currencyFound = true;
}
}
if (!$currencyFound) {
throw new InvalidConditionValueException(
\get_class(),
'currency'
);
}
return true;
} | php | protected function isCurrencyValid($currencyValue)
{
$availableCurrencies = $this->facade->getAvailableCurrencies();
/** @var Currency $currency */
$currencyFound = false;
foreach ($availableCurrencies as $currency) {
if ($currencyValue == $currency->getCode()) {
$currencyFound = true;
}
}
if (!$currencyFound) {
throw new InvalidConditionValueException(
\get_class(),
'currency'
);
}
return true;
} | [
"protected",
"function",
"isCurrencyValid",
"(",
"$",
"currencyValue",
")",
"{",
"$",
"availableCurrencies",
"=",
"$",
"this",
"->",
"facade",
"->",
"getAvailableCurrencies",
"(",
")",
";",
"/** @var Currency $currency */",
"$",
"currencyFound",
"=",
"false",
";",
... | Check if currency if valid or not
@param string $currencyValue Currency EUR|USD|..
@return bool
@throws \Thelia\Exception\InvalidConditionValueException | [
"Check",
"if",
"currency",
"if",
"valid",
"or",
"not"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/Implementation/ConditionAbstract.php#L192-L210 | train |
thelia/core | lib/Thelia/Condition/Implementation/ConditionAbstract.php | ConditionAbstract.isPriceValid | protected function isPriceValid($priceValue)
{
$floatType = new FloatType();
if (!$floatType->isValid($priceValue) || $priceValue <= 0) {
throw new InvalidConditionValueException(
\get_class(),
'price'
);
}
return true;
} | php | protected function isPriceValid($priceValue)
{
$floatType = new FloatType();
if (!$floatType->isValid($priceValue) || $priceValue <= 0) {
throw new InvalidConditionValueException(
\get_class(),
'price'
);
}
return true;
} | [
"protected",
"function",
"isPriceValid",
"(",
"$",
"priceValue",
")",
"{",
"$",
"floatType",
"=",
"new",
"FloatType",
"(",
")",
";",
"if",
"(",
"!",
"$",
"floatType",
"->",
"isValid",
"(",
"$",
"priceValue",
")",
"||",
"$",
"priceValue",
"<=",
"0",
")"... | Check if price is valid
@param float $priceValue Price value to check
@return bool
@throws \Thelia\Exception\InvalidConditionValueException | [
"Check",
"if",
"price",
"is",
"valid"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/Implementation/ConditionAbstract.php#L220-L231 | train |
thelia/core | lib/Thelia/Condition/Implementation/ConditionAbstract.php | ConditionAbstract.drawBackOfficeInputOperators | protected function drawBackOfficeInputOperators($inputKey)
{
$html = '';
$inputs = $this->getValidators();
if (isset($inputs['inputs'][$inputKey])) {
$html = $this->facade->getParser()->render(
'coupon/condition-fragments/condition-selector.html',
[
'operators' => $inputs['inputs'][$inputKey]['availableOperators'],
'value' => isset($this->operators[$inputKey]) ? $this->operators[$inputKey] : '',
'inputKey' => $inputKey
]
);
}
return $html;
} | php | protected function drawBackOfficeInputOperators($inputKey)
{
$html = '';
$inputs = $this->getValidators();
if (isset($inputs['inputs'][$inputKey])) {
$html = $this->facade->getParser()->render(
'coupon/condition-fragments/condition-selector.html',
[
'operators' => $inputs['inputs'][$inputKey]['availableOperators'],
'value' => isset($this->operators[$inputKey]) ? $this->operators[$inputKey] : '',
'inputKey' => $inputKey
]
);
}
return $html;
} | [
"protected",
"function",
"drawBackOfficeInputOperators",
"(",
"$",
"inputKey",
")",
"{",
"$",
"html",
"=",
"''",
";",
"$",
"inputs",
"=",
"$",
"this",
"->",
"getValidators",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"inputs",
"[",
"'inputs'",
"]",
"... | Draw the operator input displayed in the BackOffice
allowing Admin to set its Coupon Conditions
@param string $inputKey Input key (ex: self::INPUT1)
@return string HTML string | [
"Draw",
"the",
"operator",
"input",
"displayed",
"in",
"the",
"BackOffice",
"allowing",
"Admin",
"to",
"set",
"its",
"Coupon",
"Conditions"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/Implementation/ConditionAbstract.php#L241-L259 | train |
thelia/core | lib/Thelia/Condition/Implementation/ConditionAbstract.php | ConditionAbstract.drawBackOfficeBaseInputsText | protected function drawBackOfficeBaseInputsText($label, $inputKey)
{
$operatorSelectHtml = $this->drawBackOfficeInputOperators($inputKey);
$currentValue = '';
if (isset($this->values) && isset($this->values[$inputKey])) {
$currentValue = $this->values[$inputKey];
}
return $this->facade->getParser()->render(
'coupon/conditions-fragments/base-input-text.html',
[
'label' => $label,
'inputKey' => $inputKey,
'currentValue' => $currentValue,
'operatorSelectHtml' => $operatorSelectHtml
]
);
} | php | protected function drawBackOfficeBaseInputsText($label, $inputKey)
{
$operatorSelectHtml = $this->drawBackOfficeInputOperators($inputKey);
$currentValue = '';
if (isset($this->values) && isset($this->values[$inputKey])) {
$currentValue = $this->values[$inputKey];
}
return $this->facade->getParser()->render(
'coupon/conditions-fragments/base-input-text.html',
[
'label' => $label,
'inputKey' => $inputKey,
'currentValue' => $currentValue,
'operatorSelectHtml' => $operatorSelectHtml
]
);
} | [
"protected",
"function",
"drawBackOfficeBaseInputsText",
"(",
"$",
"label",
",",
"$",
"inputKey",
")",
"{",
"$",
"operatorSelectHtml",
"=",
"$",
"this",
"->",
"drawBackOfficeInputOperators",
"(",
"$",
"inputKey",
")",
";",
"$",
"currentValue",
"=",
"''",
";",
... | Draw the base input displayed in the BackOffice
allowing Admin to set its Coupon Conditions
@param string $label I18n input label
@param string $inputKey Input key (ex: self::INPUT1)
@return string HTML string | [
"Draw",
"the",
"base",
"input",
"displayed",
"in",
"the",
"BackOffice",
"allowing",
"Admin",
"to",
"set",
"its",
"Coupon",
"Conditions"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/Implementation/ConditionAbstract.php#L270-L288 | train |
thelia/core | lib/Thelia/Condition/Implementation/ConditionAbstract.php | ConditionAbstract.drawBackOfficeInputQuantityValues | protected function drawBackOfficeInputQuantityValues($inputKey, $max = 10, $min = 0)
{
return $this->facade->getParser()->render(
'coupon/condition-fragments/quantity-selector.html',
[
'min' => $min,
'max' => $max,
'value' => isset($this->values[$inputKey]) ? $this->values[$inputKey] : '',
'inputKey' => $inputKey
]
);
} | php | protected function drawBackOfficeInputQuantityValues($inputKey, $max = 10, $min = 0)
{
return $this->facade->getParser()->render(
'coupon/condition-fragments/quantity-selector.html',
[
'min' => $min,
'max' => $max,
'value' => isset($this->values[$inputKey]) ? $this->values[$inputKey] : '',
'inputKey' => $inputKey
]
);
} | [
"protected",
"function",
"drawBackOfficeInputQuantityValues",
"(",
"$",
"inputKey",
",",
"$",
"max",
"=",
"10",
",",
"$",
"min",
"=",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"facade",
"->",
"getParser",
"(",
")",
"->",
"render",
"(",
"'coupon/condition... | Draw the quantity input displayed in the BackOffice
allowing Admin to set its Coupon Conditions
@param string $inputKey Input key (ex: self::INPUT1)
@param int $max Maximum selectable
@param int $min Minimum selectable
@return string HTML string | [
"Draw",
"the",
"quantity",
"input",
"displayed",
"in",
"the",
"BackOffice",
"allowing",
"Admin",
"to",
"set",
"its",
"Coupon",
"Conditions"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/Implementation/ConditionAbstract.php#L300-L311 | train |
thelia/core | lib/Thelia/Condition/Implementation/ConditionAbstract.php | ConditionAbstract.drawBackOfficeCurrencyInput | protected function drawBackOfficeCurrencyInput($inputKey)
{
$currencies = CurrencyQuery::create()->find();
$cleanedCurrencies = [];
/** @var Currency $currency */
foreach ($currencies as $currency) {
$cleanedCurrencies[$currency->getCode()] = $currency->getSymbol();
}
return $this->facade->getParser()->render(
'coupon/condition-fragments/currency-selector.html',
[
'currencies' => $cleanedCurrencies,
'value' => isset($this->values[$inputKey]) ? $this->values[$inputKey] : '',
'inputKey' => $inputKey
]
);
} | php | protected function drawBackOfficeCurrencyInput($inputKey)
{
$currencies = CurrencyQuery::create()->find();
$cleanedCurrencies = [];
/** @var Currency $currency */
foreach ($currencies as $currency) {
$cleanedCurrencies[$currency->getCode()] = $currency->getSymbol();
}
return $this->facade->getParser()->render(
'coupon/condition-fragments/currency-selector.html',
[
'currencies' => $cleanedCurrencies,
'value' => isset($this->values[$inputKey]) ? $this->values[$inputKey] : '',
'inputKey' => $inputKey
]
);
} | [
"protected",
"function",
"drawBackOfficeCurrencyInput",
"(",
"$",
"inputKey",
")",
"{",
"$",
"currencies",
"=",
"CurrencyQuery",
"::",
"create",
"(",
")",
"->",
"find",
"(",
")",
";",
"$",
"cleanedCurrencies",
"=",
"[",
"]",
";",
"/** @var Currency $currency */"... | Draw the currency input displayed in the BackOffice
allowing Admin to set its Coupon Conditions
@param string $inputKey Input key (ex: self::INPUT1)
@return string HTML string | [
"Draw",
"the",
"currency",
"input",
"displayed",
"in",
"the",
"BackOffice",
"allowing",
"Admin",
"to",
"set",
"its",
"Coupon",
"Conditions"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Condition/Implementation/ConditionAbstract.php#L321-L340 | train |
BoldGrid/library | src/Library/Notice.php | Notice.setClass | private function setClass( $name, $args ) {
// Build the class string dynamically.
$class = __NAMESPACE__ . '\\Notice\\' . ucfirst( $name );
// Create a new instance or add our filters.
return $this->class = class_exists( $class ) ? new $class( $args ) : Filter::add( $this );
} | php | private function setClass( $name, $args ) {
// Build the class string dynamically.
$class = __NAMESPACE__ . '\\Notice\\' . ucfirst( $name );
// Create a new instance or add our filters.
return $this->class = class_exists( $class ) ? new $class( $args ) : Filter::add( $this );
} | [
"private",
"function",
"setClass",
"(",
"$",
"name",
",",
"$",
"args",
")",
"{",
"// Build the class string dynamically.",
"$",
"class",
"=",
"__NAMESPACE__",
".",
"'\\\\Notice\\\\'",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"// Create a new instance or add our f... | Sets the class class property.
@since 1.0.0
@param string $name Name of the notice class to initialize.
@param array $args Optional arguments to pass to the class initialization.
@return string $class The class class property. | [
"Sets",
"the",
"class",
"class",
"property",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Notice.php#L62-L69 | train |
BoldGrid/library | src/Library/Notice.php | Notice.show | public static function show( $message, $id, $class = "notice notice-warning" ) {
$nonce = wp_nonce_field( 'boldgrid_set_key', 'set_key_auth', true, false );
if( self::isDismissed( $id ) ) {
return;
}
printf( '<div class="%1$s boldgrid-notice is-dismissible" data-notice-id="%2$s">%3$s%4$s</div>',
$class,
$id,
$message,
$nonce
);
/*
* Enqueue js required to allow for notices to be dismissed permanently.
*
* When notices (such as the "keyPrompt" notice) are shown by creating a new instance of
* this class, the js is enqueued by the Filter::add call in the constructor. We do however
* allow notices to be shown via this static method, and so we need to enqueue the js now.
*/
self::enqueue();
} | php | public static function show( $message, $id, $class = "notice notice-warning" ) {
$nonce = wp_nonce_field( 'boldgrid_set_key', 'set_key_auth', true, false );
if( self::isDismissed( $id ) ) {
return;
}
printf( '<div class="%1$s boldgrid-notice is-dismissible" data-notice-id="%2$s">%3$s%4$s</div>',
$class,
$id,
$message,
$nonce
);
/*
* Enqueue js required to allow for notices to be dismissed permanently.
*
* When notices (such as the "keyPrompt" notice) are shown by creating a new instance of
* this class, the js is enqueued by the Filter::add call in the constructor. We do however
* allow notices to be shown via this static method, and so we need to enqueue the js now.
*/
self::enqueue();
} | [
"public",
"static",
"function",
"show",
"(",
"$",
"message",
",",
"$",
"id",
",",
"$",
"class",
"=",
"\"notice notice-warning\"",
")",
"{",
"$",
"nonce",
"=",
"wp_nonce_field",
"(",
"'boldgrid_set_key'",
",",
"'set_key_auth'",
",",
"true",
",",
"false",
")",... | Show an admin notice.
At one point we had this method running on the following hook:
Boldgrid\Libary\Notice\show. Because several different notices are
instantiating this class (such as the keyPrompt and ClaimPremiumKey notices),
the hook was being added more than once, causing duplicate admin notices
to show.
@since 2.2.0
@param string $message
@param string $id
@param string $class | [
"Show",
"an",
"admin",
"notice",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Notice.php#L86-L108 | train |
BoldGrid/library | src/Library/Notice.php | Notice.add | public function add( $name = null ) {
$name = $name ? $name : $this->getName();
$path = __DIR__;
$name = ucfirst( $name );
include "{$path}/Views/{$name}.php";
} | php | public function add( $name = null ) {
$name = $name ? $name : $this->getName();
$path = __DIR__;
$name = ucfirst( $name );
include "{$path}/Views/{$name}.php";
} | [
"public",
"function",
"add",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"name",
"?",
"$",
"name",
":",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"$",
"path",
"=",
"__DIR__",
";",
"$",
"name",
"=",
"ucfirst",
"(",
"$",
... | Displays the license notice in the WordPress admin.
@since 1.0.0
@nohook: admin_notices | [
"Displays",
"the",
"license",
"notice",
"in",
"the",
"WordPress",
"admin",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Notice.php#L117-L122 | train |
BoldGrid/library | src/Library/Notice.php | Notice.dismiss | public function dismiss() {
// Validate nonce.
if ( isset( $_POST['set_key_auth'] ) && check_ajax_referer( 'boldgrid_set_key', 'set_key_auth', false ) ) {
$id = sanitize_key( $_POST['notice'] );
// Mark the notice as dismissed, if not already done so.
$dismissal = array(
'id' => $id,
'timestamp' => time(),
);
if ( ! Notice::isDismissed( $id ) ) {
add_user_meta( get_current_user_id(), 'boldgrid_dismissed_admin_notices', $dismissal );
}
}
} | php | public function dismiss() {
// Validate nonce.
if ( isset( $_POST['set_key_auth'] ) && check_ajax_referer( 'boldgrid_set_key', 'set_key_auth', false ) ) {
$id = sanitize_key( $_POST['notice'] );
// Mark the notice as dismissed, if not already done so.
$dismissal = array(
'id' => $id,
'timestamp' => time(),
);
if ( ! Notice::isDismissed( $id ) ) {
add_user_meta( get_current_user_id(), 'boldgrid_dismissed_admin_notices', $dismissal );
}
}
} | [
"public",
"function",
"dismiss",
"(",
")",
"{",
"// Validate nonce.",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'set_key_auth'",
"]",
")",
"&&",
"check_ajax_referer",
"(",
"'boldgrid_set_key'",
",",
"'set_key_auth'",
",",
"false",
")",
")",
"{",
"$",
"id"... | Handle dismissal of the key prompt notice.
@since 2.1.0
@see \Boldgrid\Library\Library\Notice::isDismissed()
@uses $_POST['notice'] Notice id.
@hook: wp_ajax_dismissBoldgridNotice | [
"Handle",
"dismissal",
"of",
"the",
"key",
"prompt",
"notice",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Notice.php#L157-L172 | train |
BoldGrid/library | src/Library/Notice.php | Notice.undismiss | public function undismiss() {
// Validate nonce.
if ( isset( $_POST['set_key_auth'] ) && ! empty( $_POST['notice'] ) && check_ajax_referer( 'boldgrid_set_key', 'set_key_auth', false ) ) {
$id = sanitize_key( $_POST['notice'] );
// Get all of the notices this user has dismissed.
$dismissals = get_user_meta( get_current_user_id(), 'boldgrid_dismissed_admin_notices' );
// Loop through all of the dismissed notices. If we find the dismissal, then remove it.
foreach ( $dismissals as $dismissal ) {
if ( $id === $dismissal['id'] ) {
delete_user_meta( get_current_user_id(), 'boldgrid_dismissed_admin_notices', $dismissal );
break;
}
}
}
} | php | public function undismiss() {
// Validate nonce.
if ( isset( $_POST['set_key_auth'] ) && ! empty( $_POST['notice'] ) && check_ajax_referer( 'boldgrid_set_key', 'set_key_auth', false ) ) {
$id = sanitize_key( $_POST['notice'] );
// Get all of the notices this user has dismissed.
$dismissals = get_user_meta( get_current_user_id(), 'boldgrid_dismissed_admin_notices' );
// Loop through all of the dismissed notices. If we find the dismissal, then remove it.
foreach ( $dismissals as $dismissal ) {
if ( $id === $dismissal['id'] ) {
delete_user_meta( get_current_user_id(), 'boldgrid_dismissed_admin_notices', $dismissal );
break;
}
}
}
} | [
"public",
"function",
"undismiss",
"(",
")",
"{",
"// Validate nonce.",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'set_key_auth'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"_POST",
"[",
"'notice'",
"]",
")",
"&&",
"check_ajax_referer",
"(",
"'boldgrid_se... | Handle undismissal of the key prompt notice.
@since 2.1.0
@uses $_POST['notice'] Notice id.
@hook: wp_ajax_undismissBoldgridNotice | [
"Handle",
"undismissal",
"of",
"the",
"key",
"prompt",
"notice",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Notice.php#L183-L199 | train |
BoldGrid/library | src/Library/Notice.php | Notice.isDismissed | public static function isDismissed( $id ) {
$dismissed = false;
$id = sanitize_key( $id );
// Get all of the notices this user has dismissed.
$dismissals = get_user_meta( get_current_user_id(), 'boldgrid_dismissed_admin_notices' );
// Loop through all of the dismissed notices. If we find our $id, then mark bool and break.
foreach ( $dismissals as $dismissal ) {
if ( $id === $dismissal['id'] ) {
$dismissed = true;
break;
}
}
return $dismissed;
} | php | public static function isDismissed( $id ) {
$dismissed = false;
$id = sanitize_key( $id );
// Get all of the notices this user has dismissed.
$dismissals = get_user_meta( get_current_user_id(), 'boldgrid_dismissed_admin_notices' );
// Loop through all of the dismissed notices. If we find our $id, then mark bool and break.
foreach ( $dismissals as $dismissal ) {
if ( $id === $dismissal['id'] ) {
$dismissed = true;
break;
}
}
return $dismissed;
} | [
"public",
"static",
"function",
"isDismissed",
"(",
"$",
"id",
")",
"{",
"$",
"dismissed",
"=",
"false",
";",
"$",
"id",
"=",
"sanitize_key",
"(",
"$",
"id",
")",
";",
"// Get all of the notices this user has dismissed.",
"$",
"dismissals",
"=",
"get_user_meta",... | Is there a user dismissal record for a particular admin notice id?
@since 2.1.0
@static
@param string $id An admin notice id.
@return bool | [
"Is",
"there",
"a",
"user",
"dismissal",
"record",
"for",
"a",
"particular",
"admin",
"notice",
"id?"
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Notice.php#L211-L227 | train |
thelia/core | lib/Thelia/Install/CheckPermission.php | CheckPermission.exec | public function exec()
{
if (version_compare(phpversion(), '5.5', '<')) {
$this->validationMessages['php_version']['text'] = $this->getI18nPhpVersionText('5.5', phpversion(), false);
$this->validationMessages['php_version']['status'] = false;
$this->validationMessages['php_version']['hint'] = $this->getI18nPhpVersionHint();
}
foreach ($this->directoriesToBeWritable as $directory) {
$fullDirectory = THELIA_ROOT . $directory;
$this->validationMessages[$directory]['text'] = $this->getI18nDirectoryText($fullDirectory, true);
if (is_writable($fullDirectory) === false) {
if (!$this->makeDirectoryWritable($fullDirectory)) {
$this->isValid = false;
$this->validationMessages[$directory]['status'] = false;
$this->validationMessages[$directory]['text'] = $this->getI18nDirectoryText($fullDirectory, false);
}
}
}
foreach ($this->minServerConfigurationNecessary as $key => $value) {
$this->validationMessages[$key]['text'] = $this->getI18nConfigText($key, $this->formatBytes($value), ini_get($key), true);
if (!$this->verifyServerMemoryValues($key, $value)) {
$this->isValid = false;
$this->validationMessages[$key]['status'] = false;
$this->validationMessages[$key]['text'] = $this->getI18nConfigText($key, $this->formatBytes($value), ini_get($key), false);
;
}
}
foreach ($this->extensions as $extension) {
$this->validationMessages[$extension]['text'] = $this->getI18nExtensionText($extension, true);
if (false === extension_loaded($extension)) {
$this->isValid = false;
$this->validationMessages[$extension]['status'] = false;
$this->validationMessages[$extension]['text'] = $this->getI18nExtensionText($extension, false);
}
}
return $this->isValid;
} | php | public function exec()
{
if (version_compare(phpversion(), '5.5', '<')) {
$this->validationMessages['php_version']['text'] = $this->getI18nPhpVersionText('5.5', phpversion(), false);
$this->validationMessages['php_version']['status'] = false;
$this->validationMessages['php_version']['hint'] = $this->getI18nPhpVersionHint();
}
foreach ($this->directoriesToBeWritable as $directory) {
$fullDirectory = THELIA_ROOT . $directory;
$this->validationMessages[$directory]['text'] = $this->getI18nDirectoryText($fullDirectory, true);
if (is_writable($fullDirectory) === false) {
if (!$this->makeDirectoryWritable($fullDirectory)) {
$this->isValid = false;
$this->validationMessages[$directory]['status'] = false;
$this->validationMessages[$directory]['text'] = $this->getI18nDirectoryText($fullDirectory, false);
}
}
}
foreach ($this->minServerConfigurationNecessary as $key => $value) {
$this->validationMessages[$key]['text'] = $this->getI18nConfigText($key, $this->formatBytes($value), ini_get($key), true);
if (!$this->verifyServerMemoryValues($key, $value)) {
$this->isValid = false;
$this->validationMessages[$key]['status'] = false;
$this->validationMessages[$key]['text'] = $this->getI18nConfigText($key, $this->formatBytes($value), ini_get($key), false);
;
}
}
foreach ($this->extensions as $extension) {
$this->validationMessages[$extension]['text'] = $this->getI18nExtensionText($extension, true);
if (false === extension_loaded($extension)) {
$this->isValid = false;
$this->validationMessages[$extension]['status'] = false;
$this->validationMessages[$extension]['text'] = $this->getI18nExtensionText($extension, false);
}
}
return $this->isValid;
} | [
"public",
"function",
"exec",
"(",
")",
"{",
"if",
"(",
"version_compare",
"(",
"phpversion",
"(",
")",
",",
"'5.5'",
",",
"'<'",
")",
")",
"{",
"$",
"this",
"->",
"validationMessages",
"[",
"'php_version'",
"]",
"[",
"'text'",
"]",
"=",
"$",
"this",
... | Perform file permission check
@return bool | [
"Perform",
"file",
"permission",
"check"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Install/CheckPermission.php#L120-L160 | train |
thelia/core | lib/Thelia/Install/CheckPermission.php | CheckPermission.getI18nDirectoryText | protected function getI18nDirectoryText($directory, $isValid)
{
if ($this->translator !== null) {
if ($isValid) {
$sentence = 'The directory %directory% is writable';
} else {
$sentence = 'The directory %directory% is not writable';
}
$translatedText = $this->translator->trans(
$sentence,
array(
'%directory%' => $directory
)
);
} else {
$translatedText = sprintf('The directory %s should be writable', $directory);
}
return $translatedText;
} | php | protected function getI18nDirectoryText($directory, $isValid)
{
if ($this->translator !== null) {
if ($isValid) {
$sentence = 'The directory %directory% is writable';
} else {
$sentence = 'The directory %directory% is not writable';
}
$translatedText = $this->translator->trans(
$sentence,
array(
'%directory%' => $directory
)
);
} else {
$translatedText = sprintf('The directory %s should be writable', $directory);
}
return $translatedText;
} | [
"protected",
"function",
"getI18nDirectoryText",
"(",
"$",
"directory",
",",
"$",
"isValid",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"translator",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"isValid",
")",
"{",
"$",
"sentence",
"=",
"'The directory %director... | Get Translated text about the directory state
@param string $directory Directory being checked
@param bool $isValid If directory permission is valid
@return string | [
"Get",
"Translated",
"text",
"about",
"the",
"directory",
"state"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Install/CheckPermission.php#L192-L212 | train |
thelia/core | lib/Thelia/Install/CheckPermission.php | CheckPermission.getI18nConfigText | protected function getI18nConfigText($key, $expectedValue, $currentValue, $isValid)
{
if ($isValid) {
$sentence = 'The PHP "%key%" configuration value (currently %currentValue%) is correct (%expectedValue% required).';
} else {
$sentence = 'The PHP "%key%" configuration value (currently %currentValue%) is below minimal requirements to run Thelia2 (%expectedValue% required).';
}
$translatedText = $this->translator->trans(
$sentence,
array(
'%key%' => $key,
'%expectedValue%' => $expectedValue,
'%currentValue%' => $currentValue,
),
'install-wizard'
);
return $translatedText;
} | php | protected function getI18nConfigText($key, $expectedValue, $currentValue, $isValid)
{
if ($isValid) {
$sentence = 'The PHP "%key%" configuration value (currently %currentValue%) is correct (%expectedValue% required).';
} else {
$sentence = 'The PHP "%key%" configuration value (currently %currentValue%) is below minimal requirements to run Thelia2 (%expectedValue% required).';
}
$translatedText = $this->translator->trans(
$sentence,
array(
'%key%' => $key,
'%expectedValue%' => $expectedValue,
'%currentValue%' => $currentValue,
),
'install-wizard'
);
return $translatedText;
} | [
"protected",
"function",
"getI18nConfigText",
"(",
"$",
"key",
",",
"$",
"expectedValue",
",",
"$",
"currentValue",
",",
"$",
"isValid",
")",
"{",
"if",
"(",
"$",
"isValid",
")",
"{",
"$",
"sentence",
"=",
"'The PHP \"%key%\" configuration value (currently %curren... | Get Translated text about the directory state
Not usable with CLI
@param string $key .ini file key
@param string $expectedValue Expected server value
@param string $currentValue Actual server value
@param bool $isValid If server configuration is valid
@return string | [
"Get",
"Translated",
"text",
"about",
"the",
"directory",
"state",
"Not",
"usable",
"with",
"CLI"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Install/CheckPermission.php#L238-L257 | train |
thelia/core | lib/Thelia/Install/CheckPermission.php | CheckPermission.getI18nPhpVersionText | protected function getI18nPhpVersionText($expectedValue, $currentValue, $isValid)
{
if ($this->translator !== null) {
if ($isValid) {
$sentence = 'PHP version %currentValue% matches the minimum required (PHP %expectedValue%).';
} else {
$sentence = 'The installer detected PHP version %currentValue%, but Thelia 2 requires PHP %expectedValue% or newer.';
}
$translatedText = $this->translator->trans(
$sentence,
array(
'%expectedValue%' => $expectedValue,
'%currentValue%' => $currentValue,
)
);
} else {
$translatedText = sprintf('Thelia requires PHP %s or newer (%s currently).', $expectedValue, $currentValue);
}
return $translatedText;
} | php | protected function getI18nPhpVersionText($expectedValue, $currentValue, $isValid)
{
if ($this->translator !== null) {
if ($isValid) {
$sentence = 'PHP version %currentValue% matches the minimum required (PHP %expectedValue%).';
} else {
$sentence = 'The installer detected PHP version %currentValue%, but Thelia 2 requires PHP %expectedValue% or newer.';
}
$translatedText = $this->translator->trans(
$sentence,
array(
'%expectedValue%' => $expectedValue,
'%currentValue%' => $currentValue,
)
);
} else {
$translatedText = sprintf('Thelia requires PHP %s or newer (%s currently).', $expectedValue, $currentValue);
}
return $translatedText;
} | [
"protected",
"function",
"getI18nPhpVersionText",
"(",
"$",
"expectedValue",
",",
"$",
"currentValue",
",",
"$",
"isValid",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"translator",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"isValid",
")",
"{",
"$",
"sentence... | Get Translated hint about the PHP version requirement issue
@param string $expectedValue
@param string $currentValue
@param bool $isValid
@return string | [
"Get",
"Translated",
"hint",
"about",
"the",
"PHP",
"version",
"requirement",
"issue"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Install/CheckPermission.php#L288-L309 | train |
thelia/core | lib/Thelia/Install/CheckPermission.php | CheckPermission.verifyServerMemoryValues | protected function verifyServerMemoryValues($key, $necessaryValueInBytes)
{
$serverValueInBytes = $this->returnBytes(ini_get($key));
if ($serverValueInBytes == -1) {
return true;
}
return ($serverValueInBytes >= $necessaryValueInBytes);
} | php | protected function verifyServerMemoryValues($key, $necessaryValueInBytes)
{
$serverValueInBytes = $this->returnBytes(ini_get($key));
if ($serverValueInBytes == -1) {
return true;
}
return ($serverValueInBytes >= $necessaryValueInBytes);
} | [
"protected",
"function",
"verifyServerMemoryValues",
"(",
"$",
"key",
",",
"$",
"necessaryValueInBytes",
")",
"{",
"$",
"serverValueInBytes",
"=",
"$",
"this",
"->",
"returnBytes",
"(",
"ini_get",
"(",
"$",
"key",
")",
")",
";",
"if",
"(",
"$",
"serverValueI... | Check if a server memory value is met or not
@param string $key .ini file key
@param int $necessaryValueInBytes Expected value in bytes
@return bool | [
"Check",
"if",
"a",
"server",
"memory",
"value",
"is",
"met",
"or",
"not"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Install/CheckPermission.php#L335-L344 | train |
thelia/core | lib/Thelia/Install/CheckPermission.php | CheckPermission.returnBytes | protected function returnBytes($val)
{
$val = trim($val);
$last = strtolower($val[strlen($val)-1]);
// Do not add breaks in the switch below
switch ($last) {
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$val = (int)$val*1024;
// no break
case 'm':
$val = (int)$val*1024;
// no break
case 'k':
$val = (int)$val*1024;
}
return $val;
} | php | protected function returnBytes($val)
{
$val = trim($val);
$last = strtolower($val[strlen($val)-1]);
// Do not add breaks in the switch below
switch ($last) {
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$val = (int)$val*1024;
// no break
case 'm':
$val = (int)$val*1024;
// no break
case 'k':
$val = (int)$val*1024;
}
return $val;
} | [
"protected",
"function",
"returnBytes",
"(",
"$",
"val",
")",
"{",
"$",
"val",
"=",
"trim",
"(",
"$",
"val",
")",
";",
"$",
"last",
"=",
"strtolower",
"(",
"$",
"val",
"[",
"strlen",
"(",
"$",
"val",
")",
"-",
"1",
"]",
")",
";",
"// Do not add b... | Return bytes from memory .ini value
@param string $val .ini value
@return int | [
"Return",
"bytes",
"from",
"memory",
".",
"ini",
"value"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Install/CheckPermission.php#L353-L371 | train |
melisplatform/melis-cms | src/Service/MelisCmsRightsService.php | MelisCmsRightsService.isActionButtonActive | public function isActionButtonActive($actionwanted)
{
$active = 0;
$pathArrayConfig = '';
switch ($actionwanted)
{
case 'save' : $pathArrayConfig = 'meliscms_page_action_save';
break;
case 'delete' : $pathArrayConfig = 'meliscms_page_action_delete';
break;
case 'publish' : $pathArrayConfig = 'meliscms_page_action_publishunpublish';
break;
case 'unpublish' : $pathArrayConfig = 'meliscms_page_action_publishunpublish';
break;
}
$melisAppConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$melisKeys = $melisAppConfig->getMelisKeys();
$melisCoreAuth = $this->getServiceLocator()->get('MelisCoreAuth');
$xmlRights = $melisCoreAuth->getAuthRights();
$melisCoreRights = $this->getServiceLocator()->get('MelisCoreRights');
if (!empty($melisKeys[$pathArrayConfig]))
{
$isAccessible = $melisCoreRights->isAccessible($xmlRights, MelisCoreRightsService::MELISCORE_PREFIX_INTERFACE, $melisKeys[$pathArrayConfig]);
if ($isAccessible)
$active = 1;
}
return $active;
} | php | public function isActionButtonActive($actionwanted)
{
$active = 0;
$pathArrayConfig = '';
switch ($actionwanted)
{
case 'save' : $pathArrayConfig = 'meliscms_page_action_save';
break;
case 'delete' : $pathArrayConfig = 'meliscms_page_action_delete';
break;
case 'publish' : $pathArrayConfig = 'meliscms_page_action_publishunpublish';
break;
case 'unpublish' : $pathArrayConfig = 'meliscms_page_action_publishunpublish';
break;
}
$melisAppConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$melisKeys = $melisAppConfig->getMelisKeys();
$melisCoreAuth = $this->getServiceLocator()->get('MelisCoreAuth');
$xmlRights = $melisCoreAuth->getAuthRights();
$melisCoreRights = $this->getServiceLocator()->get('MelisCoreRights');
if (!empty($melisKeys[$pathArrayConfig]))
{
$isAccessible = $melisCoreRights->isAccessible($xmlRights, MelisCoreRightsService::MELISCORE_PREFIX_INTERFACE, $melisKeys[$pathArrayConfig]);
if ($isAccessible)
$active = 1;
}
return $active;
} | [
"public",
"function",
"isActionButtonActive",
"(",
"$",
"actionwanted",
")",
"{",
"$",
"active",
"=",
"0",
";",
"$",
"pathArrayConfig",
"=",
"''",
";",
"switch",
"(",
"$",
"actionwanted",
")",
"{",
"case",
"'save'",
":",
"$",
"pathArrayConfig",
"=",
"'meli... | This function returns whether or not a user has access to the "save", "delete", "publish", "unpublish"
action buttons in the interface. Allowing to expand the rights to php saving functions, and updating
treeview right menu
@return int | [
"This",
"function",
"returns",
"whether",
"or",
"not",
"a",
"user",
"has",
"access",
"to",
"the",
"save",
"delete",
"publish",
"unpublish",
"action",
"buttons",
"in",
"the",
"interface",
".",
"Allowing",
"to",
"expand",
"the",
"rights",
"to",
"php",
"saving"... | ed470338f4c7653fd93e530013ab934eb7a52b6f | https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Service/MelisCmsRightsService.php#L271-L304 | train |
perimeter/rate-limiter-php | Throttler/RedisThrottler.php | RedisThrottler.trackMeter | protected function trackMeter($meterId, $buckets, $rates)
{
// create a key for this bucket's start time
$trackKey = sprintf('track:%s', $buckets[0]);
// track the meter key to this bucket with the number of times it was called
$this->redis->hset($trackKey, $meterId, $rates[0]);
// ensure this meter expires
$expireAt = $buckets[0] + ($this->config['bucket_size'] * $this->config['num_buckets']);
$this->redis->expireat($trackKey, $expireAt);
} | php | protected function trackMeter($meterId, $buckets, $rates)
{
// create a key for this bucket's start time
$trackKey = sprintf('track:%s', $buckets[0]);
// track the meter key to this bucket with the number of times it was called
$this->redis->hset($trackKey, $meterId, $rates[0]);
// ensure this meter expires
$expireAt = $buckets[0] + ($this->config['bucket_size'] * $this->config['num_buckets']);
$this->redis->expireat($trackKey, $expireAt);
} | [
"protected",
"function",
"trackMeter",
"(",
"$",
"meterId",
",",
"$",
"buckets",
",",
"$",
"rates",
")",
"{",
"// create a key for this bucket's start time",
"$",
"trackKey",
"=",
"sprintf",
"(",
"'track:%s'",
",",
"$",
"buckets",
"[",
"0",
"]",
")",
";",
"/... | This method allows you to change how the meter is tracked
So if you'd like to use a sorted set rather than a hash,
go on ahead! | [
"This",
"method",
"allows",
"you",
"to",
"change",
"how",
"the",
"meter",
"is",
"tracked",
"So",
"if",
"you",
"d",
"like",
"to",
"use",
"a",
"sorted",
"set",
"rather",
"than",
"a",
"hash",
"go",
"on",
"ahead!"
] | 121ba37284dd701afc2f546c4f49d1954564a24a | https://github.com/perimeter/rate-limiter-php/blob/121ba37284dd701afc2f546c4f49d1954564a24a/Throttler/RedisThrottler.php#L153-L164 | train |
jomweb/ringgit | src/Concerns/Tax.php | Tax.afterTax | public static function afterTax($amount, Taxable $taxable)
{
return static::beforeTax(
$taxable->getAmountWithoutTax(static::asMoney($amount)), $taxable
);
} | php | public static function afterTax($amount, Taxable $taxable)
{
return static::beforeTax(
$taxable->getAmountWithoutTax(static::asMoney($amount)), $taxable
);
} | [
"public",
"static",
"function",
"afterTax",
"(",
"$",
"amount",
",",
"Taxable",
"$",
"taxable",
")",
"{",
"return",
"static",
"::",
"beforeTax",
"(",
"$",
"taxable",
"->",
"getAmountWithoutTax",
"(",
"static",
"::",
"asMoney",
"(",
"$",
"amount",
")",
")",... | Make object with Tax.
@param int|string $amount
@param \Duit\Concerns\Taxable $taxable
@return static | [
"Make",
"object",
"with",
"Tax",
"."
] | d444f994bafabfbfa063cce2017500ebf2aa35f7 | https://github.com/jomweb/ringgit/blob/d444f994bafabfbfa063cce2017500ebf2aa35f7/src/Concerns/Tax.php#L28-L33 | train |
jomweb/ringgit | src/Concerns/Tax.php | Tax.getAmountWithTax | public function getAmountWithTax(): string
{
if (! $this->hasTax()) {
return $this->getMoney()->getAmount();
}
return $this->getTax()->getAmountWithTax($this->getMoney());
} | php | public function getAmountWithTax(): string
{
if (! $this->hasTax()) {
return $this->getMoney()->getAmount();
}
return $this->getTax()->getAmountWithTax($this->getMoney());
} | [
"public",
"function",
"getAmountWithTax",
"(",
")",
":",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasTax",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getMoney",
"(",
")",
"->",
"getAmount",
"(",
")",
";",
"}",
"return",
"$",
"this"... | Returns the value represented by this object with Tax.
@return string | [
"Returns",
"the",
"value",
"represented",
"by",
"this",
"object",
"with",
"Tax",
"."
] | d444f994bafabfbfa063cce2017500ebf2aa35f7 | https://github.com/jomweb/ringgit/blob/d444f994bafabfbfa063cce2017500ebf2aa35f7/src/Concerns/Tax.php#L137-L144 | train |
jomweb/ringgit | src/Concerns/Tax.php | Tax.allocateWithTax | public function allocateWithTax(array $ratios): array
{
$method = $this->hasTax() ? 'afterTax' : 'withoutTax';
$results = [];
$allocates = static::asMoney($this->getAmountWithTax())->allocate($ratios);
foreach ($allocates as $allocate) {
$results[] = static::{$method}($allocate->getAmount(), $this->getTax());
}
return $results;
} | php | public function allocateWithTax(array $ratios): array
{
$method = $this->hasTax() ? 'afterTax' : 'withoutTax';
$results = [];
$allocates = static::asMoney($this->getAmountWithTax())->allocate($ratios);
foreach ($allocates as $allocate) {
$results[] = static::{$method}($allocate->getAmount(), $this->getTax());
}
return $results;
} | [
"public",
"function",
"allocateWithTax",
"(",
"array",
"$",
"ratios",
")",
":",
"array",
"{",
"$",
"method",
"=",
"$",
"this",
"->",
"hasTax",
"(",
")",
"?",
"'afterTax'",
":",
"'withoutTax'",
";",
"$",
"results",
"=",
"[",
"]",
";",
"$",
"allocates",
... | Allocate the money according to a list of ratios with Tax.
@param array $ratios
@return Money[] | [
"Allocate",
"the",
"money",
"according",
"to",
"a",
"list",
"of",
"ratios",
"with",
"Tax",
"."
] | d444f994bafabfbfa063cce2017500ebf2aa35f7 | https://github.com/jomweb/ringgit/blob/d444f994bafabfbfa063cce2017500ebf2aa35f7/src/Concerns/Tax.php#L165-L177 | train |
jomweb/ringgit | src/Concerns/Tax.php | Tax.allocateWithTaxTo | public function allocateWithTaxTo(int $n): array
{
$method = $this->hasTax() ? 'afterTax' : 'withoutTax';
$results = [];
$allocates = static::asMoney($this->getAmountWithTax())->allocateTo($n);
foreach ($allocates as $allocate) {
$results[] = static::{$method}($allocate->getAmount(), $this->getTax());
}
return $results;
} | php | public function allocateWithTaxTo(int $n): array
{
$method = $this->hasTax() ? 'afterTax' : 'withoutTax';
$results = [];
$allocates = static::asMoney($this->getAmountWithTax())->allocateTo($n);
foreach ($allocates as $allocate) {
$results[] = static::{$method}($allocate->getAmount(), $this->getTax());
}
return $results;
} | [
"public",
"function",
"allocateWithTaxTo",
"(",
"int",
"$",
"n",
")",
":",
"array",
"{",
"$",
"method",
"=",
"$",
"this",
"->",
"hasTax",
"(",
")",
"?",
"'afterTax'",
":",
"'withoutTax'",
";",
"$",
"results",
"=",
"[",
"]",
";",
"$",
"allocates",
"="... | Allocate the money among N targets with GST.
@param int $n
@throws \InvalidArgumentException If number of targets is not an integer
@return Money[] | [
"Allocate",
"the",
"money",
"among",
"N",
"targets",
"with",
"GST",
"."
] | d444f994bafabfbfa063cce2017500ebf2aa35f7 | https://github.com/jomweb/ringgit/blob/d444f994bafabfbfa063cce2017500ebf2aa35f7/src/Concerns/Tax.php#L188-L200 | train |
thelia/core | lib/Thelia/Model/Lang.php | Lang.getDefaultLanguage | public static function getDefaultLanguage()
{
if (null === self::$defaultLanguage) {
self::$defaultLanguage = LangQuery::create()->findOneByByDefault(1);
if (null === self::$defaultLanguage) {
throw new \RuntimeException("No default language is defined. Please define one.");
}
}
return self::$defaultLanguage;
} | php | public static function getDefaultLanguage()
{
if (null === self::$defaultLanguage) {
self::$defaultLanguage = LangQuery::create()->findOneByByDefault(1);
if (null === self::$defaultLanguage) {
throw new \RuntimeException("No default language is defined. Please define one.");
}
}
return self::$defaultLanguage;
} | [
"public",
"static",
"function",
"getDefaultLanguage",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"self",
"::",
"$",
"defaultLanguage",
")",
"{",
"self",
"::",
"$",
"defaultLanguage",
"=",
"LangQuery",
"::",
"create",
"(",
")",
"->",
"findOneByByDefault",
"(",
... | Return the default language object, using a local variable to cache it.
@throws \RuntimeException | [
"Return",
"the",
"default",
"language",
"object",
"using",
"a",
"local",
"variable",
"to",
"cache",
"it",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Lang.php#L28-L39 | train |
MetaModels/attribute_tags | src/Attribute/MetaModelTags.php | MetaModelTags.convertValuesToIds | private function convertValuesToIds($varValue): array
{
$aliasColumn = $this->getAliasColumn();
$alias = [];
foreach ($varValue as $valueId => $value) {
if (array_key_exists($aliasColumn, $value)) {
$alias[$valueId] = $value[$aliasColumn];
continue;
}
if (array_key_exists(self::TAGS_RAW, $value) && array_key_exists($aliasColumn, $value[self::TAGS_RAW])) {
$alias[$valueId] = $value[self::TAGS_RAW][$aliasColumn];
}
}
return $alias;
} | php | private function convertValuesToIds($varValue): array
{
$aliasColumn = $this->getAliasColumn();
$alias = [];
foreach ($varValue as $valueId => $value) {
if (array_key_exists($aliasColumn, $value)) {
$alias[$valueId] = $value[$aliasColumn];
continue;
}
if (array_key_exists(self::TAGS_RAW, $value) && array_key_exists($aliasColumn, $value[self::TAGS_RAW])) {
$alias[$valueId] = $value[self::TAGS_RAW][$aliasColumn];
}
}
return $alias;
} | [
"private",
"function",
"convertValuesToIds",
"(",
"$",
"varValue",
")",
":",
"array",
"{",
"$",
"aliasColumn",
"=",
"$",
"this",
"->",
"getAliasColumn",
"(",
")",
";",
"$",
"alias",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"varValue",
"as",
"$",
"value... | Convert the passed values to a value id list.
@param array $varValue The values to convert.
@return array | [
"Convert",
"the",
"passed",
"values",
"to",
"a",
"value",
"id",
"list",
"."
] | d09c2cd18b299a48532caa0de8c70b7944282a8e | https://github.com/MetaModels/attribute_tags/blob/d09c2cd18b299a48532caa0de8c70b7944282a8e/src/Attribute/MetaModelTags.php#L269-L284 | train |
MetaModels/attribute_tags | src/Attribute/MetaModelTags.php | MetaModelTags.calculateFilterOptionsCount | protected function calculateFilterOptionsCount($items, &$amountArray, $idList)
{
$builder = $this
->getConnection()
->createQueryBuilder()
->select('value_id')
->addSelect('COUNT(item_id) AS amount')
->from('tl_metamodel_tag_relation')
->where('att_id=:attId')
->setParameter('attId', $this->get('id'))
->groupBy('value_id');
if (0 < $items->getCount()) {
$ids = [];
foreach ($items as $item) {
$ids[] = $item->get('id');
}
$builder
->andWhere('value_id IN (:valueIds)')
->setParameter('valueIds', $ids, Connection::PARAM_STR_ARRAY);
if ($idList && \is_array($idList)) {
$builder
->andWhere('item_id IN (:itemIds)')
->setParameter('itemIds', $idList, Connection::PARAM_STR_ARRAY);
}
}
$counts = $builder->execute();
foreach ($counts->fetchAll(\PDO::FETCH_ASSOC) as $count) {
$amountArray[$count['value_id']] = $count['amount'];
}
} | php | protected function calculateFilterOptionsCount($items, &$amountArray, $idList)
{
$builder = $this
->getConnection()
->createQueryBuilder()
->select('value_id')
->addSelect('COUNT(item_id) AS amount')
->from('tl_metamodel_tag_relation')
->where('att_id=:attId')
->setParameter('attId', $this->get('id'))
->groupBy('value_id');
if (0 < $items->getCount()) {
$ids = [];
foreach ($items as $item) {
$ids[] = $item->get('id');
}
$builder
->andWhere('value_id IN (:valueIds)')
->setParameter('valueIds', $ids, Connection::PARAM_STR_ARRAY);
if ($idList && \is_array($idList)) {
$builder
->andWhere('item_id IN (:itemIds)')
->setParameter('itemIds', $idList, Connection::PARAM_STR_ARRAY);
}
}
$counts = $builder->execute();
foreach ($counts->fetchAll(\PDO::FETCH_ASSOC) as $count) {
$amountArray[$count['value_id']] = $count['amount'];
}
} | [
"protected",
"function",
"calculateFilterOptionsCount",
"(",
"$",
"items",
",",
"&",
"$",
"amountArray",
",",
"$",
"idList",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"createQueryBuilder",
"(",
")",
"->",
"select",
... | Calculate the amount how often each value has been assigned.
@param IItems $items The item list containing the values.
@param array $amountArray The target array to where the counters shall be stored to.
@param array $idList The ids of items.
@return void | [
"Calculate",
"the",
"amount",
"how",
"often",
"each",
"value",
"has",
"been",
"assigned",
"."
] | d09c2cd18b299a48532caa0de8c70b7944282a8e | https://github.com/MetaModels/attribute_tags/blob/d09c2cd18b299a48532caa0de8c70b7944282a8e/src/Attribute/MetaModelTags.php#L355-L386 | train |
thelia/core | lib/Thelia/Model/Tools/PositionManagementTrait.php | PositionManagementTrait.getNextPosition | public function getNextPosition()
{
$query = $this->createQuery()
->orderByPosition(Criteria::DESC)
->limit(1);
$this->addCriteriaToPositionQuery($query);
$last = $query->findOne();
return $last != null ? $last->getPosition() + 1 : 1;
} | php | public function getNextPosition()
{
$query = $this->createQuery()
->orderByPosition(Criteria::DESC)
->limit(1);
$this->addCriteriaToPositionQuery($query);
$last = $query->findOne();
return $last != null ? $last->getPosition() + 1 : 1;
} | [
"public",
"function",
"getNextPosition",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"createQuery",
"(",
")",
"->",
"orderByPosition",
"(",
"Criteria",
"::",
"DESC",
")",
"->",
"limit",
"(",
"1",
")",
";",
"$",
"this",
"->",
"addCriteriaToPositi... | Get the position of the next inserted object | [
"Get",
"the",
"position",
"of",
"the",
"next",
"inserted",
"object"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Tools/PositionManagementTrait.php#L44-L55 | train |
thelia/core | lib/Thelia/Model/Tools/PositionManagementTrait.php | PositionManagementTrait.movePositionUpOrDown | protected function movePositionUpOrDown($up = true)
{
// The current position of the object
$myPosition = $this->getPosition();
// Find object to exchange position with
$search = $this->createQuery();
$this->addCriteriaToPositionQuery($search);
// Up or down ?
if ($up === true) {
// Find the object immediately before me
$search->filterByPosition(array('max' => $myPosition-1))->orderByPosition(Criteria::DESC);
} else {
// Find the object immediately after me
$search->filterByPosition(array('min' => $myPosition+1))->orderByPosition(Criteria::ASC);
}
$result = $search->findOne();
// If we found the proper object, exchange their positions
if ($result) {
$cnx = Propel::getWriteConnection($this->getDatabaseName());
$cnx->beginTransaction();
try {
$this
->setPosition($result->getPosition())
->save($cnx)
;
// For BC
if (method_exists($result, 'setDispatcher') && method_exists($this, 'getDispatcher')) {
$result->setDispatcher($this->getDispatcher());
}
$result->setPosition($myPosition)->save($cnx);
$cnx->commit();
} catch (\Exception $e) {
$cnx->rollback();
}
}
} | php | protected function movePositionUpOrDown($up = true)
{
// The current position of the object
$myPosition = $this->getPosition();
// Find object to exchange position with
$search = $this->createQuery();
$this->addCriteriaToPositionQuery($search);
// Up or down ?
if ($up === true) {
// Find the object immediately before me
$search->filterByPosition(array('max' => $myPosition-1))->orderByPosition(Criteria::DESC);
} else {
// Find the object immediately after me
$search->filterByPosition(array('min' => $myPosition+1))->orderByPosition(Criteria::ASC);
}
$result = $search->findOne();
// If we found the proper object, exchange their positions
if ($result) {
$cnx = Propel::getWriteConnection($this->getDatabaseName());
$cnx->beginTransaction();
try {
$this
->setPosition($result->getPosition())
->save($cnx)
;
// For BC
if (method_exists($result, 'setDispatcher') && method_exists($this, 'getDispatcher')) {
$result->setDispatcher($this->getDispatcher());
}
$result->setPosition($myPosition)->save($cnx);
$cnx->commit();
} catch (\Exception $e) {
$cnx->rollback();
}
}
} | [
"protected",
"function",
"movePositionUpOrDown",
"(",
"$",
"up",
"=",
"true",
")",
"{",
"// The current position of the object",
"$",
"myPosition",
"=",
"$",
"this",
"->",
"getPosition",
"(",
")",
";",
"// Find object to exchange position with",
"$",
"search",
"=",
... | Move up or down a object
@param bool $up the exchange mode: go up (POSITION_UP) or go down (POSITION_DOWN) | [
"Move",
"up",
"or",
"down",
"a",
"object"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Tools/PositionManagementTrait.php#L78-L123 | train |
thelia/core | lib/Thelia/Model/Tools/PositionManagementTrait.php | PositionManagementTrait.changeAbsolutePosition | public function changeAbsolutePosition($newPosition)
{
// The current position
$current_position = $this->getPosition();
if ($newPosition != null && $newPosition > 0 && $newPosition != $current_position) {
// Find categories to offset
$search = $this->createQuery();
$this->addCriteriaToPositionQuery($search);
if ($newPosition > $current_position) {
// The new position is after the current position -> we will offset + 1 all categories located between us and the new position
$search->filterByPosition(array('min' => 1+$current_position, 'max' => $newPosition));
$delta = -1;
} else {
// The new position is brefore the current position -> we will offset - 1 all categories located between us and the new position
$search->filterByPosition(array('min' => $newPosition, 'max' => $current_position - 1));
$delta = 1;
}
$results = $search->find();
$cnx = Propel::getWriteConnection($this->getDatabaseName());
$cnx->beginTransaction();
try {
foreach ($results as $result) {
$objNewPosition = $result->getPosition() + $delta;
// For BC
if (method_exists($result, 'setDispatcher') && method_exists($this, 'getDispatcher')) {
$result->setDispatcher($this->getDispatcher());
}
$result->setPosition($objNewPosition)->save($cnx);
}
$this
->setPosition($newPosition)
->save($cnx)
;
$cnx->commit();
} catch (\Exception $e) {
$cnx->rollback();
}
}
} | php | public function changeAbsolutePosition($newPosition)
{
// The current position
$current_position = $this->getPosition();
if ($newPosition != null && $newPosition > 0 && $newPosition != $current_position) {
// Find categories to offset
$search = $this->createQuery();
$this->addCriteriaToPositionQuery($search);
if ($newPosition > $current_position) {
// The new position is after the current position -> we will offset + 1 all categories located between us and the new position
$search->filterByPosition(array('min' => 1+$current_position, 'max' => $newPosition));
$delta = -1;
} else {
// The new position is brefore the current position -> we will offset - 1 all categories located between us and the new position
$search->filterByPosition(array('min' => $newPosition, 'max' => $current_position - 1));
$delta = 1;
}
$results = $search->find();
$cnx = Propel::getWriteConnection($this->getDatabaseName());
$cnx->beginTransaction();
try {
foreach ($results as $result) {
$objNewPosition = $result->getPosition() + $delta;
// For BC
if (method_exists($result, 'setDispatcher') && method_exists($this, 'getDispatcher')) {
$result->setDispatcher($this->getDispatcher());
}
$result->setPosition($objNewPosition)->save($cnx);
}
$this
->setPosition($newPosition)
->save($cnx)
;
$cnx->commit();
} catch (\Exception $e) {
$cnx->rollback();
}
}
} | [
"public",
"function",
"changeAbsolutePosition",
"(",
"$",
"newPosition",
")",
"{",
"// The current position",
"$",
"current_position",
"=",
"$",
"this",
"->",
"getPosition",
"(",
")",
";",
"if",
"(",
"$",
"newPosition",
"!=",
"null",
"&&",
"$",
"newPosition",
... | Changes object position
@param newPosition | [
"Changes",
"object",
"position"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/Tools/PositionManagementTrait.php#L141-L192 | train |
thelia/core | lib/Thelia/Core/Propel/Schema/SchemaLocator.php | SchemaLocator.findForActiveModules | public function findForActiveModules()
{
$fs = new Filesystem();
$codes = $this->queryActiveModuleCodes();
foreach ($codes as $key => $code) {
// test if the module exists on the file system
if (!$fs->exists(THELIA_MODULE_DIR . $code)) {
unset($codes[$key]);
}
}
// reset keys
$codes = array_values($codes);
return $this->findForModules($codes);
} | php | public function findForActiveModules()
{
$fs = new Filesystem();
$codes = $this->queryActiveModuleCodes();
foreach ($codes as $key => $code) {
// test if the module exists on the file system
if (!$fs->exists(THELIA_MODULE_DIR . $code)) {
unset($codes[$key]);
}
}
// reset keys
$codes = array_values($codes);
return $this->findForModules($codes);
} | [
"public",
"function",
"findForActiveModules",
"(",
")",
"{",
"$",
"fs",
"=",
"new",
"Filesystem",
"(",
")",
";",
"$",
"codes",
"=",
"$",
"this",
"->",
"queryActiveModuleCodes",
"(",
")",
";",
"foreach",
"(",
"$",
"codes",
"as",
"$",
"key",
"=>",
"$",
... | Get schema documents for Thelia core and active modules, as well as included external schemas.
@return \DOMDocument[] Schema documents. | [
"Get",
"schema",
"documents",
"for",
"Thelia",
"core",
"and",
"active",
"modules",
"as",
"well",
"as",
"included",
"external",
"schemas",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Propel/Schema/SchemaLocator.php#L75-L92 | train |
thelia/core | lib/Thelia/Core/Propel/Schema/SchemaLocator.php | SchemaLocator.addModulesDependencies | protected function addModulesDependencies(array $modules = [])
{
if (empty($modules)) {
return [];
}
// Thelia is always a dependency
if (!\in_array('Thelia', $modules)) {
$modules[] = 'Thelia';
}
foreach ($modules as $module) {
// Thelia is not a real module, do not try to get its dependencies
if ($module === 'Thelia') {
continue;
}
$moduleValidator = new ModuleValidator("{$this->theliaModuleDir}/{$module}");
$dependencies = $moduleValidator->getCurrentModuleDependencies(true);
foreach ($dependencies as $dependency) {
if (!\in_array($dependency['code'], $modules)) {
$modules[] = $dependency['code'];
}
}
}
return $modules;
} | php | protected function addModulesDependencies(array $modules = [])
{
if (empty($modules)) {
return [];
}
// Thelia is always a dependency
if (!\in_array('Thelia', $modules)) {
$modules[] = 'Thelia';
}
foreach ($modules as $module) {
// Thelia is not a real module, do not try to get its dependencies
if ($module === 'Thelia') {
continue;
}
$moduleValidator = new ModuleValidator("{$this->theliaModuleDir}/{$module}");
$dependencies = $moduleValidator->getCurrentModuleDependencies(true);
foreach ($dependencies as $dependency) {
if (!\in_array($dependency['code'], $modules)) {
$modules[] = $dependency['code'];
}
}
}
return $modules;
} | [
"protected",
"function",
"addModulesDependencies",
"(",
"array",
"$",
"modules",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"modules",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"// Thelia is always a dependency",
"if",
"(",
"!",
"\\",
"in_... | Add dependencies of some modules.
@param string[] $modules Module codes.
@return string[] Modules codes with added dependencies. | [
"Add",
"dependencies",
"of",
"some",
"modules",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Propel/Schema/SchemaLocator.php#L138-L165 | train |
thelia/core | lib/Thelia/Core/Propel/Schema/SchemaLocator.php | SchemaLocator.addExternalSchemaDocuments | protected function addExternalSchemaDocuments(array $schemaDocuments)
{
$fs = new Filesystem();
$externalSchemaDocuments = [];
foreach ($schemaDocuments as $schemaDocument) {
/** @var \DOMElement $externalSchemaElement */
foreach ($schemaDocument->getElementsByTagName('external-schema') as $externalSchemaElement) {
if (!$externalSchemaElement->hasAttribute('filename')) {
continue;
}
$externalSchemaPath = $externalSchemaElement->getAttribute('filename');
if (!$fs->exists($externalSchemaPath)) {
continue;
}
$externalSchemaDocument = new \DOMDocument();
if (!$externalSchemaDocument->load($externalSchemaPath)) {
continue;
}
$externalSchemaDocuments[] = $externalSchemaDocument;
}
}
return $this->mergeDOMDocumentsArrays([$schemaDocuments, $externalSchemaDocuments]);
} | php | protected function addExternalSchemaDocuments(array $schemaDocuments)
{
$fs = new Filesystem();
$externalSchemaDocuments = [];
foreach ($schemaDocuments as $schemaDocument) {
/** @var \DOMElement $externalSchemaElement */
foreach ($schemaDocument->getElementsByTagName('external-schema') as $externalSchemaElement) {
if (!$externalSchemaElement->hasAttribute('filename')) {
continue;
}
$externalSchemaPath = $externalSchemaElement->getAttribute('filename');
if (!$fs->exists($externalSchemaPath)) {
continue;
}
$externalSchemaDocument = new \DOMDocument();
if (!$externalSchemaDocument->load($externalSchemaPath)) {
continue;
}
$externalSchemaDocuments[] = $externalSchemaDocument;
}
}
return $this->mergeDOMDocumentsArrays([$schemaDocuments, $externalSchemaDocuments]);
} | [
"protected",
"function",
"addExternalSchemaDocuments",
"(",
"array",
"$",
"schemaDocuments",
")",
"{",
"$",
"fs",
"=",
"new",
"Filesystem",
"(",
")",
";",
"$",
"externalSchemaDocuments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"schemaDocuments",
"as",
"$",
... | Add external schema documents not already included.
@param \DOMDocument[] $schemaDocuments Schema documents.
@return \DOMDocument[] Schema documents. | [
"Add",
"external",
"schema",
"documents",
"not",
"already",
"included",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Core/Propel/Schema/SchemaLocator.php#L203-L232 | train |
NotifyMeHQ/notifyme | src/Manager/NotifyMeManager.php | NotifyMeManager.reconnect | public function reconnect($name = null)
{
$name = $name ?: $this->default;
$this->disconnect($name);
return $this->connection($name);
} | php | public function reconnect($name = null)
{
$name = $name ?: $this->default;
$this->disconnect($name);
return $this->connection($name);
} | [
"public",
"function",
"reconnect",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"name",
"?",
":",
"$",
"this",
"->",
"default",
";",
"$",
"this",
"->",
"disconnect",
"(",
"$",
"name",
")",
";",
"return",
"$",
"this",
"->",
"con... | Reconnect to the given connection.
@param string|null $name
@return \NotifyMeHQ\Contracts\GatewayInterface | [
"Reconnect",
"to",
"the",
"given",
"connection",
"."
] | 2af4bdcfe9df6db7ea79e2dce90b106ccb285b06 | https://github.com/NotifyMeHQ/notifyme/blob/2af4bdcfe9df6db7ea79e2dce90b106ccb285b06/src/Manager/NotifyMeManager.php#L90-L97 | train |
thelia/core | lib/Thelia/Controller/Admin/BaseAdminController.php | BaseAdminController.adminLogAppend | public function adminLogAppend($resource, $action, $message, $resourceId = null)
{
AdminLog::append(
$resource,
$action,
$message,
$this->getRequest(),
$this->getSecurityContext()->getAdminUser(),
true,
$resourceId
);
} | php | public function adminLogAppend($resource, $action, $message, $resourceId = null)
{
AdminLog::append(
$resource,
$action,
$message,
$this->getRequest(),
$this->getSecurityContext()->getAdminUser(),
true,
$resourceId
);
} | [
"public",
"function",
"adminLogAppend",
"(",
"$",
"resource",
",",
"$",
"action",
",",
"$",
"message",
",",
"$",
"resourceId",
"=",
"null",
")",
"{",
"AdminLog",
"::",
"append",
"(",
"$",
"resource",
",",
"$",
"action",
",",
"$",
"message",
",",
"$",
... | Helper to append a message to the admin log.
@param string $resource
@param string $action
@param string $message | [
"Helper",
"to",
"append",
"a",
"message",
"to",
"the",
"admin",
"log",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/BaseAdminController.php#L52-L63 | train |
thelia/core | lib/Thelia/Controller/Admin/BaseAdminController.php | BaseAdminController.processTemplateAction | public function processTemplateAction($template)
{
try {
if (! empty($template)) {
// If we have a view in the URL, render this view
return $this->render($template);
} elseif (null != $view = $this->getRequest()->get('view')) {
return $this->render($view);
}
} catch (\Exception $ex) {
return $this->errorPage($ex->getMessage());
}
return $this->pageNotFound();
} | php | public function processTemplateAction($template)
{
try {
if (! empty($template)) {
// If we have a view in the URL, render this view
return $this->render($template);
} elseif (null != $view = $this->getRequest()->get('view')) {
return $this->render($view);
}
} catch (\Exception $ex) {
return $this->errorPage($ex->getMessage());
}
return $this->pageNotFound();
} | [
"public",
"function",
"processTemplateAction",
"(",
"$",
"template",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"template",
")",
")",
"{",
"// If we have a view in the URL, render this view",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"temp... | This method process the rendering of view called from an admin page
@param string $template the template name
@return Response the response which contains the rendered view | [
"This",
"method",
"process",
"the",
"rendering",
"of",
"view",
"called",
"from",
"an",
"admin",
"page"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/BaseAdminController.php#L71-L85 | train |
thelia/core | lib/Thelia/Controller/Admin/BaseAdminController.php | BaseAdminController.errorPage | protected function errorPage($message, $status = 500)
{
if ($message instanceof \Exception) {
$strMessage = $this->getTranslator()->trans(
"Sorry, an error occured: %msg",
[ '%msg' => $message->getMessage() ]
);
Tlog::getInstance()->addError($strMessage.": ".$message->getTraceAsString());
$message = $strMessage;
} else {
Tlog::getInstance()->addError($message);
}
return $this->render(
'general_error',
array(
"error_message" => $message
),
$status
);
} | php | protected function errorPage($message, $status = 500)
{
if ($message instanceof \Exception) {
$strMessage = $this->getTranslator()->trans(
"Sorry, an error occured: %msg",
[ '%msg' => $message->getMessage() ]
);
Tlog::getInstance()->addError($strMessage.": ".$message->getTraceAsString());
$message = $strMessage;
} else {
Tlog::getInstance()->addError($message);
}
return $this->render(
'general_error',
array(
"error_message" => $message
),
$status
);
} | [
"protected",
"function",
"errorPage",
"(",
"$",
"message",
",",
"$",
"status",
"=",
"500",
")",
"{",
"if",
"(",
"$",
"message",
"instanceof",
"\\",
"Exception",
")",
"{",
"$",
"strMessage",
"=",
"$",
"this",
"->",
"getTranslator",
"(",
")",
"->",
"tran... | Return a general error page
@param \Exception|string $message a message string, or an exception instance
@param int $status the HTTP status (default is 500)
@return \Thelia\Core\HttpFoundation\Response | [
"Return",
"a",
"general",
"error",
"page"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/BaseAdminController.php#L113-L135 | train |
thelia/core | lib/Thelia/Controller/Admin/BaseAdminController.php | BaseAdminController.checkAuth | protected function checkAuth($resources, $modules, $accesses)
{
$resources = \is_array($resources) ? $resources : array($resources);
$modules = \is_array($modules) ? $modules : array($modules);
$accesses = \is_array($accesses) ? $accesses : array($accesses);
if ($this->getSecurityContext()->isGranted(array("ADMIN"), $resources, $modules, $accesses)) {
// Okay !
return null;
}
// Log the problem
$this->adminLogAppend(implode(",", $resources), implode(",", $accesses), "User is not granted for resources %s with accesses %s", implode(", ", $resources), implode(", ", $accesses));
return $this->errorPage($this->getTranslator()->trans("Sorry, you're not allowed to perform this action"), 403);
} | php | protected function checkAuth($resources, $modules, $accesses)
{
$resources = \is_array($resources) ? $resources : array($resources);
$modules = \is_array($modules) ? $modules : array($modules);
$accesses = \is_array($accesses) ? $accesses : array($accesses);
if ($this->getSecurityContext()->isGranted(array("ADMIN"), $resources, $modules, $accesses)) {
// Okay !
return null;
}
// Log the problem
$this->adminLogAppend(implode(",", $resources), implode(",", $accesses), "User is not granted for resources %s with accesses %s", implode(", ", $resources), implode(", ", $accesses));
return $this->errorPage($this->getTranslator()->trans("Sorry, you're not allowed to perform this action"), 403);
} | [
"protected",
"function",
"checkAuth",
"(",
"$",
"resources",
",",
"$",
"modules",
",",
"$",
"accesses",
")",
"{",
"$",
"resources",
"=",
"\\",
"is_array",
"(",
"$",
"resources",
")",
"?",
"$",
"resources",
":",
"array",
"(",
"$",
"resources",
")",
";",... | Check current admin user authorisations. An ADMIN role is assumed.
@param mixed $resources a single resource or an array of resources.
@param mixed $modules a single module or an array of modules.
@param mixed $accesses a single access or an array of accesses.
@return mixed null if authorization is granted, or a Response object which contains the error page otherwise | [
"Check",
"current",
"admin",
"user",
"authorisations",
".",
"An",
"ADMIN",
"role",
"is",
"assumed",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/BaseAdminController.php#L146-L161 | train |
thelia/core | lib/Thelia/Controller/Admin/BaseAdminController.php | BaseAdminController.setupFormErrorContext | protected function setupFormErrorContext($action, $error_message, BaseForm $form = null, \Exception $exception = null)
{
if ($error_message !== false) {
// Log the error message
Tlog::getInstance()->error(
$this->getTranslator()->trans(
"Error during %action process : %error. Exception was %exc",
array(
'%action' => $action,
'%error' => $error_message,
'%exc' => $exception != null ? $exception->getMessage() : 'no exception'
)
)
);
if ($form != null) {
// Mark the form as errored
$form->setErrorMessage($error_message);
// Pass it to the parser context
$this->getParserContext()->addForm($form);
}
// Pass the error message to the parser.
$this->getParserContext()->setGeneralError($error_message);
}
} | php | protected function setupFormErrorContext($action, $error_message, BaseForm $form = null, \Exception $exception = null)
{
if ($error_message !== false) {
// Log the error message
Tlog::getInstance()->error(
$this->getTranslator()->trans(
"Error during %action process : %error. Exception was %exc",
array(
'%action' => $action,
'%error' => $error_message,
'%exc' => $exception != null ? $exception->getMessage() : 'no exception'
)
)
);
if ($form != null) {
// Mark the form as errored
$form->setErrorMessage($error_message);
// Pass it to the parser context
$this->getParserContext()->addForm($form);
}
// Pass the error message to the parser.
$this->getParserContext()->setGeneralError($error_message);
}
} | [
"protected",
"function",
"setupFormErrorContext",
"(",
"$",
"action",
",",
"$",
"error_message",
",",
"BaseForm",
"$",
"form",
"=",
"null",
",",
"\\",
"Exception",
"$",
"exception",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"error_message",
"!==",
"false",
")... | Setup the error context when an error occurs in a action method.
@param string $action the action that caused the error (category modification, variable creation, currency update, etc.)
@param BaseForm $form the form where the error occured, or null if no form was involved
@param string $error_message the error message
@param \Exception $exception the exception or null if no exception | [
"Setup",
"the",
"error",
"context",
"when",
"an",
"error",
"occurs",
"in",
"a",
"action",
"method",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/BaseAdminController.php#L184-L210 | train |
thelia/core | lib/Thelia/Controller/Admin/BaseAdminController.php | BaseAdminController.getCurrentEditionCurrency | protected function getCurrentEditionCurrency()
{
// Return the new language if a change is required.
if (null !== $edit_currency_id = $this->getRequest()->get('edit_currency_id', null)) {
if (null !== $edit_currency = CurrencyQuery::create()->findOneById($edit_currency_id)) {
return $edit_currency;
}
}
// Otherwise return the lang stored in session.
return $this->getSession()->getAdminEditionCurrency();
} | php | protected function getCurrentEditionCurrency()
{
// Return the new language if a change is required.
if (null !== $edit_currency_id = $this->getRequest()->get('edit_currency_id', null)) {
if (null !== $edit_currency = CurrencyQuery::create()->findOneById($edit_currency_id)) {
return $edit_currency;
}
}
// Otherwise return the lang stored in session.
return $this->getSession()->getAdminEditionCurrency();
} | [
"protected",
"function",
"getCurrentEditionCurrency",
"(",
")",
"{",
"// Return the new language if a change is required.",
"if",
"(",
"null",
"!==",
"$",
"edit_currency_id",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"get",
"(",
"'edit_currency_id'",
",",
... | Get the current edition currency ID, checking if a change was requested in the current request. | [
"Get",
"the",
"current",
"edition",
"currency",
"ID",
"checking",
"if",
"a",
"change",
"was",
"requested",
"in",
"the",
"current",
"request",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/BaseAdminController.php#L250-L261 | train |
thelia/core | lib/Thelia/Controller/Admin/BaseAdminController.php | BaseAdminController.getCurrentEditionLang | protected function getCurrentEditionLang()
{
// Return the new language if a change is required.
if (null !== $edit_language_id = $this->getRequest()->get('edit_language_id', null)) {
if (null !== $edit_language = LangQuery::create()->findOneById($edit_language_id)) {
return $edit_language;
}
}
// Otherwise return the lang stored in session.
return $this->getSession()->getAdminEditionLang();
} | php | protected function getCurrentEditionLang()
{
// Return the new language if a change is required.
if (null !== $edit_language_id = $this->getRequest()->get('edit_language_id', null)) {
if (null !== $edit_language = LangQuery::create()->findOneById($edit_language_id)) {
return $edit_language;
}
}
// Otherwise return the lang stored in session.
return $this->getSession()->getAdminEditionLang();
} | [
"protected",
"function",
"getCurrentEditionLang",
"(",
")",
"{",
"// Return the new language if a change is required.",
"if",
"(",
"null",
"!==",
"$",
"edit_language_id",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"get",
"(",
"'edit_language_id'",
",",
"n... | Get the current edition lang ID, checking if a change was requested in the current request. | [
"Get",
"the",
"current",
"edition",
"lang",
"ID",
"checking",
"if",
"a",
"change",
"was",
"requested",
"in",
"the",
"current",
"request",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/BaseAdminController.php#L266-L277 | train |
thelia/core | lib/Thelia/Controller/Admin/BaseAdminController.php | BaseAdminController.getUrlLanguage | protected function getUrlLanguage($locale = null)
{
// Check if the functionality is activated
if (!ConfigQuery::isMultiDomainActivated()) {
return null;
}
// If we don't have a locale value, use the locale value in the session
if (!$locale) {
$locale = $this->getCurrentEditionLocale();
}
return LangQuery::create()->findOneByLocale($locale)->getUrl();
} | php | protected function getUrlLanguage($locale = null)
{
// Check if the functionality is activated
if (!ConfigQuery::isMultiDomainActivated()) {
return null;
}
// If we don't have a locale value, use the locale value in the session
if (!$locale) {
$locale = $this->getCurrentEditionLocale();
}
return LangQuery::create()->findOneByLocale($locale)->getUrl();
} | [
"protected",
"function",
"getUrlLanguage",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"// Check if the functionality is activated",
"if",
"(",
"!",
"ConfigQuery",
"::",
"isMultiDomainActivated",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"// If we don't have a ... | A simple helper to get the URL based on the language.
@param string $locale the locale, or null to get the current one
@return null|string the URL for the current language, or null if the "One domain for each lang" feature is disabled. | [
"A",
"simple",
"helper",
"to",
"get",
"the",
"URL",
"based",
"on",
"the",
"language",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/BaseAdminController.php#L293-L306 | train |
thelia/core | lib/Thelia/Controller/Admin/BaseAdminController.php | BaseAdminController.getListOrderFromSession | protected function getListOrderFromSession($objectName, $requestParameterName, $defaultListOrder, $updateSession = true)
{
$orderSessionIdentifier = sprintf("admin.%s.currentListOrder", $objectName);
// Find the current order
$order = $this->getRequest()->get(
$requestParameterName,
$this->getSession()->get($orderSessionIdentifier, $defaultListOrder)
);
if ($updateSession) {
$this->getSession()->set($orderSessionIdentifier, $order);
}
return $order;
} | php | protected function getListOrderFromSession($objectName, $requestParameterName, $defaultListOrder, $updateSession = true)
{
$orderSessionIdentifier = sprintf("admin.%s.currentListOrder", $objectName);
// Find the current order
$order = $this->getRequest()->get(
$requestParameterName,
$this->getSession()->get($orderSessionIdentifier, $defaultListOrder)
);
if ($updateSession) {
$this->getSession()->set($orderSessionIdentifier, $order);
}
return $order;
} | [
"protected",
"function",
"getListOrderFromSession",
"(",
"$",
"objectName",
",",
"$",
"requestParameterName",
",",
"$",
"defaultListOrder",
",",
"$",
"updateSession",
"=",
"true",
")",
"{",
"$",
"orderSessionIdentifier",
"=",
"sprintf",
"(",
"\"admin.%s.currentListOrd... | Return the current list order identifier for a given object name,
updating in using the current request.
@param string $objectName the object name (e.g. 'attribute', 'message')
@param string $requestParameterName the name of the request parameter that defines the list order
@param string $defaultListOrder the default order to use, if none is defined
@param bool $updateSession if true, the session will be updated with the current order.
@return String the current list order. | [
"Return",
"the",
"current",
"list",
"order",
"identifier",
"for",
"a",
"given",
"object",
"name",
"updating",
"in",
"using",
"the",
"current",
"request",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/BaseAdminController.php#L320-L334 | train |
grom358/pharborist | src/Functions/ParameterTrait.php | ParameterTrait.appendParameter | public function appendParameter($parameter) {
if (is_callable($parameter)) {
$parameter = $parameter($this);
}
if (!($parameter instanceof ParameterNode)) {
throw new \InvalidArgumentException();
}
$this->parameters->appendItem($parameter);
return $this;
} | php | public function appendParameter($parameter) {
if (is_callable($parameter)) {
$parameter = $parameter($this);
}
if (!($parameter instanceof ParameterNode)) {
throw new \InvalidArgumentException();
}
$this->parameters->appendItem($parameter);
return $this;
} | [
"public",
"function",
"appendParameter",
"(",
"$",
"parameter",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"parameter",
")",
")",
"{",
"$",
"parameter",
"=",
"$",
"parameter",
"(",
"$",
"this",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"parameter",... | Appends a parameter.
@param \Pharborist\Functions\ParameterNode|callable $parameter
Either an existing parameter node, or a callable which will return
the parameter to append. The callable will receive $this as its
only argument.
@return $this
@throws \InvalidArgumentException | [
"Appends",
"a",
"parameter",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Functions/ParameterTrait.php#L62-L71 | train |
grom358/pharborist | src/Functions/ParameterTrait.php | ParameterTrait.insertParameter | public function insertParameter(ParameterNode $parameter, $index) {
$this->parameters->insertItem($parameter, $index);
return $this;
} | php | public function insertParameter(ParameterNode $parameter, $index) {
$this->parameters->insertItem($parameter, $index);
return $this;
} | [
"public",
"function",
"insertParameter",
"(",
"ParameterNode",
"$",
"parameter",
",",
"$",
"index",
")",
"{",
"$",
"this",
"->",
"parameters",
"->",
"insertItem",
"(",
"$",
"parameter",
",",
"$",
"index",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Insert parameter before parameter at index.
@param ParameterNode $parameter
@param int $index
@throws \OutOfBoundsException
Index out of bounds.
@return $this | [
"Insert",
"parameter",
"before",
"parameter",
"at",
"index",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Functions/ParameterTrait.php#L82-L85 | train |
grom358/pharborist | src/Functions/ParameterTrait.php | ParameterTrait.getParameter | public function getParameter($key) {
if (is_string($key)) {
return $this->getParameterByName($key);
}
elseif (is_integer($key)) {
return $this->getParameterAtIndex($key);
}
else {
throw new \InvalidArgumentException("Illegal parameter index {$key}.");
}
} | php | public function getParameter($key) {
if (is_string($key)) {
return $this->getParameterByName($key);
}
elseif (is_integer($key)) {
return $this->getParameterAtIndex($key);
}
else {
throw new \InvalidArgumentException("Illegal parameter index {$key}.");
}
} | [
"public",
"function",
"getParameter",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getParameterByName",
"(",
"$",
"key",
")",
";",
"}",
"elseif",
"(",
"is_integer",
"(",
"$",
"key",
... | Gets a parameter by name or index.
@param mixed $key
The parameter's name (without leading $) or position in the
parameter list.
@return ParameterNode
@throws \InvalidArgumentException if the key is not a string or integer. | [
"Gets",
"a",
"parameter",
"by",
"name",
"or",
"index",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Functions/ParameterTrait.php#L108-L118 | train |
grom358/pharborist | src/Functions/ParameterTrait.php | ParameterTrait.getParameterByName | public function getParameterByName($name) {
$name = ltrim($name, '$');
/** @var ParameterNode $parameter */
foreach ($this->getParameters()->reverse() as $parameter) {
if ($parameter->getName() === $name) {
return $parameter;
}
}
throw new \UnexpectedValueException("Parameter {$name} does not exist.");
} | php | public function getParameterByName($name) {
$name = ltrim($name, '$');
/** @var ParameterNode $parameter */
foreach ($this->getParameters()->reverse() as $parameter) {
if ($parameter->getName() === $name) {
return $parameter;
}
}
throw new \UnexpectedValueException("Parameter {$name} does not exist.");
} | [
"public",
"function",
"getParameterByName",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"ltrim",
"(",
"$",
"name",
",",
"'$'",
")",
";",
"/** @var ParameterNode $parameter */",
"foreach",
"(",
"$",
"this",
"->",
"getParameters",
"(",
")",
"->",
"reverse",
... | Gets a parameter by its name.
@param string $name
The parameter name with or without leading $.
@return ParameterNode
@throws \UnexpectedValueException if the named parameter doesn't exist. | [
"Gets",
"a",
"parameter",
"by",
"its",
"name",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Functions/ParameterTrait.php#L141-L150 | train |
thelia/core | lib/Thelia/Tools/URL.php | URL.getBaseUrl | public function getBaseUrl($scheme_only = false)
{
if (null === $this->baseUrlScheme) {
$scheme = "http";
$port = 80;
if ($host = $this->requestContext->getHost()) {
$scheme = $this->requestContext->getScheme();
$port = '';
if ('http' === $scheme && 80 != $this->requestContext->getHttpPort()) {
$port = ':'.$this->requestContext->getHttpPort();
} elseif ('https' === $scheme && 443 != $this->requestContext->getHttpsPort()) {
$port = ':'.$this->requestContext->getHttpsPort();
}
}
$this->baseUrlScheme = "$scheme://$host"."$port";
}
return $scheme_only ? $this->baseUrlScheme : $this->baseUrlScheme . $this->requestContext->getBaseUrl();
} | php | public function getBaseUrl($scheme_only = false)
{
if (null === $this->baseUrlScheme) {
$scheme = "http";
$port = 80;
if ($host = $this->requestContext->getHost()) {
$scheme = $this->requestContext->getScheme();
$port = '';
if ('http' === $scheme && 80 != $this->requestContext->getHttpPort()) {
$port = ':'.$this->requestContext->getHttpPort();
} elseif ('https' === $scheme && 443 != $this->requestContext->getHttpsPort()) {
$port = ':'.$this->requestContext->getHttpsPort();
}
}
$this->baseUrlScheme = "$scheme://$host"."$port";
}
return $scheme_only ? $this->baseUrlScheme : $this->baseUrlScheme . $this->requestContext->getBaseUrl();
} | [
"public",
"function",
"getBaseUrl",
"(",
"$",
"scheme_only",
"=",
"false",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"baseUrlScheme",
")",
"{",
"$",
"scheme",
"=",
"\"http\"",
";",
"$",
"port",
"=",
"80",
";",
"if",
"(",
"$",
"host",
"... | Return the base URL, either the base_url defined in Config, or the URL
of the current language, if 'one_domain_foreach_lang' is enabled.
@param bool $scheme_only if true, only the scheme will be returned. If false, the complete base URL, including path, is returned.
@return string the base URL, with a trailing '/' | [
"Return",
"the",
"base",
"URL",
"either",
"the",
"base_url",
"defined",
"in",
"Config",
"or",
"the",
"URL",
"of",
"the",
"current",
"language",
"if",
"one_domain_foreach_lang",
"is",
"enabled",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Tools/URL.php#L89-L111 | train |
thelia/core | lib/Thelia/Tools/URL.php | URL.adminViewUrl | public function adminViewUrl($viewName, array $parameters = array())
{
$path = sprintf("%s/admin/%s", $this->getIndexPage(), $viewName);
return $this->absoluteUrl($path, $parameters);
} | php | public function adminViewUrl($viewName, array $parameters = array())
{
$path = sprintf("%s/admin/%s", $this->getIndexPage(), $viewName);
return $this->absoluteUrl($path, $parameters);
} | [
"public",
"function",
"adminViewUrl",
"(",
"$",
"viewName",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"path",
"=",
"sprintf",
"(",
"\"%s/admin/%s\"",
",",
"$",
"this",
"->",
"getIndexPage",
"(",
")",
",",
"$",
"viewName",
... | Returns the Absolute URL to a administration view
@param string $viewName the view name (e.g. login for login.html)
@param mixed $parameters An array of parameters
@return string The generated URL | [
"Returns",
"the",
"Absolute",
"URL",
"to",
"a",
"administration",
"view"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Tools/URL.php#L207-L212 | train |
thelia/core | lib/Thelia/Tools/URL.php | URL.viewUrl | public function viewUrl($viewName, array $parameters = array())
{
$path = sprintf("?view=%s", $viewName);
return $this->absoluteUrl($path, $parameters);
} | php | public function viewUrl($viewName, array $parameters = array())
{
$path = sprintf("?view=%s", $viewName);
return $this->absoluteUrl($path, $parameters);
} | [
"public",
"function",
"viewUrl",
"(",
"$",
"viewName",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"path",
"=",
"sprintf",
"(",
"\"?view=%s\"",
",",
"$",
"viewName",
")",
";",
"return",
"$",
"this",
"->",
"absoluteUrl",
"(",... | Returns the Absolute URL to a view
@param string $viewName the view name (e.g. login for login.html)
@param mixed $parameters An array of parameters
@return string The generated URL | [
"Returns",
"the",
"Absolute",
"URL",
"to",
"a",
"view"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Tools/URL.php#L222-L227 | train |
thelia/core | lib/Thelia/Tools/URL.php | URL.retrieve | public function retrieve($view, $viewId, $viewLocale)
{
if (ConfigQuery::isRewritingEnable()) {
$this->retriever->loadViewUrl($view, $viewLocale, $viewId);
} else {
$allParametersWithoutView = array();
$allParametersWithoutView['lang'] = $viewLocale;
if (null !== $viewId) {
$allParametersWithoutView[$view . '_id'] = $viewId;
}
$this->retriever->rewrittenUrl = null;
$this->retriever->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
}
return $this->retriever;
} | php | public function retrieve($view, $viewId, $viewLocale)
{
if (ConfigQuery::isRewritingEnable()) {
$this->retriever->loadViewUrl($view, $viewLocale, $viewId);
} else {
$allParametersWithoutView = array();
$allParametersWithoutView['lang'] = $viewLocale;
if (null !== $viewId) {
$allParametersWithoutView[$view . '_id'] = $viewId;
}
$this->retriever->rewrittenUrl = null;
$this->retriever->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
}
return $this->retriever;
} | [
"public",
"function",
"retrieve",
"(",
"$",
"view",
",",
"$",
"viewId",
",",
"$",
"viewLocale",
")",
"{",
"if",
"(",
"ConfigQuery",
"::",
"isRewritingEnable",
"(",
")",
")",
"{",
"$",
"this",
"->",
"retriever",
"->",
"loadViewUrl",
"(",
"$",
"view",
",... | Retrieve a rewritten URL from a view, a view id and a locale
@param $view
@param $viewId
@param $viewLocale
@return RewritingRetriever You can access $url and $rewrittenUrl properties | [
"Retrieve",
"a",
"rewritten",
"URL",
"from",
"a",
"view",
"a",
"view",
"id",
"and",
"a",
"locale"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Tools/URL.php#L238-L253 | train |
thelia/core | lib/Thelia/Tools/URL.php | URL.retrieveCurrent | public function retrieveCurrent(Request $request)
{
if (ConfigQuery::isRewritingEnable()) {
$view = $request->attributes->get('_view', null);
$viewLocale = $this->getViewLocale($request);
$viewId = $view === null ? null : $request->query->get($view . '_id', null);
$allOtherParameters = $request->query->all();
if ($view !== null) {
unset($allOtherParameters['view']);
if ($viewId !== null) {
unset($allOtherParameters[$view . '_id']);
}
}
if ($viewLocale !== null) {
unset($allOtherParameters['lang']);
unset($allOtherParameters['locale']);
}
$this->retriever->loadSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters);
} else {
$allParametersWithoutView = $request->query->all();
$view = $request->attributes->get('_view');
if (isset($allOtherParameters['view'])) {
unset($allOtherParameters['view']);
}
$this->retriever->rewrittenUrl = null;
$this->retriever->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
}
return $this->retriever;
} | php | public function retrieveCurrent(Request $request)
{
if (ConfigQuery::isRewritingEnable()) {
$view = $request->attributes->get('_view', null);
$viewLocale = $this->getViewLocale($request);
$viewId = $view === null ? null : $request->query->get($view . '_id', null);
$allOtherParameters = $request->query->all();
if ($view !== null) {
unset($allOtherParameters['view']);
if ($viewId !== null) {
unset($allOtherParameters[$view . '_id']);
}
}
if ($viewLocale !== null) {
unset($allOtherParameters['lang']);
unset($allOtherParameters['locale']);
}
$this->retriever->loadSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters);
} else {
$allParametersWithoutView = $request->query->all();
$view = $request->attributes->get('_view');
if (isset($allOtherParameters['view'])) {
unset($allOtherParameters['view']);
}
$this->retriever->rewrittenUrl = null;
$this->retriever->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
}
return $this->retriever;
} | [
"public",
"function",
"retrieveCurrent",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"ConfigQuery",
"::",
"isRewritingEnable",
"(",
")",
")",
"{",
"$",
"view",
"=",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'_view'",
",",
"null",
")... | Retrieve a rewritten URL from the current GET parameters
@param Request $request
@return RewritingRetriever You can access $url and $rewrittenUrl properties or use toString method | [
"Retrieve",
"a",
"rewritten",
"URL",
"from",
"the",
"current",
"GET",
"parameters"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Tools/URL.php#L262-L295 | train |
thelia/core | lib/Thelia/Tools/URL.php | URL.getViewLocale | private function getViewLocale(Request $request)
{
$viewLocale = $request->query->get('lang', null);
if (null === $viewLocale) {
// fallback for old parameter
$viewLocale = $request->query->get('locale', null);
}
return $viewLocale;
} | php | private function getViewLocale(Request $request)
{
$viewLocale = $request->query->get('lang', null);
if (null === $viewLocale) {
// fallback for old parameter
$viewLocale = $request->query->get('locale', null);
}
return $viewLocale;
} | [
"private",
"function",
"getViewLocale",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"viewLocale",
"=",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'lang'",
",",
"null",
")",
";",
"if",
"(",
"null",
"===",
"$",
"viewLocale",
")",
"{",
"// fallb... | Get the locale code from the lang attribute in URL.
@param Request $request
@return null|string | [
"Get",
"the",
"locale",
"code",
"from",
"the",
"lang",
"attribute",
"in",
"URL",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Tools/URL.php#L343-L352 | train |
thelia/core | lib/Thelia/Model/OrderPostage.php | OrderPostage.loadFromPostage | public static function loadFromPostage($postage)
{
if ($postage instanceof OrderPostage) {
$orderPostage = $postage;
} else {
$orderPostage = new OrderPostage($postage);
}
return $orderPostage;
} | php | public static function loadFromPostage($postage)
{
if ($postage instanceof OrderPostage) {
$orderPostage = $postage;
} else {
$orderPostage = new OrderPostage($postage);
}
return $orderPostage;
} | [
"public",
"static",
"function",
"loadFromPostage",
"(",
"$",
"postage",
")",
"{",
"if",
"(",
"$",
"postage",
"instanceof",
"OrderPostage",
")",
"{",
"$",
"orderPostage",
"=",
"$",
"postage",
";",
"}",
"else",
"{",
"$",
"orderPostage",
"=",
"new",
"OrderPos... | Convert a amount or OrderPostage object to an OrderPostage object
@param OrderPostage|float $postage
@return OrderPostage | [
"Convert",
"a",
"amount",
"or",
"OrderPostage",
"object",
"to",
"an",
"OrderPostage",
"object"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Model/OrderPostage.php#L45-L54 | train |
thelia/core | lib/Thelia/Action/Document.php | Document.processDocument | public function processDocument(DocumentEvent $event)
{
$subdir = $event->getCacheSubdirectory();
$sourceFile = $event->getSourceFilepath();
if (null == $subdir || null == $sourceFile) {
throw new \InvalidArgumentException("Cache sub-directory and source file path cannot be null");
}
$originalDocumentPathInCache = $this->getCacheFilePath($subdir, $sourceFile, true);
if (! file_exists($originalDocumentPathInCache)) {
if (! file_exists($sourceFile)) {
throw new DocumentException(sprintf("Source document file %s does not exists.", $sourceFile));
}
$mode = ConfigQuery::read(self::CONFIG_DELIVERY_MODE, 'symlink');
if ($mode == 'symlink') {
if (false === symlink($sourceFile, $originalDocumentPathInCache)) {
throw new DocumentException(sprintf("Failed to create symbolic link for %s in %s document cache directory", basename($sourceFile), $subdir));
}
} else {
// mode = 'copy'
if (false === @copy($sourceFile, $originalDocumentPathInCache)) {
throw new DocumentException(sprintf("Failed to copy %s in %s document cache directory", basename($sourceFile), $subdir));
}
}
}
// Compute the document URL
$documentUrl = $this->getCacheFileURL($subdir, basename($originalDocumentPathInCache));
// Update the event with file path and file URL
$event->setDocumentPath($documentUrl);
$event->setDocumentUrl(URL::getInstance()->absoluteUrl($documentUrl, null, URL::PATH_TO_FILE, $this->cdnBaseUrl));
} | php | public function processDocument(DocumentEvent $event)
{
$subdir = $event->getCacheSubdirectory();
$sourceFile = $event->getSourceFilepath();
if (null == $subdir || null == $sourceFile) {
throw new \InvalidArgumentException("Cache sub-directory and source file path cannot be null");
}
$originalDocumentPathInCache = $this->getCacheFilePath($subdir, $sourceFile, true);
if (! file_exists($originalDocumentPathInCache)) {
if (! file_exists($sourceFile)) {
throw new DocumentException(sprintf("Source document file %s does not exists.", $sourceFile));
}
$mode = ConfigQuery::read(self::CONFIG_DELIVERY_MODE, 'symlink');
if ($mode == 'symlink') {
if (false === symlink($sourceFile, $originalDocumentPathInCache)) {
throw new DocumentException(sprintf("Failed to create symbolic link for %s in %s document cache directory", basename($sourceFile), $subdir));
}
} else {
// mode = 'copy'
if (false === @copy($sourceFile, $originalDocumentPathInCache)) {
throw new DocumentException(sprintf("Failed to copy %s in %s document cache directory", basename($sourceFile), $subdir));
}
}
}
// Compute the document URL
$documentUrl = $this->getCacheFileURL($subdir, basename($originalDocumentPathInCache));
// Update the event with file path and file URL
$event->setDocumentPath($documentUrl);
$event->setDocumentUrl(URL::getInstance()->absoluteUrl($documentUrl, null, URL::PATH_TO_FILE, $this->cdnBaseUrl));
} | [
"public",
"function",
"processDocument",
"(",
"DocumentEvent",
"$",
"event",
")",
"{",
"$",
"subdir",
"=",
"$",
"event",
"->",
"getCacheSubdirectory",
"(",
")",
";",
"$",
"sourceFile",
"=",
"$",
"event",
"->",
"getSourceFilepath",
"(",
")",
";",
"if",
"(",... | Process document and write the result in the document cache.
When the original document is required, create either a symbolic link with the
original document in the cache dir, or copy it in the cache dir if it's not already done.
This method updates the cache_file_path and file_url attributes of the event
@param DocumentEvent $event Event
@throws \Thelia\Exception\DocumentException
@throws \InvalidArgumentException , DocumentException | [
"Process",
"document",
"and",
"write",
"the",
"result",
"in",
"the",
"document",
"cache",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Document.php#L70-L106 | train |
thelia/core | lib/Thelia/Action/Category.php | Category.create | public function create(CategoryCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$category = new CategoryModel();
$category
->setDispatcher($dispatcher)
->setLocale($event->getLocale())
->setParent($event->getParent())
->setVisible($event->getVisible())
->setTitle($event->getTitle())
->save()
;
$event->setCategory($category);
} | php | public function create(CategoryCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$category = new CategoryModel();
$category
->setDispatcher($dispatcher)
->setLocale($event->getLocale())
->setParent($event->getParent())
->setVisible($event->getVisible())
->setTitle($event->getTitle())
->save()
;
$event->setCategory($category);
} | [
"public",
"function",
"create",
"(",
"CategoryCreateEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"category",
"=",
"new",
"CategoryModel",
"(",
")",
";",
"$",
"category",
"->",
"setDispatcher",
... | Create a new category entry
@param \Thelia\Core\Event\Category\CategoryCreateEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Create",
"a",
"new",
"category",
"entry"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Category.php#L47-L63 | train |
thelia/core | lib/Thelia/Action/Category.php | Category.update | public function update(CategoryUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) {
$category
->setDispatcher($dispatcher)
->setDefaultTemplateId($event->getDefaultTemplateId() == 0 ? null : $event->getDefaultTemplateId())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
->setChapo($event->getChapo())
->setPostscriptum($event->getPostscriptum())
->setParent($event->getParent())
->setVisible($event->getVisible())
->save();
$event->setCategory($category);
}
} | php | public function update(CategoryUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) {
$category
->setDispatcher($dispatcher)
->setDefaultTemplateId($event->getDefaultTemplateId() == 0 ? null : $event->getDefaultTemplateId())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
->setChapo($event->getChapo())
->setPostscriptum($event->getPostscriptum())
->setParent($event->getParent())
->setVisible($event->getVisible())
->save();
$event->setCategory($category);
}
} | [
"public",
"function",
"update",
"(",
"CategoryUpdateEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"category",
"=",
"CategoryQuery",
"::",
"create",
"(",
")",
"->",
"f... | Change a category
@param \Thelia\Core\Event\Category\CategoryUpdateEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Change",
"a",
"category"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Category.php#L72-L91 | train |
thelia/core | lib/Thelia/Action/Category.php | Category.delete | public function delete(CategoryDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) {
$con = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$fileList = ['images' => [], 'documentList' => []];
// Get category's files to delete after category deletion
$fileList['images']['list'] = CategoryImageQuery::create()
->findByCategoryId($event->getCategoryId());
$fileList['images']['type'] = TheliaEvents::IMAGE_DELETE;
$fileList['documentList']['list'] = CategoryDocumentQuery::create()
->findByCategoryId($event->getCategoryId());
$fileList['documentList']['type'] = TheliaEvents::DOCUMENT_DELETE;
// Delete category
$category
->setDispatcher($dispatcher)
->delete($con);
$event->setCategory($category);
// Dispatch delete category's files event
foreach ($fileList as $fileTypeList) {
foreach ($fileTypeList['list'] as $fileToDelete) {
$fileDeleteEvent = new FileDeleteEvent($fileToDelete);
$dispatcher->dispatch($fileTypeList['type'], $fileDeleteEvent);
}
}
$con->commit();
} catch (\Exception $e) {
$con->rollback();
throw $e;
}
}
} | php | public function delete(CategoryDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) {
$con = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
$fileList = ['images' => [], 'documentList' => []];
// Get category's files to delete after category deletion
$fileList['images']['list'] = CategoryImageQuery::create()
->findByCategoryId($event->getCategoryId());
$fileList['images']['type'] = TheliaEvents::IMAGE_DELETE;
$fileList['documentList']['list'] = CategoryDocumentQuery::create()
->findByCategoryId($event->getCategoryId());
$fileList['documentList']['type'] = TheliaEvents::DOCUMENT_DELETE;
// Delete category
$category
->setDispatcher($dispatcher)
->delete($con);
$event->setCategory($category);
// Dispatch delete category's files event
foreach ($fileList as $fileTypeList) {
foreach ($fileTypeList['list'] as $fileToDelete) {
$fileDeleteEvent = new FileDeleteEvent($fileToDelete);
$dispatcher->dispatch($fileTypeList['type'], $fileDeleteEvent);
}
}
$con->commit();
} catch (\Exception $e) {
$con->rollback();
throw $e;
}
}
} | [
"public",
"function",
"delete",
"(",
"CategoryDeleteEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"category",
"=",
"CategoryQuery",
"::",
"create",
"(",
")",
"->",
"f... | Delete a category entry
@param \Thelia\Core\Event\Category\CategoryDeleteEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher
@throws \Exception | [
"Delete",
"a",
"category",
"entry"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Category.php#L114-L153 | train |
thelia/core | lib/Thelia/Action/Category.php | Category.toggleVisibility | public function toggleVisibility(CategoryToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$category = $event->getCategory();
$category
->setDispatcher($dispatcher)
->setVisible($category->getVisible() ? false : true)
->save()
;
$event->setCategory($category);
} | php | public function toggleVisibility(CategoryToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$category = $event->getCategory();
$category
->setDispatcher($dispatcher)
->setVisible($category->getVisible() ? false : true)
->save()
;
$event->setCategory($category);
} | [
"public",
"function",
"toggleVisibility",
"(",
"CategoryToggleVisibilityEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"category",
"=",
"$",
"event",
"->",
"getCategory",
"(",
")",
";",
"$",
"categ... | Toggle category visibility. No form used here
@param CategoryToggleVisibilityEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Toggle",
"category",
"visibility",
".",
"No",
"form",
"used",
"here"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Category.php#L162-L173 | train |
thelia/core | lib/Thelia/Action/Category.php | Category.viewCheck | public function viewCheck(ViewCheckEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if ($event->getView() == 'category') {
$category = CategoryQuery::create()
->filterById($event->getViewId())
->filterByVisible(1)
->count();
if ($category == 0) {
$dispatcher->dispatch(TheliaEvents::VIEW_CATEGORY_ID_NOT_VISIBLE, $event);
}
}
} | php | public function viewCheck(ViewCheckEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if ($event->getView() == 'category') {
$category = CategoryQuery::create()
->filterById($event->getViewId())
->filterByVisible(1)
->count();
if ($category == 0) {
$dispatcher->dispatch(TheliaEvents::VIEW_CATEGORY_ID_NOT_VISIBLE, $event);
}
}
} | [
"public",
"function",
"viewCheck",
"(",
"ViewCheckEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"getView",
"(",
")",
"==",
"'category'",
")",
"{",
"$",
"category",
... | Check if is a category view and if category_id is visible
@param ViewCheckEvent $event
@param string $eventName
@param EventDispatcherInterface $dispatcher | [
"Check",
"if",
"is",
"a",
"category",
"view",
"and",
"if",
"category_id",
"is",
"visible"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Category.php#L224-L236 | train |
melisplatform/melis-cms | src/Controller/SiteController.php | SiteController.renderToolSiteHeaderAction | public function renderToolSiteHeaderAction() {
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
$melisKey = $this->params()->fromRoute('melisKey', '');
$melisTool->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY);
$view = new ViewModel();
$view->title = $melisTool->getTitle();
return $view;
} | php | public function renderToolSiteHeaderAction() {
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
$melisKey = $this->params()->fromRoute('melisKey', '');
$melisTool->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY);
$view = new ViewModel();
$view->title = $melisTool->getTitle();
return $view;
} | [
"public",
"function",
"renderToolSiteHeaderAction",
"(",
")",
"{",
"$",
"melisTool",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreTool'",
")",
";",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
... | Renders to the header section of the tool
@return \Zend\View\Model\ViewModel | [
"Renders",
"to",
"the",
"header",
"section",
"of",
"the",
"tool"
] | ed470338f4c7653fd93e530013ab934eb7a52b6f | https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/SiteController.php#L62-L73 | train |
melisplatform/melis-cms | src/Controller/SiteController.php | SiteController.renderToolSiteModalAddAction | public function renderToolSiteModalAddAction()
{
// declare the Tool service that we will be using to completely create our tool.
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
// tell the Tool what configuration in the app.tool.php that will be used.
$melisTool->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY);
$view = new ViewModel();
$view->setVariable('meliscms_site_tool_creation_form', $melisTool->getForm('meliscms_site_tool_creation_form'));
return $view;
} | php | public function renderToolSiteModalAddAction()
{
// declare the Tool service that we will be using to completely create our tool.
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
// tell the Tool what configuration in the app.tool.php that will be used.
$melisTool->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY);
$view = new ViewModel();
$view->setVariable('meliscms_site_tool_creation_form', $melisTool->getForm('meliscms_site_tool_creation_form'));
return $view;
} | [
"public",
"function",
"renderToolSiteModalAddAction",
"(",
")",
"{",
"// declare the Tool service that we will be using to completely create our tool.",
"$",
"melisTool",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreTool'",
")",
";",
... | Displays the add form in the modal
@return \Zend\View\Model\ViewModel | [
"Displays",
"the",
"add",
"form",
"in",
"the",
"modal"
] | ed470338f4c7653fd93e530013ab934eb7a52b6f | https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/SiteController.php#L186-L199 | train |
melisplatform/melis-cms | src/Controller/SiteController.php | SiteController.getSiteDomainPlatform | public function getSiteDomainPlatform()
{
$data = array();
if($this->getRequest()->isGet()){
$siteDomain = $this->getServiceLocator()->get('SiteDomain');
$data = $siteDomain->getSiteDomain();
}
return $data;
} | php | public function getSiteDomainPlatform()
{
$data = array();
if($this->getRequest()->isGet()){
$siteDomain = $this->getServiceLocator()->get('SiteDomain');
$data = $siteDomain->getSiteDomain();
}
return $data;
} | [
"public",
"function",
"getSiteDomainPlatform",
"(",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"isGet",
"(",
")",
")",
"{",
"$",
"siteDomain",
"=",
"$",
"this",
"->",
"getServiceLoc... | Return site domain
return array() | [
"Return",
"site",
"domain"
] | ed470338f4c7653fd93e530013ab934eb7a52b6f | https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/SiteController.php#L344-L356 | train |
melisplatform/melis-cms | src/Controller/SiteController.php | SiteController.getSiteEnvironmentAction | public function getSiteEnvironmentAction()
{
$json = array();
$siteId = (int) $this->params()->fromQuery('siteId');
$melisEngineTableSiteDomain = $this->getServiceLocator()->get('MelisEngineTableSiteDomain');
$sitePlatform = $melisEngineTableSiteDomain->getEntryByField('sdom_site_id', $siteId);
$sitePlatform = $sitePlatform->current();
$siteDomainEnv = ($sitePlatform) ? $sitePlatform->sdom_env : null;
return new JsonModel(array('data' => $siteDomainEnv));
} | php | public function getSiteEnvironmentAction()
{
$json = array();
$siteId = (int) $this->params()->fromQuery('siteId');
$melisEngineTableSiteDomain = $this->getServiceLocator()->get('MelisEngineTableSiteDomain');
$sitePlatform = $melisEngineTableSiteDomain->getEntryByField('sdom_site_id', $siteId);
$sitePlatform = $sitePlatform->current();
$siteDomainEnv = ($sitePlatform) ? $sitePlatform->sdom_env : null;
return new JsonModel(array('data' => $siteDomainEnv));
} | [
"public",
"function",
"getSiteEnvironmentAction",
"(",
")",
"{",
"$",
"json",
"=",
"array",
"(",
")",
";",
"$",
"siteId",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromQuery",
"(",
"'siteId'",
")",
";",
"$",
"melisEngineTableS... | Fetching Current Platform on specific Site
@return Json - Name of the Platform | [
"Fetching",
"Current",
"Platform",
"on",
"specific",
"Site"
] | ed470338f4c7653fd93e530013ab934eb7a52b6f | https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/SiteController.php#L636-L648 | train |
melisplatform/melis-cms | src/Controller/SiteController.php | SiteController.getSiteEnvironmentsAction | public function getSiteEnvironmentsAction()
{
$json = array();
$siteId = (int) $this->params()->fromQuery('siteId');
$domainTable = $this->getServiceLocator()->get('MelisCoreTablePlatform');
$domainData = $domainTable->fetchAll();
$domainData = $domainData->toArray();
if($domainData) {
foreach($domainData as $domainValues) {
$json[] = $domainValues['plf_name'];
}
}
return new JsonModel(array('data' => $json));
} | php | public function getSiteEnvironmentsAction()
{
$json = array();
$siteId = (int) $this->params()->fromQuery('siteId');
$domainTable = $this->getServiceLocator()->get('MelisCoreTablePlatform');
$domainData = $domainTable->fetchAll();
$domainData = $domainData->toArray();
if($domainData) {
foreach($domainData as $domainValues) {
$json[] = $domainValues['plf_name'];
}
}
return new JsonModel(array('data' => $json));
} | [
"public",
"function",
"getSiteEnvironmentsAction",
"(",
")",
"{",
"$",
"json",
"=",
"array",
"(",
")",
";",
"$",
"siteId",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromQuery",
"(",
"'siteId'",
")",
";",
"$",
"domainTable",
... | Fetching all Core Platforms
@return Json | [
"Fetching",
"all",
"Core",
"Platforms"
] | ed470338f4c7653fd93e530013ab934eb7a52b6f | https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/SiteController.php#L654-L670 | train |
melisplatform/melis-cms | src/Controller/SiteController.php | SiteController.deleteSiteByIdAction | public function deleteSiteByIdAction()
{
$translator = $this->getServiceLocator()->get('translator');
$request = $this->getRequest();
$domainId = null;
$success = 0;
$textTitle = 'tr_meliscms_tool_site';
$textMessage = '';
$eventDatas = array();
$this->getEventManager()->trigger('meliscms_site_delete_by_id_start', $this, $eventDatas);
if($request->isPost()) {
$domainTable = $this->getServiceLocator()->get('MelisEngineTableSiteDomain');
$site404Table = $this->getServiceLocator()->get('MelisEngineTableSite404');
$siteID = (int) $request->getPost('siteid');
$siteEnv = $request->getPost('env');
$site404PageId = $request->getPost('site404Page');
$domainData = $domainTable->getDataBySiteIdAndEnv($siteID,$siteEnv);
$domainData = $domainData->current();
if($domainData)
{
$domainId = $domainData->sdom_id;
$domainTable->deleteByField('sdom_id', $domainId);
$success = 1;
$textMessage = 'tr_meliscms_tool_site_delete_env_success';
}
else
{
$textMessage = 'tr_meliscms_tool_site_delete_env_failed';
}
}
$response = array(
'success' => $success,
'textTitle' => $textTitle,
'textMessage' => $textMessage,
);
$this->getEventManager()->trigger('meliscms_site_delete_by_id_end', $this, array_merge($response, array('typeCode' => 'CMS_SITE_ENV_DELETE', 'itemId' => $domainId)));
return new JsonModel($response);
} | php | public function deleteSiteByIdAction()
{
$translator = $this->getServiceLocator()->get('translator');
$request = $this->getRequest();
$domainId = null;
$success = 0;
$textTitle = 'tr_meliscms_tool_site';
$textMessage = '';
$eventDatas = array();
$this->getEventManager()->trigger('meliscms_site_delete_by_id_start', $this, $eventDatas);
if($request->isPost()) {
$domainTable = $this->getServiceLocator()->get('MelisEngineTableSiteDomain');
$site404Table = $this->getServiceLocator()->get('MelisEngineTableSite404');
$siteID = (int) $request->getPost('siteid');
$siteEnv = $request->getPost('env');
$site404PageId = $request->getPost('site404Page');
$domainData = $domainTable->getDataBySiteIdAndEnv($siteID,$siteEnv);
$domainData = $domainData->current();
if($domainData)
{
$domainId = $domainData->sdom_id;
$domainTable->deleteByField('sdom_id', $domainId);
$success = 1;
$textMessage = 'tr_meliscms_tool_site_delete_env_success';
}
else
{
$textMessage = 'tr_meliscms_tool_site_delete_env_failed';
}
}
$response = array(
'success' => $success,
'textTitle' => $textTitle,
'textMessage' => $textMessage,
);
$this->getEventManager()->trigger('meliscms_site_delete_by_id_end', $this, array_merge($response, array('typeCode' => 'CMS_SITE_ENV_DELETE', 'itemId' => $domainId)));
return new JsonModel($response);
} | [
"public",
"function",
"deleteSiteByIdAction",
"(",
")",
"{",
"$",
"translator",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'translator'",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
... | Deletes the specific information of an environment
@return \Zend\View\Model\JsonModel | [
"Deletes",
"the",
"specific",
"information",
"of",
"an",
"environment"
] | ed470338f4c7653fd93e530013ab934eb7a52b6f | https://github.com/melisplatform/melis-cms/blob/ed470338f4c7653fd93e530013ab934eb7a52b6f/src/Controller/SiteController.php#L676-L724 | train |
grom358/pharborist | src/Namespaces/UseDeclarationNode.php | UseDeclarationNode.setAlias | public function setAlias($alias) {
if (is_string($alias)) {
$alias = new TokenNode(T_STRING, $alias);
}
if ($alias instanceof TokenNode) {
if ($this->hasAlias()) {
$this->alias->replaceWith($alias);
}
else {
$this->alias = $alias;
$this->addChild(WhitespaceNode::create(' '));
$this->addChild(Token::_as());
$this->addChild(WhitespaceNode::create(' '));
$this->addChild($alias, 'alias');
}
}
elseif ($alias === NULL && $this->hasAlias()) {
$this->alias->previousUntil(Filter::isInstanceOf('\Pharborist\Namespaces\NameNode'))->remove();
$this->alias->remove();
$this->alias = NULL;
}
else {
throw new \InvalidArgumentException();
}
return $this;
} | php | public function setAlias($alias) {
if (is_string($alias)) {
$alias = new TokenNode(T_STRING, $alias);
}
if ($alias instanceof TokenNode) {
if ($this->hasAlias()) {
$this->alias->replaceWith($alias);
}
else {
$this->alias = $alias;
$this->addChild(WhitespaceNode::create(' '));
$this->addChild(Token::_as());
$this->addChild(WhitespaceNode::create(' '));
$this->addChild($alias, 'alias');
}
}
elseif ($alias === NULL && $this->hasAlias()) {
$this->alias->previousUntil(Filter::isInstanceOf('\Pharborist\Namespaces\NameNode'))->remove();
$this->alias->remove();
$this->alias = NULL;
}
else {
throw new \InvalidArgumentException();
}
return $this;
} | [
"public",
"function",
"setAlias",
"(",
"$",
"alias",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"alias",
")",
")",
"{",
"$",
"alias",
"=",
"new",
"TokenNode",
"(",
"T_STRING",
",",
"$",
"alias",
")",
";",
"}",
"if",
"(",
"$",
"alias",
"instanceof"... | Sets the imported item's alias. If NULL is passed, the alias is removed.
@param \Pharborist\TokenNode|string|NULL $alias
@return $this | [
"Sets",
"the",
"imported",
"item",
"s",
"alias",
".",
"If",
"NULL",
"is",
"passed",
"the",
"alias",
"is",
"removed",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Namespaces/UseDeclarationNode.php#L72-L99 | train |
grom358/pharborist | src/Namespaces/UseDeclarationNode.php | UseDeclarationNode.getBoundedName | public function getBoundedName() {
if ($this->alias) {
return $this->alias->getText();
}
else {
return $this->name->lastChild()->getText();
}
} | php | public function getBoundedName() {
if ($this->alias) {
return $this->alias->getText();
}
else {
return $this->name->lastChild()->getText();
}
} | [
"public",
"function",
"getBoundedName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"alias",
")",
"{",
"return",
"$",
"this",
"->",
"alias",
"->",
"getText",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"name",
"->",
"lastChild",
... | Name bounded inside namespace.
@return string | [
"Name",
"bounded",
"inside",
"namespace",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Namespaces/UseDeclarationNode.php#L142-L149 | train |
thelia/core | lib/Thelia/Action/Order.php | Order.orderCartClear | public function orderCartClear(/** @noinspection PhpUnusedParameterInspection */ OrderEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
// Empty cart and clear current order
$session = $this->getSession();
$session->clearSessionCart($dispatcher);
$session->setOrder(new OrderModel());
} | php | public function orderCartClear(/** @noinspection PhpUnusedParameterInspection */ OrderEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
// Empty cart and clear current order
$session = $this->getSession();
$session->clearSessionCart($dispatcher);
$session->setOrder(new OrderModel());
} | [
"public",
"function",
"orderCartClear",
"(",
"/** @noinspection PhpUnusedParameterInspection */",
"OrderEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"// Empty cart and clear current order",
"$",
"session",
"=",
"... | Clear the cart and the order in the customer session once the order is placed,
and the payment performed.
@param OrderEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher | [
"Clear",
"the",
"cart",
"and",
"the",
"order",
"in",
"the",
"customer",
"session",
"once",
"the",
"order",
"is",
"placed",
"and",
"the",
"payment",
"performed",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Order.php#L473-L481 | train |
thelia/core | lib/Thelia/Action/Order.php | Order.getStockUpdateOnOrderStatusChange | public function getStockUpdateOnOrderStatusChange(GetStockUpdateOperationOnOrderStatusChangeEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
// The order
$order = $event->getOrder();
// The new order status
$newStatus = $event->getNewOrderStatus();
if ($newStatus->getId() !== $order->getStatusId()) {
// We have to change the stock in the following cases :
// 1) The order is currently paid, and will become unpaid (get products back in stock unconditionnaly)
// 2) The order is currently unpaid, and will become paid (remove products from stock, except if was done at order creation $manageStockOnCreation == false)
// 3) The order is currently NOT PAID, and will become canceled or the like (get products back in stock if it was done at order creation $manageStockOnCreation == true)
// We consider the ManageStockOnCreation flag only if the order status as not yet changed.
// Count distinct order statuses (e.g. NOT_PAID to something else) in the order version table.
if (OrderVersionQuery::create()->groupByStatusId()->filterById($order->getId())->count() > 1) {
// A status change occured. Ignore $manageStockOnCreation
$manageStockOnCreation = false;
} else {
// A status has not yet occured. Consider the ManageStockOnCreation flag
$manageStockOnCreation = $order->isStockManagedOnOrderCreation($dispatcher);
}
if (($order->isPaid(false) && $newStatus->isNotPaid(false)) // Case 1
||
($order->isNotPaid(true) && $newStatus->isNotPaid(false) && $manageStockOnCreation === true) // Case 3
) {
$event->setOperation($event::INCREASE_STOCK);
}
if ($order->isNotPaid(false) // Case 2
&&
$newStatus->isPaid(false)
&&
$manageStockOnCreation === false) {
$event->setOperation($event::DECREASE_STOCK);
}
Tlog::getInstance()->addInfo(
"Checking stock operation for status change of order : " . $order->getRef()
. ", version: " . $order->getVersion()
. ", manageStockOnCreation: " . ($manageStockOnCreation ? 0 : 1)
. ", paid:" . ($order->isPaid(false) ? 1 : 0)
. ", is not paid:" . ($order->isNotPaid(false) ? 1 : 0)
. ", new status paid:" . ($newStatus->isPaid(false) ? 1 : 0)
. ", new status is not paid:" . ($newStatus->isNotPaid(false) ? 1 : 0)
. " = operation: " . $event->getOperation()
);
}
} | php | public function getStockUpdateOnOrderStatusChange(GetStockUpdateOperationOnOrderStatusChangeEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
// The order
$order = $event->getOrder();
// The new order status
$newStatus = $event->getNewOrderStatus();
if ($newStatus->getId() !== $order->getStatusId()) {
// We have to change the stock in the following cases :
// 1) The order is currently paid, and will become unpaid (get products back in stock unconditionnaly)
// 2) The order is currently unpaid, and will become paid (remove products from stock, except if was done at order creation $manageStockOnCreation == false)
// 3) The order is currently NOT PAID, and will become canceled or the like (get products back in stock if it was done at order creation $manageStockOnCreation == true)
// We consider the ManageStockOnCreation flag only if the order status as not yet changed.
// Count distinct order statuses (e.g. NOT_PAID to something else) in the order version table.
if (OrderVersionQuery::create()->groupByStatusId()->filterById($order->getId())->count() > 1) {
// A status change occured. Ignore $manageStockOnCreation
$manageStockOnCreation = false;
} else {
// A status has not yet occured. Consider the ManageStockOnCreation flag
$manageStockOnCreation = $order->isStockManagedOnOrderCreation($dispatcher);
}
if (($order->isPaid(false) && $newStatus->isNotPaid(false)) // Case 1
||
($order->isNotPaid(true) && $newStatus->isNotPaid(false) && $manageStockOnCreation === true) // Case 3
) {
$event->setOperation($event::INCREASE_STOCK);
}
if ($order->isNotPaid(false) // Case 2
&&
$newStatus->isPaid(false)
&&
$manageStockOnCreation === false) {
$event->setOperation($event::DECREASE_STOCK);
}
Tlog::getInstance()->addInfo(
"Checking stock operation for status change of order : " . $order->getRef()
. ", version: " . $order->getVersion()
. ", manageStockOnCreation: " . ($manageStockOnCreation ? 0 : 1)
. ", paid:" . ($order->isPaid(false) ? 1 : 0)
. ", is not paid:" . ($order->isNotPaid(false) ? 1 : 0)
. ", new status paid:" . ($newStatus->isPaid(false) ? 1 : 0)
. ", new status is not paid:" . ($newStatus->isNotPaid(false) ? 1 : 0)
. " = operation: " . $event->getOperation()
);
}
} | [
"public",
"function",
"getStockUpdateOnOrderStatusChange",
"(",
"GetStockUpdateOperationOnOrderStatusChangeEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"// The order",
"$",
"order",
"=",
"$",
"event",
"->",
"... | Check if a stock update is required on order products for a given order status change, and compute if
the stock should be decreased or increased.
@param GetStockUpdateOperationOnOrderStatusChangeEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher
@throws \Propel\Runtime\Exception\PropelException | [
"Check",
"if",
"a",
"stock",
"update",
"is",
"required",
"on",
"order",
"products",
"for",
"a",
"given",
"order",
"status",
"change",
"and",
"compute",
"if",
"the",
"stock",
"should",
"be",
"decreased",
"or",
"increased",
"."
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Order.php#L557-L607 | train |
thelia/core | lib/Thelia/Action/Order.php | Order.updateQuantity | protected function updateQuantity(ModelOrder $order, $newStatus, EventDispatcherInterface $dispatcher)
{
if ($newStatus !== $order->getStatusId()) {
if (null !== $newStatusModel = OrderStatusQuery::create()->findPk($newStatus)) {
$operationEvent = new GetStockUpdateOperationOnOrderStatusChangeEvent($order, $newStatusModel);
$dispatcher->dispatch(
TheliaEvents::ORDER_GET_STOCK_UPDATE_OPERATION_ON_ORDER_STATUS_CHANGE,
$operationEvent
);
if ($operationEvent->getOperation() !== $operationEvent::DO_NOTHING) {
$orderProductList = $order->getOrderProducts();
/** @var OrderProduct $orderProduct */
foreach ($orderProductList as $orderProduct) {
$productSaleElementsId = $orderProduct->getProductSaleElementsId();
/** @var ProductSaleElements $productSaleElements */
if (null !== $productSaleElements = ProductSaleElementsQuery::create()->findPk($productSaleElementsId)) {
$offset = 0;
if ($operationEvent->getOperation() == $operationEvent::INCREASE_STOCK) {
$offset = $orderProduct->getQuantity();
} elseif ($operationEvent->getOperation() == $operationEvent::DECREASE_STOCK) {
/* Check if we have enough stock */
if ($orderProduct->getQuantity() > $productSaleElements->getQuantity() && true === ConfigQuery::checkAvailableStock()) {
throw new TheliaProcessException($productSaleElements->getRef() . " : Not enough stock 2");
}
$offset = -$orderProduct->getQuantity();
}
Tlog::getInstance()->addError("Product stock: " . $productSaleElements->getQuantity() . " -> " . ($productSaleElements->getQuantity() + $offset));
$productSaleElements
->setQuantity($productSaleElements->getQuantity() + $offset)
->save();
}
}
}
}
}
} | php | protected function updateQuantity(ModelOrder $order, $newStatus, EventDispatcherInterface $dispatcher)
{
if ($newStatus !== $order->getStatusId()) {
if (null !== $newStatusModel = OrderStatusQuery::create()->findPk($newStatus)) {
$operationEvent = new GetStockUpdateOperationOnOrderStatusChangeEvent($order, $newStatusModel);
$dispatcher->dispatch(
TheliaEvents::ORDER_GET_STOCK_UPDATE_OPERATION_ON_ORDER_STATUS_CHANGE,
$operationEvent
);
if ($operationEvent->getOperation() !== $operationEvent::DO_NOTHING) {
$orderProductList = $order->getOrderProducts();
/** @var OrderProduct $orderProduct */
foreach ($orderProductList as $orderProduct) {
$productSaleElementsId = $orderProduct->getProductSaleElementsId();
/** @var ProductSaleElements $productSaleElements */
if (null !== $productSaleElements = ProductSaleElementsQuery::create()->findPk($productSaleElementsId)) {
$offset = 0;
if ($operationEvent->getOperation() == $operationEvent::INCREASE_STOCK) {
$offset = $orderProduct->getQuantity();
} elseif ($operationEvent->getOperation() == $operationEvent::DECREASE_STOCK) {
/* Check if we have enough stock */
if ($orderProduct->getQuantity() > $productSaleElements->getQuantity() && true === ConfigQuery::checkAvailableStock()) {
throw new TheliaProcessException($productSaleElements->getRef() . " : Not enough stock 2");
}
$offset = -$orderProduct->getQuantity();
}
Tlog::getInstance()->addError("Product stock: " . $productSaleElements->getQuantity() . " -> " . ($productSaleElements->getQuantity() + $offset));
$productSaleElements
->setQuantity($productSaleElements->getQuantity() + $offset)
->save();
}
}
}
}
}
} | [
"protected",
"function",
"updateQuantity",
"(",
"ModelOrder",
"$",
"order",
",",
"$",
"newStatus",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"$",
"newStatus",
"!==",
"$",
"order",
"->",
"getStatusId",
"(",
")",
")",
"{",
"if",
... | Update order products stock after an order status change
@param OrderModel $order
@param int $newStatus the new status ID
@throws \Exception
@throws \Propel\Runtime\Exception\PropelException | [
"Update",
"order",
"products",
"stock",
"after",
"an",
"order",
"status",
"change"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Order.php#L617-L660 | train |
BoldGrid/library | src/Library/Key/PostNewKey.php | PostNewKey.admin_notices | public function admin_notices() {
$afterKeyAdded = get_option( $this->option );
if ( empty( $afterKeyAdded ) ) {
return;
}
switch( $afterKeyAdded ) {
case 'success':
echo '<div class="notice notice-success is-dismissible bglib-key-added"><p>' .
esc_html( 'Your new BoldGrid Connect Key has been successfully added!', 'boldgrid-library' ) .
'</p></div>';
break;
case 'fail':
echo '<div class="notice notice-error is-dismissible bglib-key-added"><p>' .
esc_html( 'An unknown error occurred adding your new BoldGrid Connect Key.', 'boldgrid-library' ) .
'</p></div>';
break;
}
delete_option( $this->option );
} | php | public function admin_notices() {
$afterKeyAdded = get_option( $this->option );
if ( empty( $afterKeyAdded ) ) {
return;
}
switch( $afterKeyAdded ) {
case 'success':
echo '<div class="notice notice-success is-dismissible bglib-key-added"><p>' .
esc_html( 'Your new BoldGrid Connect Key has been successfully added!', 'boldgrid-library' ) .
'</p></div>';
break;
case 'fail':
echo '<div class="notice notice-error is-dismissible bglib-key-added"><p>' .
esc_html( 'An unknown error occurred adding your new BoldGrid Connect Key.', 'boldgrid-library' ) .
'</p></div>';
break;
}
delete_option( $this->option );
} | [
"public",
"function",
"admin_notices",
"(",
")",
"{",
"$",
"afterKeyAdded",
"=",
"get_option",
"(",
"$",
"this",
"->",
"option",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"afterKeyAdded",
")",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"$",
"afterKeyAd... | Admin notices.
If the user's key was successfully added, we need to show an admin notice.
@since 1.8.0 | [
"Admin",
"notices",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Key/PostNewKey.php#L53-L74 | train |
BoldGrid/library | src/Library/Key/PostNewKey.php | PostNewKey.getCentralUrl | public static function getCentralUrl() {
/**
* Allow the return url to be filtered.
*
* The return url is the url that BoldGrid Central will link the user to after they received
* their new BoldGrid Connect Key.
*
* By default, we will link them to Dashboard > Settings > BoldGrid Connect. However,
* with this filter plugins can change this url.
*
* @since 2.8.0
*
* @param string URL to the BoldGrid Connect settings page.
*/
$returnUrl = apply_filters( 'Boldgrid\Library\Key\returnUrl', admin_url( 'options-general.php?page=boldgrid-connect.php' ) );
$returnUrl = add_query_arg( 'nonce', wp_create_nonce( 'bglib-key-prompt' ), $returnUrl );
// Create the final url and return it.
return add_query_arg(
array(
'wp-url' => urlencode( $returnUrl ),
),
Configs::get( 'getNewKey' )
);
} | php | public static function getCentralUrl() {
/**
* Allow the return url to be filtered.
*
* The return url is the url that BoldGrid Central will link the user to after they received
* their new BoldGrid Connect Key.
*
* By default, we will link them to Dashboard > Settings > BoldGrid Connect. However,
* with this filter plugins can change this url.
*
* @since 2.8.0
*
* @param string URL to the BoldGrid Connect settings page.
*/
$returnUrl = apply_filters( 'Boldgrid\Library\Key\returnUrl', admin_url( 'options-general.php?page=boldgrid-connect.php' ) );
$returnUrl = add_query_arg( 'nonce', wp_create_nonce( 'bglib-key-prompt' ), $returnUrl );
// Create the final url and return it.
return add_query_arg(
array(
'wp-url' => urlencode( $returnUrl ),
),
Configs::get( 'getNewKey' )
);
} | [
"public",
"static",
"function",
"getCentralUrl",
"(",
")",
"{",
"/**\n\t\t * Allow the return url to be filtered.\n\t\t *\n\t\t * The return url is the url that BoldGrid Central will link the user to after they received\n\t\t * their new BoldGrid Connect Key.\n\t\t *\n\t\t * By default, we will link t... | Get the url to BoldGrid Central for the user to get a new Connect Key.
@since 2.8.0
@return string | [
"Get",
"the",
"url",
"to",
"BoldGrid",
"Central",
"for",
"the",
"user",
"to",
"get",
"a",
"new",
"Connect",
"Key",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Key/PostNewKey.php#L83-L108 | train |
BoldGrid/library | src/Library/Key/PostNewKey.php | PostNewKey.processPost | public function processPost() {
if ( $this->isPosting() ) {
$releaseChannel = new ReleaseChannel;
$key = new Key( $releaseChannel );
$hashed_key = md5( $_POST['activateKey'] );
$success = $key->addKey( $hashed_key );
/*
* This option is used to setup an event similiar to WordPress' after_switch_theme hook.
* It allows us to take action on the page load following a new Connect Key being added.
*/
update_option( $this->option, $success ? 'success' : 'fail' );
/*
* Refersh the current page so that when it reloads the new page begins with the user
* having a Connect Key installed. Otherwise, the current page will load and propmpt the
* user for a key even though we've just added one.
*/
header( 'Refresh:0' );
exit;
}
} | php | public function processPost() {
if ( $this->isPosting() ) {
$releaseChannel = new ReleaseChannel;
$key = new Key( $releaseChannel );
$hashed_key = md5( $_POST['activateKey'] );
$success = $key->addKey( $hashed_key );
/*
* This option is used to setup an event similiar to WordPress' after_switch_theme hook.
* It allows us to take action on the page load following a new Connect Key being added.
*/
update_option( $this->option, $success ? 'success' : 'fail' );
/*
* Refersh the current page so that when it reloads the new page begins with the user
* having a Connect Key installed. Otherwise, the current page will load and propmpt the
* user for a key even though we've just added one.
*/
header( 'Refresh:0' );
exit;
}
} | [
"public",
"function",
"processPost",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isPosting",
"(",
")",
")",
"{",
"$",
"releaseChannel",
"=",
"new",
"ReleaseChannel",
";",
"$",
"key",
"=",
"new",
"Key",
"(",
"$",
"releaseChannel",
")",
";",
"$",
"ha... | Handle the submission of an api key via a post call.
@since 2.8.0
@hook admin_init | [
"Handle",
"the",
"submission",
"of",
"an",
"api",
"key",
"via",
"a",
"post",
"call",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Key/PostNewKey.php#L117-L141 | train |
BoldGrid/library | src/Library/Key/PostNewKey.php | PostNewKey.isPosting | private function isPosting() {
if ( empty( $_POST['activateKey'] ) ) {
return false;
}
if ( empty( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'bglib-key-prompt') ) {
return false;
}
if ( ! current_user_can( 'update_plugins' ) ) {
return false;
}
return true;
} | php | private function isPosting() {
if ( empty( $_POST['activateKey'] ) ) {
return false;
}
if ( empty( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'bglib-key-prompt') ) {
return false;
}
if ( ! current_user_can( 'update_plugins' ) ) {
return false;
}
return true;
} | [
"private",
"function",
"isPosting",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"_POST",
"[",
"'activateKey'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"_GET",
"[",
"'nonce'",
"]",
")",
"||",
"!",
"wp_verify_n... | Determine whether or not we are posting a new Connect Key to the dashboard.
@since 2.8.0
@return bool | [
"Determine",
"whether",
"or",
"not",
"we",
"are",
"posting",
"a",
"new",
"Connect",
"Key",
"to",
"the",
"dashboard",
"."
] | 51afe070e211cff9cf78454ff97912a0d943805c | https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Key/PostNewKey.php#L150-L164 | train |
thelia/core | lib/Thelia/Tools/Rest/ResponseRest.php | ResponseRest.setRestContent | public function setRestContent($data)
{
$serializer = $this->getSerializer();
if (isset($data)) {
$this->setContent($serializer->serialize($data, $this->format));
}
return $this;
} | php | public function setRestContent($data)
{
$serializer = $this->getSerializer();
if (isset($data)) {
$this->setContent($serializer->serialize($data, $this->format));
}
return $this;
} | [
"public",
"function",
"setRestContent",
"(",
"$",
"data",
")",
"{",
"$",
"serializer",
"=",
"$",
"this",
"->",
"getSerializer",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"setContent",
"(",
"$",
"serializer... | Set Content to be serialized in the response, array or object
@param array $data array or object to be serialized
@return $this | [
"Set",
"Content",
"to",
"be",
"serialized",
"in",
"the",
"response",
"array",
"or",
"object"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Tools/Rest/ResponseRest.php#L74-L83 | train |
grom358/pharborist | src/Namespaces/NameNode.php | NameNode.create | public static function create($name) {
$parts = explode('\\', $name);
$name_node = new NameNode();
foreach ($parts as $i => $part) {
$part = trim($part);
if ($i > 0) {
$name_node->append(Token::namespaceSeparator());
}
if ($part !== '') {
$name_node->append(Token::identifier($part));
}
}
return $name_node;
} | php | public static function create($name) {
$parts = explode('\\', $name);
$name_node = new NameNode();
foreach ($parts as $i => $part) {
$part = trim($part);
if ($i > 0) {
$name_node->append(Token::namespaceSeparator());
}
if ($part !== '') {
$name_node->append(Token::identifier($part));
}
}
return $name_node;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"name",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"name",
")",
";",
"$",
"name_node",
"=",
"new",
"NameNode",
"(",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"i",
... | Create namespace path.
@param string $name
@return NameNode | [
"Create",
"namespace",
"path",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Namespaces/NameNode.php#L26-L39 | train |
grom358/pharborist | src/Namespaces/NameNode.php | NameNode.getPathInfo | public function getPathInfo() {
/** @var TokenNode $first */
$first = $this->firstChild();
$absolute = $first->getType() === T_NS_SEPARATOR;
$relative = $first->getType() === T_NAMESPACE;
$parts = $this->getParts();
return [
'absolute' => $absolute,
'relative' => $relative,
'qualified' => !$absolute && count($parts) > 1,
'unqualified' => !$absolute && count($parts) === 1,
'parts' => $parts,
];
} | php | public function getPathInfo() {
/** @var TokenNode $first */
$first = $this->firstChild();
$absolute = $first->getType() === T_NS_SEPARATOR;
$relative = $first->getType() === T_NAMESPACE;
$parts = $this->getParts();
return [
'absolute' => $absolute,
'relative' => $relative,
'qualified' => !$absolute && count($parts) > 1,
'unqualified' => !$absolute && count($parts) === 1,
'parts' => $parts,
];
} | [
"public",
"function",
"getPathInfo",
"(",
")",
"{",
"/** @var TokenNode $first */",
"$",
"first",
"=",
"$",
"this",
"->",
"firstChild",
"(",
")",
";",
"$",
"absolute",
"=",
"$",
"first",
"->",
"getType",
"(",
")",
"===",
"T_NS_SEPARATOR",
";",
"$",
"relati... | Return information about the name.
@return array | [
"Return",
"information",
"about",
"the",
"name",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Namespaces/NameNode.php#L79-L92 | train |
grom358/pharborist | src/Namespaces/NameNode.php | NameNode.getPath | public function getPath() {
$path = '';
/** @var TokenNode $child */
$child = $this->head;
while ($child) {
$type = $child->getType();
if ($type === T_NAMESPACE || $type === T_NS_SEPARATOR || $type === T_STRING) {
$path .= $child->getText();
}
$child = $child->next;
}
return $path;
} | php | public function getPath() {
$path = '';
/** @var TokenNode $child */
$child = $this->head;
while ($child) {
$type = $child->getType();
if ($type === T_NAMESPACE || $type === T_NS_SEPARATOR || $type === T_STRING) {
$path .= $child->getText();
}
$child = $child->next;
}
return $path;
} | [
"public",
"function",
"getPath",
"(",
")",
"{",
"$",
"path",
"=",
"''",
";",
"/** @var TokenNode $child */",
"$",
"child",
"=",
"$",
"this",
"->",
"head",
";",
"while",
"(",
"$",
"child",
")",
"{",
"$",
"type",
"=",
"$",
"child",
"->",
"getType",
"("... | Get the namespace path.
@return string | [
"Get",
"the",
"namespace",
"path",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Namespaces/NameNode.php#L159-L171 | train |
grom358/pharborist | src/Namespaces/NameNode.php | NameNode.resolveUnqualified | protected function resolveUnqualified($name) {
if ($this->parent instanceof NamespaceNode) {
return '\\' . $name;
}
if ($this->parent instanceof UseDeclarationNode) {
return '\\' . $name;
}
$namespace = $this->getNamespace();
$use_declarations = array();
if ($namespace) {
$use_declarations = $namespace->getBody()->getUseDeclarations();
}
else {
/** @var \Pharborist\RootNode $root_node */
$root_node = $this->closest(Filter::isInstanceOf('\Pharborist\RootNode'));
if ($root_node) {
$use_declarations = $root_node->getUseDeclarations();
}
}
if ($this->parent instanceof FunctionCallNode) {
/** @var UseDeclarationNode $use_declaration */
foreach ($use_declarations as $use_declaration) {
if ($use_declaration->isFunction() && $use_declaration->getBoundedName() === $name) {
return '\\' . $use_declaration->getName()->getPath();
}
}
return $this->getParentPath() . $name;
}
elseif ($this->parent instanceof ConstantNode) {
/** @var UseDeclarationNode $use_declaration */
foreach ($use_declarations as $use_declaration) {
if ($use_declaration->isConst() && $use_declaration->getBoundedName() === $name) {
return '\\' . $use_declaration->getName()->getPath();
}
}
return $this->getParentPath() . $name;
}
else {
// Name is a class reference.
/** @var UseDeclarationNode $use_declaration */
foreach ($use_declarations as $use_declaration) {
if ($use_declaration->isClass() && $use_declaration->getBoundedName() === $name) {
return '\\' . $use_declaration->getName()->getPath();
}
}
// No use declaration so class name refers to class in current namespace.
return $this->getParentPath() . $name;
}
} | php | protected function resolveUnqualified($name) {
if ($this->parent instanceof NamespaceNode) {
return '\\' . $name;
}
if ($this->parent instanceof UseDeclarationNode) {
return '\\' . $name;
}
$namespace = $this->getNamespace();
$use_declarations = array();
if ($namespace) {
$use_declarations = $namespace->getBody()->getUseDeclarations();
}
else {
/** @var \Pharborist\RootNode $root_node */
$root_node = $this->closest(Filter::isInstanceOf('\Pharborist\RootNode'));
if ($root_node) {
$use_declarations = $root_node->getUseDeclarations();
}
}
if ($this->parent instanceof FunctionCallNode) {
/** @var UseDeclarationNode $use_declaration */
foreach ($use_declarations as $use_declaration) {
if ($use_declaration->isFunction() && $use_declaration->getBoundedName() === $name) {
return '\\' . $use_declaration->getName()->getPath();
}
}
return $this->getParentPath() . $name;
}
elseif ($this->parent instanceof ConstantNode) {
/** @var UseDeclarationNode $use_declaration */
foreach ($use_declarations as $use_declaration) {
if ($use_declaration->isConst() && $use_declaration->getBoundedName() === $name) {
return '\\' . $use_declaration->getName()->getPath();
}
}
return $this->getParentPath() . $name;
}
else {
// Name is a class reference.
/** @var UseDeclarationNode $use_declaration */
foreach ($use_declarations as $use_declaration) {
if ($use_declaration->isClass() && $use_declaration->getBoundedName() === $name) {
return '\\' . $use_declaration->getName()->getPath();
}
}
// No use declaration so class name refers to class in current namespace.
return $this->getParentPath() . $name;
}
} | [
"protected",
"function",
"resolveUnqualified",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parent",
"instanceof",
"NamespaceNode",
")",
"{",
"return",
"'\\\\'",
".",
"$",
"name",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"parent",
"instanceo... | Resolve an unqualified name to fully qualified name.
@param string $name
The unqualified name to resolve.
@return string
Fully qualified name. | [
"Resolve",
"an",
"unqualified",
"name",
"to",
"fully",
"qualified",
"name",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Namespaces/NameNode.php#L182-L230 | train |
GrahamCampbell/Analyzer | src/ReferenceAnalyzer.php | ReferenceAnalyzer.analyze | public function analyze(string $path)
{
$contents = (string) file_get_contents($path);
$traverser = new NodeTraverser();
$traverser->addVisitor(new NameResolver());
$traverser->addVisitor($imports = new ImportVisitor());
$traverser->addVisitor($names = new NameVisitor());
$traverser->addVisitor($docs = DocVisitor::create($contents));
$traverser->traverse($this->parser->parse($contents));
return array_values(array_unique(array_merge(
$imports->getImports(),
$names->getNames(),
DocProcessor::process($docs->getDoc())
)));
} | php | public function analyze(string $path)
{
$contents = (string) file_get_contents($path);
$traverser = new NodeTraverser();
$traverser->addVisitor(new NameResolver());
$traverser->addVisitor($imports = new ImportVisitor());
$traverser->addVisitor($names = new NameVisitor());
$traverser->addVisitor($docs = DocVisitor::create($contents));
$traverser->traverse($this->parser->parse($contents));
return array_values(array_unique(array_merge(
$imports->getImports(),
$names->getNames(),
DocProcessor::process($docs->getDoc())
)));
} | [
"public",
"function",
"analyze",
"(",
"string",
"$",
"path",
")",
"{",
"$",
"contents",
"=",
"(",
"string",
")",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"$",
"traverser",
"=",
"new",
"NodeTraverser",
"(",
")",
";",
"$",
"traverser",
"->",
"add... | Get the fullyqualified imports and typehints.
@param string $path
@return string[] | [
"Get",
"the",
"fullyqualified",
"imports",
"and",
"typehints",
"."
] | e918797f052c001362bda65e7364026910608bef | https://github.com/GrahamCampbell/Analyzer/blob/e918797f052c001362bda65e7364026910608bef/src/ReferenceAnalyzer.php#L54-L72 | train |
grom358/pharborist | src/CommentNode.php | CommentNode.create | public static function create($comment) {
$comment = trim($comment);
$nl_count = substr_count($comment, "\n");
if ($nl_count > 1) {
return LineCommentBlockNode::create($comment);
}
else {
return new CommentNode(T_COMMENT, '// ' . $comment . "\n");
}
} | php | public static function create($comment) {
$comment = trim($comment);
$nl_count = substr_count($comment, "\n");
if ($nl_count > 1) {
return LineCommentBlockNode::create($comment);
}
else {
return new CommentNode(T_COMMENT, '// ' . $comment . "\n");
}
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"comment",
")",
"{",
"$",
"comment",
"=",
"trim",
"(",
"$",
"comment",
")",
";",
"$",
"nl_count",
"=",
"substr_count",
"(",
"$",
"comment",
",",
"\"\\n\"",
")",
";",
"if",
"(",
"$",
"nl_count",
">",... | Create line comment.
@param string $comment
Comment without leading prefix.
@return CommentNode|LineCommentBlockNode | [
"Create",
"line",
"comment",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/CommentNode.php#L57-L66 | train |
ElfSundae/laravel-bearychat | src/ClientManager.php | ClientManager.getWebhookForClient | public function getWebhookForClient($name)
{
return Arr::get($this->clientsConfig[$name], 'webhook') ?:
Arr::get($this->clientsDefaults, 'webhook');
} | php | public function getWebhookForClient($name)
{
return Arr::get($this->clientsConfig[$name], 'webhook') ?:
Arr::get($this->clientsDefaults, 'webhook');
} | [
"public",
"function",
"getWebhookForClient",
"(",
"$",
"name",
")",
"{",
"return",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"clientsConfig",
"[",
"$",
"name",
"]",
",",
"'webhook'",
")",
"?",
":",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"clien... | Get the webhook for the given client.
@param string $name
@return string | [
"Get",
"the",
"webhook",
"for",
"the",
"given",
"client",
"."
] | d4fd4948e6fd24af669e9916717b7446a6cdd7fa | https://github.com/ElfSundae/laravel-bearychat/blob/d4fd4948e6fd24af669e9916717b7446a6cdd7fa/src/ClientManager.php#L160-L164 | train |
ElfSundae/laravel-bearychat | src/ClientManager.php | ClientManager.getMessageDefaultsForClient | public function getMessageDefaultsForClient($name)
{
return array_merge(
Arr::get($this->clientsDefaults, 'message_defaults', []),
Arr::get($this->clientsConfig[$name], 'message_defaults', [])
);
} | php | public function getMessageDefaultsForClient($name)
{
return array_merge(
Arr::get($this->clientsDefaults, 'message_defaults', []),
Arr::get($this->clientsConfig[$name], 'message_defaults', [])
);
} | [
"public",
"function",
"getMessageDefaultsForClient",
"(",
"$",
"name",
")",
"{",
"return",
"array_merge",
"(",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"clientsDefaults",
",",
"'message_defaults'",
",",
"[",
"]",
")",
",",
"Arr",
"::",
"get",
"(",
"$",
... | Get the message defaults for the given client.
@param string $name
@return array | [
"Get",
"the",
"message",
"defaults",
"for",
"the",
"given",
"client",
"."
] | d4fd4948e6fd24af669e9916717b7446a6cdd7fa | https://github.com/ElfSundae/laravel-bearychat/blob/d4fd4948e6fd24af669e9916717b7446a6cdd7fa/src/ClientManager.php#L172-L178 | train |
nattreid/cms | src/Mailing/Mailer.php | Mailer.sendRestorePassword | public function sendRestorePassword(string $email, string $hash): void
{
$mail = $this->createMail('restorePassword');
$mail->link = $this->link('Cms:Sign:restorePassword', [
'hash' => $hash
]);
$mail->setSubject('cms.mailing.restorePassword.subject')
->addTo($email);
$mail->send();
} | php | public function sendRestorePassword(string $email, string $hash): void
{
$mail = $this->createMail('restorePassword');
$mail->link = $this->link('Cms:Sign:restorePassword', [
'hash' => $hash
]);
$mail->setSubject('cms.mailing.restorePassword.subject')
->addTo($email);
$mail->send();
} | [
"public",
"function",
"sendRestorePassword",
"(",
"string",
"$",
"email",
",",
"string",
"$",
"hash",
")",
":",
"void",
"{",
"$",
"mail",
"=",
"$",
"this",
"->",
"createMail",
"(",
"'restorePassword'",
")",
";",
"$",
"mail",
"->",
"link",
"=",
"$",
"th... | Odeslani linku pro zmenu hesla
@param string $email
@param string $hash
@throws \Nette\Application\UI\InvalidLinkException | [
"Odeslani",
"linku",
"pro",
"zmenu",
"hesla"
] | 28eae564c6a8cdaf01d32ff5a1dffba58232f9c1 | https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Mailing/Mailer.php#L23-L35 | train |
nattreid/cms | src/Mailing/Mailer.php | Mailer.sendNewUser | public function sendNewUser(string $email, string $username, string $password): void
{
$mail = $this->createMail('newUser');
$mail->link = $this->link('Cms:Sign:in');
$mail->username = $username;
$mail->password = $password;
$mail->setSubject('cms.mailing.newUser.subject')
->addTo($email);
$mail->send();
} | php | public function sendNewUser(string $email, string $username, string $password): void
{
$mail = $this->createMail('newUser');
$mail->link = $this->link('Cms:Sign:in');
$mail->username = $username;
$mail->password = $password;
$mail->setSubject('cms.mailing.newUser.subject')
->addTo($email);
$mail->send();
} | [
"public",
"function",
"sendNewUser",
"(",
"string",
"$",
"email",
",",
"string",
"$",
"username",
",",
"string",
"$",
"password",
")",
":",
"void",
"{",
"$",
"mail",
"=",
"$",
"this",
"->",
"createMail",
"(",
"'newUser'",
")",
";",
"$",
"mail",
"->",
... | Posle email novemu uzivateli s loginem a heslem
@param string $email
@param string $username
@param string $password
@throws \Nette\Application\UI\InvalidLinkException | [
"Posle",
"email",
"novemu",
"uzivateli",
"s",
"loginem",
"a",
"heslem"
] | 28eae564c6a8cdaf01d32ff5a1dffba58232f9c1 | https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Mailing/Mailer.php#L44-L56 | train |
thelia/core | lib/Thelia/Action/State.php | State.toggleVisibility | public function toggleVisibility(StateToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$state = $event->getState();
$state
->setDispatcher($dispatcher)
->setVisible(!$state->getVisible())
->save()
;
$event->setState($state);
} | php | public function toggleVisibility(StateToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$state = $event->getState();
$state
->setDispatcher($dispatcher)
->setVisible(!$state->getVisible())
->save()
;
$event->setState($state);
} | [
"public",
"function",
"toggleVisibility",
"(",
"StateToggleVisibilityEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"state",
"=",
"$",
"event",
"->",
"getState",
"(",
")",
";",
"$",
"state",
"->"... | Toggle State visibility
@param StateToggleVisibilityEvent $event | [
"Toggle",
"State",
"visibility"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/State.php#L78-L89 | train |
grom358/pharborist | src/StatementNode.php | StatementNode.getLineCount | public function getLineCount() {
$count = 1;
$this
->find(Filter::isInstanceOf('\Pharborist\WhitespaceNode'))
->each(function(WhitespaceNode $node) use (&$count) {
$count += $node->getNewlineCount();
});
return $count;
} | php | public function getLineCount() {
$count = 1;
$this
->find(Filter::isInstanceOf('\Pharborist\WhitespaceNode'))
->each(function(WhitespaceNode $node) use (&$count) {
$count += $node->getNewlineCount();
});
return $count;
} | [
"public",
"function",
"getLineCount",
"(",
")",
"{",
"$",
"count",
"=",
"1",
";",
"$",
"this",
"->",
"find",
"(",
"Filter",
"::",
"isInstanceOf",
"(",
"'\\Pharborist\\WhitespaceNode'",
")",
")",
"->",
"each",
"(",
"function",
"(",
"WhitespaceNode",
"$",
"n... | Gets the number of lines spanned by this statement.
@return integer
Always returns at least one, because any statement will be at least
one line long. | [
"Gets",
"the",
"number",
"of",
"lines",
"spanned",
"by",
"this",
"statement",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/StatementNode.php#L29-L39 | train |
grom358/pharborist | src/StatementNode.php | StatementNode.addCommentAbove | public function addCommentAbove($comment) {
if ($comment instanceof LineCommentBlockNode) {
$this->before($comment);
}
elseif (is_string($comment)) {
$this->addCommentAbove(LineCommentBlockNode::create($comment));
}
else {
throw new \InvalidArgumentException();
}
return $this;
} | php | public function addCommentAbove($comment) {
if ($comment instanceof LineCommentBlockNode) {
$this->before($comment);
}
elseif (is_string($comment)) {
$this->addCommentAbove(LineCommentBlockNode::create($comment));
}
else {
throw new \InvalidArgumentException();
}
return $this;
} | [
"public",
"function",
"addCommentAbove",
"(",
"$",
"comment",
")",
"{",
"if",
"(",
"$",
"comment",
"instanceof",
"LineCommentBlockNode",
")",
"{",
"$",
"this",
"->",
"before",
"(",
"$",
"comment",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"com... | Adds a line comment block above the statement.
@param \Pharborist\LineCommentBlockNode|string $comment
The comment to add.
@return $this
@throws \InvalidArgumentException | [
"Adds",
"a",
"line",
"comment",
"block",
"above",
"the",
"statement",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/StatementNode.php#L60-L71 | train |
grom358/pharborist | src/Functions/ParameterNode.php | ParameterNode.create | public static function create($parameter_name) {
$parameter_name = '$' . ltrim($parameter_name, '$');
$parameter_node = new ParameterNode();
$parameter_node->addChild(new VariableNode(T_VARIABLE, $parameter_name), 'name');
return $parameter_node;
} | php | public static function create($parameter_name) {
$parameter_name = '$' . ltrim($parameter_name, '$');
$parameter_node = new ParameterNode();
$parameter_node->addChild(new VariableNode(T_VARIABLE, $parameter_name), 'name');
return $parameter_node;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"parameter_name",
")",
"{",
"$",
"parameter_name",
"=",
"'$'",
".",
"ltrim",
"(",
"$",
"parameter_name",
",",
"'$'",
")",
";",
"$",
"parameter_node",
"=",
"new",
"ParameterNode",
"(",
")",
";",
"$",
"pa... | Create a parameter node.
@param string $parameter_name
Parameter name, eg. $parm
@return ParameterNode | [
"Create",
"a",
"parameter",
"node",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Functions/ParameterNode.php#L51-L56 | train |
grom358/pharborist | src/Functions/ParameterNode.php | ParameterNode.getDocBlockTag | public function getDocBlockTag() {
$doc_comment = $this->getFunction()->getDocComment();
return $doc_comment ? $doc_comment->getParameter($this->name->getText()) : NULL;
} | php | public function getDocBlockTag() {
$doc_comment = $this->getFunction()->getDocComment();
return $doc_comment ? $doc_comment->getParameter($this->name->getText()) : NULL;
} | [
"public",
"function",
"getDocBlockTag",
"(",
")",
"{",
"$",
"doc_comment",
"=",
"$",
"this",
"->",
"getFunction",
"(",
")",
"->",
"getDocComment",
"(",
")",
";",
"return",
"$",
"doc_comment",
"?",
"$",
"doc_comment",
"->",
"getParameter",
"(",
"$",
"this",... | Get the doc block tag associated with this parameter.
@return null|\phpDocumentor\Reflection\DocBlock\Tag\ParamTag
The parameter tag or null if not found. | [
"Get",
"the",
"doc",
"block",
"tag",
"associated",
"with",
"this",
"parameter",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Functions/ParameterNode.php#L281-L284 | train |
grom358/pharborist | src/Functions/ParameterNode.php | ParameterNode.hasDocTypes | public function hasDocTypes() {
$doc_comment = $this->getFunction()->getDocComment();
if (!$doc_comment) {
return FALSE;
}
$param_tag = $doc_comment->getParameter($this->getName());
if (!$param_tag) {
return FALSE;
}
$types = $param_tag->getTypes();
return !empty($types);
} | php | public function hasDocTypes() {
$doc_comment = $this->getFunction()->getDocComment();
if (!$doc_comment) {
return FALSE;
}
$param_tag = $doc_comment->getParameter($this->getName());
if (!$param_tag) {
return FALSE;
}
$types = $param_tag->getTypes();
return !empty($types);
} | [
"public",
"function",
"hasDocTypes",
"(",
")",
"{",
"$",
"doc_comment",
"=",
"$",
"this",
"->",
"getFunction",
"(",
")",
"->",
"getDocComment",
"(",
")",
";",
"if",
"(",
"!",
"$",
"doc_comment",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"param_tag",
... | Return TRUE if parameter has a phpDoc type.
@return bool | [
"Return",
"TRUE",
"if",
"parameter",
"has",
"a",
"phpDoc",
"type",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Functions/ParameterNode.php#L291-L302 | train |
grom358/pharborist | src/Functions/ParameterNode.php | ParameterNode.getDocTypes | public function getDocTypes() {
// No type specified means type is mixed.
$types = ['mixed'];
// Use types from the doc comment if available.
$doc_comment = $this->getFunction()->getDocComment();
if (!$doc_comment) {
return $types;
}
$param_tag = $doc_comment->getParameter($this->getName());
if (!$param_tag) {
return $types;
}
$types = Types::normalize($param_tag->getTypes());
if (empty($types)) {
$types[] = 'mixed';
}
return $types;
} | php | public function getDocTypes() {
// No type specified means type is mixed.
$types = ['mixed'];
// Use types from the doc comment if available.
$doc_comment = $this->getFunction()->getDocComment();
if (!$doc_comment) {
return $types;
}
$param_tag = $doc_comment->getParameter($this->getName());
if (!$param_tag) {
return $types;
}
$types = Types::normalize($param_tag->getTypes());
if (empty($types)) {
$types[] = 'mixed';
}
return $types;
} | [
"public",
"function",
"getDocTypes",
"(",
")",
"{",
"// No type specified means type is mixed.",
"$",
"types",
"=",
"[",
"'mixed'",
"]",
";",
"// Use types from the doc comment if available.",
"$",
"doc_comment",
"=",
"$",
"this",
"->",
"getFunction",
"(",
")",
"->",
... | Get the php doc types for parameter.
@return string[] | [
"Get",
"the",
"php",
"doc",
"types",
"for",
"parameter",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Functions/ParameterNode.php#L309-L326 | train |
grom358/pharborist | src/Functions/ParameterNode.php | ParameterNode.getTypes | public function getTypes() {
// If type hint is set then that is the type of the parameter.
if ($this->typeHint) {
if ($this->typeHint instanceof TokenNode) {
if ($this->typeHint->getType() === T_ARRAY) {
$docTypes = $this->getDocTypes();
foreach ($docTypes as $docType) {
if ($docType !== 'array' && substr($docType, -2) !== '[]') {
return [$this->typeHint->getText()];
}
}
return $docTypes;
}
else {
return [$this->typeHint->getText()];
}
}
else {
return [$this->typeHint->getAbsolutePath()];
}
}
return $this->getDocTypes();
} | php | public function getTypes() {
// If type hint is set then that is the type of the parameter.
if ($this->typeHint) {
if ($this->typeHint instanceof TokenNode) {
if ($this->typeHint->getType() === T_ARRAY) {
$docTypes = $this->getDocTypes();
foreach ($docTypes as $docType) {
if ($docType !== 'array' && substr($docType, -2) !== '[]') {
return [$this->typeHint->getText()];
}
}
return $docTypes;
}
else {
return [$this->typeHint->getText()];
}
}
else {
return [$this->typeHint->getAbsolutePath()];
}
}
return $this->getDocTypes();
} | [
"public",
"function",
"getTypes",
"(",
")",
"{",
"// If type hint is set then that is the type of the parameter.",
"if",
"(",
"$",
"this",
"->",
"typeHint",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"typeHint",
"instanceof",
"TokenNode",
")",
"{",
"if",
"(",
"$",
... | Get the type of the parameter as defined by type hinting or doc comment.
@return string[]
The types as defined by phpdoc standard. Default is ['mixed']. | [
"Get",
"the",
"type",
"of",
"the",
"parameter",
"as",
"defined",
"by",
"type",
"hinting",
"or",
"doc",
"comment",
"."
] | 0db9e51299a80e95b06857ed1809f59bbbab1af6 | https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Functions/ParameterNode.php#L334-L356 | train |
thelia/core | lib/Thelia/Controller/Admin/ContentController.php | ContentController.addAdditionalFolderAction | public function addAdditionalFolderAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
$folder_id = \intval($this->getRequest()->request->get('additional_folder_id'));
if ($folder_id > 0) {
$event = new ContentAddFolderEvent(
$this->getExistingObject(),
$folder_id
);
try {
$this->dispatch(TheliaEvents::CONTENT_ADD_FOLDER, $event);
} catch (\Exception $e) {
return $this->errorPage($e);
}
}
return $this->redirectToEditionTemplate();
} | php | public function addAdditionalFolderAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
$folder_id = \intval($this->getRequest()->request->get('additional_folder_id'));
if ($folder_id > 0) {
$event = new ContentAddFolderEvent(
$this->getExistingObject(),
$folder_id
);
try {
$this->dispatch(TheliaEvents::CONTENT_ADD_FOLDER, $event);
} catch (\Exception $e) {
return $this->errorPage($e);
}
}
return $this->redirectToEditionTemplate();
} | [
"public",
"function",
"addAdditionalFolderAction",
"(",
")",
"{",
"// Check current user authorization",
"if",
"(",
"null",
"!==",
"$",
"response",
"=",
"$",
"this",
"->",
"checkAuth",
"(",
"$",
"this",
"->",
"resourceCode",
",",
"array",
"(",
")",
",",
"Acces... | controller adding content to additional folder
@return mixed|\Thelia\Core\HttpFoundation\Response | [
"controller",
"adding",
"content",
"to",
"additional",
"folder"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/ContentController.php#L58-L81 | train |
thelia/core | lib/Thelia/Controller/Admin/ContentController.php | ContentController.removeAdditionalFolderAction | public function removeAdditionalFolderAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
$folder_id = \intval($this->getRequest()->request->get('additional_folder_id'));
if ($folder_id > 0) {
$event = new ContentRemoveFolderEvent(
$this->getExistingObject(),
$folder_id
);
try {
$this->dispatch(TheliaEvents::CONTENT_REMOVE_FOLDER, $event);
} catch (\Exception $e) {
return $this->errorPage($e);
}
}
return $this->redirectToEditionTemplate();
} | php | public function removeAdditionalFolderAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
return $response;
}
$folder_id = \intval($this->getRequest()->request->get('additional_folder_id'));
if ($folder_id > 0) {
$event = new ContentRemoveFolderEvent(
$this->getExistingObject(),
$folder_id
);
try {
$this->dispatch(TheliaEvents::CONTENT_REMOVE_FOLDER, $event);
} catch (\Exception $e) {
return $this->errorPage($e);
}
}
return $this->redirectToEditionTemplate();
} | [
"public",
"function",
"removeAdditionalFolderAction",
"(",
")",
"{",
"// Check current user authorization",
"if",
"(",
"null",
"!==",
"$",
"response",
"=",
"$",
"this",
"->",
"checkAuth",
"(",
"$",
"this",
"->",
"resourceCode",
",",
"array",
"(",
")",
",",
"Ac... | controller removing additional folder to a content
@return mixed|\Thelia\Core\HttpFoundation\Response | [
"controller",
"removing",
"additional",
"folder",
"to",
"a",
"content"
] | 38fbe7d5046bad6c0af9ea7c686b4655e8d84e67 | https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/ContentController.php#L88-L111 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.