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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
apioo/psx-framework | src/Bootstrap.php | Bootstrap.setupEnvironment | public static function setupEnvironment(Config $config)
{
if (!defined('PSX')) {
// define paths
define('PSX_PATH_CACHE', $config->get('psx_path_cache'));
define('PSX_PATH_PUBLIC', $config->get('psx_path_public'));
define('PSX_PATH_SRC', $config->get('psx_path_src') ?: $config->get('psx_path_library'));
/** @deprecated */
define('PSX_PATH_LIBRARY', $config->get('psx_path_library'));
// error handling
if ($config['psx_debug'] === true) {
$errorReporting = E_ALL | E_STRICT;
} else {
$errorReporting = 0;
}
error_reporting($errorReporting);
set_error_handler('\PSX\Framework\Bootstrap::errorHandler');
// annotation autoload
$namespaces = $config->get('psx_annotation_autoload');
if (!empty($namespaces) && is_array($namespaces)) {
self::registerAnnotationLoader($namespaces);
}
// ini settings
ini_set('date.timezone', $config['psx_timezone']);
ini_set('session.use_only_cookies', '1');
ini_set('docref_root', '');
ini_set('html_errors', '0');
// define in psx
define('PSX', true);
}
} | php | public static function setupEnvironment(Config $config)
{
if (!defined('PSX')) {
// define paths
define('PSX_PATH_CACHE', $config->get('psx_path_cache'));
define('PSX_PATH_PUBLIC', $config->get('psx_path_public'));
define('PSX_PATH_SRC', $config->get('psx_path_src') ?: $config->get('psx_path_library'));
/** @deprecated */
define('PSX_PATH_LIBRARY', $config->get('psx_path_library'));
// error handling
if ($config['psx_debug'] === true) {
$errorReporting = E_ALL | E_STRICT;
} else {
$errorReporting = 0;
}
error_reporting($errorReporting);
set_error_handler('\PSX\Framework\Bootstrap::errorHandler');
// annotation autoload
$namespaces = $config->get('psx_annotation_autoload');
if (!empty($namespaces) && is_array($namespaces)) {
self::registerAnnotationLoader($namespaces);
}
// ini settings
ini_set('date.timezone', $config['psx_timezone']);
ini_set('session.use_only_cookies', '1');
ini_set('docref_root', '');
ini_set('html_errors', '0');
// define in psx
define('PSX', true);
}
} | [
"public",
"static",
"function",
"setupEnvironment",
"(",
"Config",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'PSX'",
")",
")",
"{",
"// define paths",
"define",
"(",
"'PSX_PATH_CACHE'",
",",
"$",
"config",
"->",
"get",
"(",
"'psx_path_cache'"... | Setup an environment for PSX according to the provided configuration
@codeCoverageIgnore
@param \PSX\Framework\Config\Config $config | [
"Setup",
"an",
"environment",
"for",
"PSX",
"according",
"to",
"the",
"provided",
"configuration"
] | e8e550a1a87dae49b615b42a05583395088c1efb | https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Bootstrap.php#L42-L78 | train |
QoboLtd/cakephp-menu | src/View/Helper/MenuHelper.php | MenuHelper.setFullBaseUrl | public function setFullBaseUrl(array $menu = []): array
{
$menu = array_map(
function ($v) {
$url = Hash::get($v, 'url');
$children = Hash::get($v, 'children');
if ($url) {
$v['url'] = Router::url($url, true);
}
if (is_array($children)) {
$v['children'] = $this->setFullBaseUrl($children);
}
return $v;
},
$menu
);
return $menu;
} | php | public function setFullBaseUrl(array $menu = []): array
{
$menu = array_map(
function ($v) {
$url = Hash::get($v, 'url');
$children = Hash::get($v, 'children');
if ($url) {
$v['url'] = Router::url($url, true);
}
if (is_array($children)) {
$v['children'] = $this->setFullBaseUrl($children);
}
return $v;
},
$menu
);
return $menu;
} | [
"public",
"function",
"setFullBaseUrl",
"(",
"array",
"$",
"menu",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"menu",
"=",
"array_map",
"(",
"function",
"(",
"$",
"v",
")",
"{",
"$",
"url",
"=",
"Hash",
"::",
"get",
"(",
"$",
"v",
",",
"'url'",
... | Set the full base URL recursivelly for all the menu and their children.
@param mixed[] $menu Given menu
@return mixed[] $menus | [
"Set",
"the",
"full",
"base",
"URL",
"recursivelly",
"for",
"all",
"the",
"menu",
"and",
"their",
"children",
"."
] | 1b987b5a82727e3f19cd0036341ca4f3c276fa8c | https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/View/Helper/MenuHelper.php#L28-L47 | train |
usemarkup/contentful | src/DynamicEntry.php | DynamicEntry.getFields | public function getFields()
{
$coercedFields = [];
foreach (array_keys($this->entry->getFields()) as $key) {
$coercedFields[$key] = $this->getCoercedField($key);
}
return $coercedFields;
} | php | public function getFields()
{
$coercedFields = [];
foreach (array_keys($this->entry->getFields()) as $key) {
$coercedFields[$key] = $this->getCoercedField($key);
}
return $coercedFields;
} | [
"public",
"function",
"getFields",
"(",
")",
"{",
"$",
"coercedFields",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"entry",
"->",
"getFields",
"(",
")",
")",
"as",
"$",
"key",
")",
"{",
"$",
"coercedFields",
"[",
"$",
... | Gets the list of field values in the entry, keyed by fields. Could be scalars, DateTime objects, or links.
@return array | [
"Gets",
"the",
"list",
"of",
"field",
"values",
"in",
"the",
"entry",
"keyed",
"by",
"fields",
".",
"Could",
"be",
"scalars",
"DateTime",
"objects",
"or",
"links",
"."
] | ac5902bf891c52fd00d349bd5aae78d516dcd601 | https://github.com/usemarkup/contentful/blob/ac5902bf891c52fd00d349bd5aae78d516dcd601/src/DynamicEntry.php#L63-L71 | train |
thelia-modules/AttributeType | Model/AttributeType.php | AttributeType.getValue | public static function getValue($slug, $attributeAvId, $locale = 'en_US')
{
return self::getValues([$slug], [$attributeAvId], $locale)[$slug][$attributeAvId];
} | php | public static function getValue($slug, $attributeAvId, $locale = 'en_US')
{
return self::getValues([$slug], [$attributeAvId], $locale)[$slug][$attributeAvId];
} | [
"public",
"static",
"function",
"getValue",
"(",
"$",
"slug",
",",
"$",
"attributeAvId",
",",
"$",
"locale",
"=",
"'en_US'",
")",
"{",
"return",
"self",
"::",
"getValues",
"(",
"[",
"$",
"slug",
"]",
",",
"[",
"$",
"attributeAvId",
"]",
",",
"$",
"lo... | Returns a value based on the slug, attribute_av_id and locale
<code>
$value = AttributeType::getValue('color', 2);
</code>
@param string $slug
@param int $attributeAvId
@param string $locale
@return string
@throws \Propel\Runtime\Exception\PropelException | [
"Returns",
"a",
"value",
"based",
"on",
"the",
"slug",
"attribute_av_id",
"and",
"locale"
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/AttributeType.php#L40-L43 | train |
thelia-modules/AttributeType | Model/AttributeType.php | AttributeType.getFirstValues | public static function getFirstValues(array $slugs, array $attributeAvIds, $locale = 'en_US')
{
$results = self::getValues($slugs, $attributeAvIds, $locale);
$return = array();
foreach ($slugs as $slug) {
if (!isset($return[$slug])) {
$return[$slug] = null;
}
foreach ($results[$slug] as $value) {
if ($return[$slug] === null) {
$return[$slug] = $value;
continue;
}
break;
}
}
return $return;
} | php | public static function getFirstValues(array $slugs, array $attributeAvIds, $locale = 'en_US')
{
$results = self::getValues($slugs, $attributeAvIds, $locale);
$return = array();
foreach ($slugs as $slug) {
if (!isset($return[$slug])) {
$return[$slug] = null;
}
foreach ($results[$slug] as $value) {
if ($return[$slug] === null) {
$return[$slug] = $value;
continue;
}
break;
}
}
return $return;
} | [
"public",
"static",
"function",
"getFirstValues",
"(",
"array",
"$",
"slugs",
",",
"array",
"$",
"attributeAvIds",
",",
"$",
"locale",
"=",
"'en_US'",
")",
"{",
"$",
"results",
"=",
"self",
"::",
"getValues",
"(",
"$",
"slugs",
",",
"$",
"attributeAvIds",
... | Returns a set of first values
If the value does not exist, it is replaced by null
<code>
$values = AttributeType::getFirstValues(['color','texture','other'], [4,7]);
</code>
<sample>
array(
'color' => '#00000',
'texture' => 'lines.jpg',
'other' => null
)
</sample>
@param string[] $slugs
@param int[] $attributeAvIds
@param string $locale
@return array | [
"Returns",
"a",
"set",
"of",
"first",
"values",
"If",
"the",
"value",
"does",
"not",
"exist",
"it",
"is",
"replaced",
"by",
"null"
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/AttributeType.php#L122-L143 | train |
thelia-modules/AttributeType | Model/AttributeType.php | AttributeType.getAttributeAv | public static function getAttributeAv($slugs = null, $attributeIds = null, $values = null, $locale = 'en_US')
{
return self::queryAttributeAvs($slugs, $attributeIds, $values, $locale)->findOne();
} | php | public static function getAttributeAv($slugs = null, $attributeIds = null, $values = null, $locale = 'en_US')
{
return self::queryAttributeAvs($slugs, $attributeIds, $values, $locale)->findOne();
} | [
"public",
"static",
"function",
"getAttributeAv",
"(",
"$",
"slugs",
"=",
"null",
",",
"$",
"attributeIds",
"=",
"null",
",",
"$",
"values",
"=",
"null",
",",
"$",
"locale",
"=",
"'en_US'",
")",
"{",
"return",
"self",
"::",
"queryAttributeAvs",
"(",
"$",... | Find AttributeAv by slugs, attributeIds, values, locales
<code>
$attributeAv = AttributeType::getAttributeAv('color', '1', '#00000');
</code>
@param null|string|array $slugs
@param null|string|array $attributeIds
@param null|string|array $values meta values
@param null|string|array $locale
@return \Thelia\Model\AttributeAv | [
"Find",
"AttributeAv",
"by",
"slugs",
"attributeIds",
"values",
"locales"
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/AttributeType.php#L159-L162 | train |
thelia-modules/AttributeType | Model/AttributeType.php | AttributeType.getAttributeAvs | public static function getAttributeAvs($slugs = null, $attributeIds = null, $values = null, $locale = 'en_US')
{
return self::queryAttributeAvs($slugs, $attributeIds, $values, $locale)->find();
} | php | public static function getAttributeAvs($slugs = null, $attributeIds = null, $values = null, $locale = 'en_US')
{
return self::queryAttributeAvs($slugs, $attributeIds, $values, $locale)->find();
} | [
"public",
"static",
"function",
"getAttributeAvs",
"(",
"$",
"slugs",
"=",
"null",
",",
"$",
"attributeIds",
"=",
"null",
",",
"$",
"values",
"=",
"null",
",",
"$",
"locale",
"=",
"'en_US'",
")",
"{",
"return",
"self",
"::",
"queryAttributeAvs",
"(",
"$"... | Find AttributeAvs by slug, attributeId, value, locale
<code>
$attributeAvs = AttributeType::getAttributeAvs('color', '1', '#00000');
</code>
@param null|string|array $slugs
@param null|string|array $attributeIds
@param null|string|array $values meta values
@param null|string|array $locale
@return \Thelia\Model\AttributeAv | [
"Find",
"AttributeAvs",
"by",
"slug",
"attributeId",
"value",
"locale"
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/AttributeType.php#L178-L181 | train |
wikiworldorder/survloop | src/Controllers/Tree/SurvData.php | SurvData.printAllTableIdFlds | public function printAllTableIdFlds($tbl, $flds = [])
{
$ret = '';
$arr = $this->getAllTableIdFlds($tbl, $flds);
if (sizeof($arr) > 0) {
foreach ($arr as $i => $row) {
$ret .= ' (( ';
if (sizeof($row) > 0) {
foreach ($row as $fld => $val) {
$ret .= (($fld != 'id') ? ' , ' : '') . $fld . ' : ' . $val;
}
}
$ret .= ' )) ';
}
}
return $ret;
} | php | public function printAllTableIdFlds($tbl, $flds = [])
{
$ret = '';
$arr = $this->getAllTableIdFlds($tbl, $flds);
if (sizeof($arr) > 0) {
foreach ($arr as $i => $row) {
$ret .= ' (( ';
if (sizeof($row) > 0) {
foreach ($row as $fld => $val) {
$ret .= (($fld != 'id') ? ' , ' : '') . $fld . ' : ' . $val;
}
}
$ret .= ' )) ';
}
}
return $ret;
} | [
"public",
"function",
"printAllTableIdFlds",
"(",
"$",
"tbl",
",",
"$",
"flds",
"=",
"[",
"]",
")",
"{",
"$",
"ret",
"=",
"''",
";",
"$",
"arr",
"=",
"$",
"this",
"->",
"getAllTableIdFlds",
"(",
"$",
"tbl",
",",
"$",
"flds",
")",
";",
"if",
"(",
... | For debugging purposes | [
"For",
"debugging",
"purposes"
] | 7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a | https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/Tree/SurvData.php#L666-L682 | train |
QoboLtd/cakephp-menu | src/MenuBuilder/MenuFactory.php | MenuFactory.getMenu | public static function getMenu(string $name, array $user, bool $fullBaseUrl = false, $context = null): MenuInterface
{
$instance = new self($user, $fullBaseUrl);
return $instance->getMenuByName($name, $context);
} | php | public static function getMenu(string $name, array $user, bool $fullBaseUrl = false, $context = null): MenuInterface
{
$instance = new self($user, $fullBaseUrl);
return $instance->getMenuByName($name, $context);
} | [
"public",
"static",
"function",
"getMenu",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"user",
",",
"bool",
"$",
"fullBaseUrl",
"=",
"false",
",",
"$",
"context",
"=",
"null",
")",
":",
"MenuInterface",
"{",
"$",
"instance",
"=",
"new",
"self",
"(",... | Returns a menu instance based on the provided name.
If the name was found in database, it is checked whether the default option is enabled
If was found and the default option is disabled, the instance is constructed through events
Otherwise, the menu instance is constructed base on the menu settings defined in database
@param string $name Menu name
@param mixed[] $user User info
@param bool $fullBaseUrl Full-base URL flag
@param mixed $context The object that generates the menu to be used as the event subject
@return \Menu\MenuBuilder\MenuInterface | [
"Returns",
"a",
"menu",
"instance",
"based",
"on",
"the",
"provided",
"name",
".",
"If",
"the",
"name",
"was",
"found",
"in",
"database",
"it",
"is",
"checked",
"whether",
"the",
"default",
"option",
"is",
"enabled",
"If",
"was",
"found",
"and",
"the",
"... | 1b987b5a82727e3f19cd0036341ca4f3c276fa8c | https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/MenuBuilder/MenuFactory.php#L96-L101 | train |
QoboLtd/cakephp-menu | src/MenuBuilder/MenuFactory.php | MenuFactory.addToMenu | public static function addToMenu(MenuInterface $menu, array $items): void
{
$normalisedItems = self::normaliseItems($items);
foreach ($normalisedItems as $item) {
$menu->addMenuItem(MenuItemFactory::createMenuItem($item));
}
} | php | public static function addToMenu(MenuInterface $menu, array $items): void
{
$normalisedItems = self::normaliseItems($items);
foreach ($normalisedItems as $item) {
$menu->addMenuItem(MenuItemFactory::createMenuItem($item));
}
} | [
"public",
"static",
"function",
"addToMenu",
"(",
"MenuInterface",
"$",
"menu",
",",
"array",
"$",
"items",
")",
":",
"void",
"{",
"$",
"normalisedItems",
"=",
"self",
"::",
"normaliseItems",
"(",
"$",
"items",
")",
";",
"foreach",
"(",
"$",
"normalisedIte... | Extends the provided menu container by adding the provided menu array
@param \Menu\MenuBuilder\MenuInterface $menu Menu to be extended
@param mixed[] $items List of items to be appended to the provided menu instance
@return void | [
"Extends",
"the",
"provided",
"menu",
"container",
"by",
"adding",
"the",
"provided",
"menu",
"array"
] | 1b987b5a82727e3f19cd0036341ca4f3c276fa8c | https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/MenuBuilder/MenuFactory.php#L110-L116 | train |
QoboLtd/cakephp-menu | src/MenuBuilder/MenuFactory.php | MenuFactory.createMenu | public static function createMenu(array $menu): MenuInterface
{
$menuInstance = new Menu();
self::addToMenu($menuInstance, $menu);
return $menuInstance;
} | php | public static function createMenu(array $menu): MenuInterface
{
$menuInstance = new Menu();
self::addToMenu($menuInstance, $menu);
return $menuInstance;
} | [
"public",
"static",
"function",
"createMenu",
"(",
"array",
"$",
"menu",
")",
":",
"MenuInterface",
"{",
"$",
"menuInstance",
"=",
"new",
"Menu",
"(",
")",
";",
"self",
"::",
"addToMenu",
"(",
"$",
"menuInstance",
",",
"$",
"menu",
")",
";",
"return",
... | Constructs a menu instance by using the provided menu array
@param mixed[] $menu Menu configuration
@return \Menu\MenuBuilder\MenuInterface | [
"Constructs",
"a",
"menu",
"instance",
"by",
"using",
"the",
"provided",
"menu",
"array"
] | 1b987b5a82727e3f19cd0036341ca4f3c276fa8c | https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/MenuBuilder/MenuFactory.php#L124-L130 | train |
QoboLtd/cakephp-menu | src/MenuBuilder/MenuFactory.php | MenuFactory.getMenuByName | protected function getMenuByName(string $name, $context = null): MenuInterface
{
// validate menu name
$this->validateName($name);
// get menu
$menuEntity = null;
try {
$menuEntity = $this->Menus
->find('all')
->where(['name' => $name])
->firstOrFail();
if (!($menuEntity instanceof EntityInterface)) {
throw new RuntimeException(sprintf(
'Expected value of type "Cake\Datasource\EntityInterface", got "%s" instead',
gettype($menuEntity)
));
}
$menuInstance = $menuEntity->get('default') ?
$this->getMenuItemsFromEvent($name, [], $context) :
$this->getMenuItemsFromTable($menuEntity);
} catch (RecordNotFoundException $e) {
$menuInstance = static::getMenuItemsFromEvent($name, [], $context);
}
// maintain backwards compatibility for menu arrays
if (is_array($menuInstance)) {
$menuInstance = self::normaliseItems($menuInstance);
if ($menuEntity instanceof EntityInterface && $menuEntity->get('default')) {
$menuInstance = $this->sortItems($menuInstance);
}
$menuInstance = self::createMenu($menuInstance);
}
return $menuInstance;
} | php | protected function getMenuByName(string $name, $context = null): MenuInterface
{
// validate menu name
$this->validateName($name);
// get menu
$menuEntity = null;
try {
$menuEntity = $this->Menus
->find('all')
->where(['name' => $name])
->firstOrFail();
if (!($menuEntity instanceof EntityInterface)) {
throw new RuntimeException(sprintf(
'Expected value of type "Cake\Datasource\EntityInterface", got "%s" instead',
gettype($menuEntity)
));
}
$menuInstance = $menuEntity->get('default') ?
$this->getMenuItemsFromEvent($name, [], $context) :
$this->getMenuItemsFromTable($menuEntity);
} catch (RecordNotFoundException $e) {
$menuInstance = static::getMenuItemsFromEvent($name, [], $context);
}
// maintain backwards compatibility for menu arrays
if (is_array($menuInstance)) {
$menuInstance = self::normaliseItems($menuInstance);
if ($menuEntity instanceof EntityInterface && $menuEntity->get('default')) {
$menuInstance = $this->sortItems($menuInstance);
}
$menuInstance = self::createMenu($menuInstance);
}
return $menuInstance;
} | [
"protected",
"function",
"getMenuByName",
"(",
"string",
"$",
"name",
",",
"$",
"context",
"=",
"null",
")",
":",
"MenuInterface",
"{",
"// validate menu name",
"$",
"this",
"->",
"validateName",
"(",
"$",
"name",
")",
";",
"// get menu",
"$",
"menuEntity",
... | Returns a menu instance based on the provided name
@param string $name Menu's name
@param null|mixed $context The object that generates the menu to be used as the event subject
@return \Menu\MenuBuilder\MenuInterface | [
"Returns",
"a",
"menu",
"instance",
"based",
"on",
"the",
"provided",
"name"
] | 1b987b5a82727e3f19cd0036341ca4f3c276fa8c | https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/MenuBuilder/MenuFactory.php#L161-L198 | train |
QoboLtd/cakephp-menu | src/MenuBuilder/MenuFactory.php | MenuFactory.getMenuItemsFromEvent | protected function getMenuItemsFromEvent(string $menuName, array $modules = [], $subject = null): MenuInterface
{
if (empty($subject)) {
$subject = $this;
}
$event = new Event((string)EventName::GET_MENU_ITEMS(), $subject, [
'name' => $menuName,
'user' => $this->user,
'fullBaseUrl' => $this->fullBaseUrl,
'modules' => $modules
]);
$this->getEventManager()->dispatch($event);
return ($event->result instanceof MenuInterface) ? $event->result : new Menu();
} | php | protected function getMenuItemsFromEvent(string $menuName, array $modules = [], $subject = null): MenuInterface
{
if (empty($subject)) {
$subject = $this;
}
$event = new Event((string)EventName::GET_MENU_ITEMS(), $subject, [
'name' => $menuName,
'user' => $this->user,
'fullBaseUrl' => $this->fullBaseUrl,
'modules' => $modules
]);
$this->getEventManager()->dispatch($event);
return ($event->result instanceof MenuInterface) ? $event->result : new Menu();
} | [
"protected",
"function",
"getMenuItemsFromEvent",
"(",
"string",
"$",
"menuName",
",",
"array",
"$",
"modules",
"=",
"[",
"]",
",",
"$",
"subject",
"=",
"null",
")",
":",
"MenuInterface",
"{",
"if",
"(",
"empty",
"(",
"$",
"subject",
")",
")",
"{",
"$"... | Menu items getter using Event.
@param string $menuName Menu name
@param mixed[] $modules Modules to fetch menu items for
@param null|mixed $subject Event subject to be used. $this will be used in null
@return \Menu\MenuBuilder\MenuInterface | [
"Menu",
"items",
"getter",
"using",
"Event",
"."
] | 1b987b5a82727e3f19cd0036341ca4f3c276fa8c | https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/MenuBuilder/MenuFactory.php#L208-L223 | train |
QoboLtd/cakephp-menu | src/MenuBuilder/MenuFactory.php | MenuFactory.getMenuItemsFromTable | protected function getMenuItemsFromTable(EntityInterface $menu): array
{
$query = $this->MenuItems->find('threaded', [
'conditions' => ['MenuItems.menu_id' => $menu->id],
'order' => ['MenuItems.lft']
]);
if ($query->isEmpty()) {
return [];
}
$result = [];
$count = 0;
foreach ($query->all() as $entity) {
$item = $this->getMenuItem($menu, $entity->toArray(), ++$count);
if (empty($item)) {
continue;
}
$result[] = $item;
}
return $result;
} | php | protected function getMenuItemsFromTable(EntityInterface $menu): array
{
$query = $this->MenuItems->find('threaded', [
'conditions' => ['MenuItems.menu_id' => $menu->id],
'order' => ['MenuItems.lft']
]);
if ($query->isEmpty()) {
return [];
}
$result = [];
$count = 0;
foreach ($query->all() as $entity) {
$item = $this->getMenuItem($menu, $entity->toArray(), ++$count);
if (empty($item)) {
continue;
}
$result[] = $item;
}
return $result;
} | [
"protected",
"function",
"getMenuItemsFromTable",
"(",
"EntityInterface",
"$",
"menu",
")",
":",
"array",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"MenuItems",
"->",
"find",
"(",
"'threaded'",
",",
"[",
"'conditions'",
"=>",
"[",
"'MenuItems.menu_id'",
"=>",... | Menu items getter using database table.
@param \Cake\Datasource\EntityInterface $menu Menu entity
@return mixed[] | [
"Menu",
"items",
"getter",
"using",
"database",
"table",
"."
] | 1b987b5a82727e3f19cd0036341ca4f3c276fa8c | https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/MenuBuilder/MenuFactory.php#L231-L254 | train |
QoboLtd/cakephp-menu | src/MenuBuilder/MenuFactory.php | MenuFactory.getMenuItem | protected function getMenuItem(EntityInterface $menu, array $item, int $order = 0): array
{
if (empty($item)) {
return [];
}
$label = $item['label'];
$icon = $item['icon'];
$type = $item['type'];
$children = !empty($item['children']) ? $item['children'] : [];
if (!empty($children)) {
$count = 0;
foreach ($children as $key => $child) {
$children[$key] = $this->getMenuItem($menu, $child, ++$count);
}
}
if (static::TYPE_MODULE === $type) {
$item = $this->getMenuItemsFromEvent($menu->get('name'), [$item['url']]);
reset($item);
$item = current($item);
}
if (!empty($children)) {
$item['children'] = $children;
}
if (empty($item)) {
return [];
}
if (static::TYPE_MODULE === $type) {
$item['label'] = $label;
$item['icon'] = $icon;
}
$item['order'] = $order;
return $item;
} | php | protected function getMenuItem(EntityInterface $menu, array $item, int $order = 0): array
{
if (empty($item)) {
return [];
}
$label = $item['label'];
$icon = $item['icon'];
$type = $item['type'];
$children = !empty($item['children']) ? $item['children'] : [];
if (!empty($children)) {
$count = 0;
foreach ($children as $key => $child) {
$children[$key] = $this->getMenuItem($menu, $child, ++$count);
}
}
if (static::TYPE_MODULE === $type) {
$item = $this->getMenuItemsFromEvent($menu->get('name'), [$item['url']]);
reset($item);
$item = current($item);
}
if (!empty($children)) {
$item['children'] = $children;
}
if (empty($item)) {
return [];
}
if (static::TYPE_MODULE === $type) {
$item['label'] = $label;
$item['icon'] = $icon;
}
$item['order'] = $order;
return $item;
} | [
"protected",
"function",
"getMenuItem",
"(",
"EntityInterface",
"$",
"menu",
",",
"array",
"$",
"item",
",",
"int",
"$",
"order",
"=",
"0",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"item",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
... | Menu item getter.
@param \Cake\Datasource\EntityInterface $menu Menu entity
@param mixed[] $item Menu item
@param int $order Menu item order
@return mixed[] | [
"Menu",
"item",
"getter",
"."
] | 1b987b5a82727e3f19cd0036341ca4f3c276fa8c | https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/MenuBuilder/MenuFactory.php#L264-L305 | train |
QoboLtd/cakephp-menu | src/MenuBuilder/MenuFactory.php | MenuFactory.applyDefaults | public static function applyDefaults(array $items, array $defaults = null): array
{
$defaults = empty($defaults) ? Configure::readOrFail('Menu.defaults') : $defaults;
// merge item properties with defaults
$func = function (&$item, $k) use (&$func, $defaults) {
if (!empty($item['children'])) {
array_walk($item['children'], $func);
}
$item = array_merge($defaults, $item);
};
array_walk($items, $func);
return $items;
} | php | public static function applyDefaults(array $items, array $defaults = null): array
{
$defaults = empty($defaults) ? Configure::readOrFail('Menu.defaults') : $defaults;
// merge item properties with defaults
$func = function (&$item, $k) use (&$func, $defaults) {
if (!empty($item['children'])) {
array_walk($item['children'], $func);
}
$item = array_merge($defaults, $item);
};
array_walk($items, $func);
return $items;
} | [
"public",
"static",
"function",
"applyDefaults",
"(",
"array",
"$",
"items",
",",
"array",
"$",
"defaults",
"=",
"null",
")",
":",
"array",
"{",
"$",
"defaults",
"=",
"empty",
"(",
"$",
"defaults",
")",
"?",
"Configure",
"::",
"readOrFail",
"(",
"'Menu.d... | Applies the menu defaults on the provided menu item.
Defaults will be loaded from Configuration Menu.defaults if the provided array is empty
@param mixed[] $items List of menu items
@param array|null $defaults List of default values for a menu item
@return mixed[] The provided list of menu items including the defaults | [
"Applies",
"the",
"menu",
"defaults",
"on",
"the",
"provided",
"menu",
"item",
".",
"Defaults",
"will",
"be",
"loaded",
"from",
"Configuration",
"Menu",
".",
"defaults",
"if",
"the",
"provided",
"array",
"is",
"empty"
] | 1b987b5a82727e3f19cd0036341ca4f3c276fa8c | https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/MenuBuilder/MenuFactory.php#L330-L345 | train |
QoboLtd/cakephp-menu | src/MenuBuilder/MenuFactory.php | MenuFactory.normaliseItems | public static function normaliseItems(array $items): array
{
// merge item properties with defaults
$items = self::applyDefaults($items);
// merge duplicated labels recursively
$result = [];
foreach ($items as $item) {
if (!array_key_exists($item['label'], $result)) {
$result[$item['label']] = $item;
continue;
}
$result[$item['label']]['children'] = array_merge_recursive(
$item['children'],
$result[$item['label']]['children']
);
}
return $result;
} | php | public static function normaliseItems(array $items): array
{
// merge item properties with defaults
$items = self::applyDefaults($items);
// merge duplicated labels recursively
$result = [];
foreach ($items as $item) {
if (!array_key_exists($item['label'], $result)) {
$result[$item['label']] = $item;
continue;
}
$result[$item['label']]['children'] = array_merge_recursive(
$item['children'],
$result[$item['label']]['children']
);
}
return $result;
} | [
"public",
"static",
"function",
"normaliseItems",
"(",
"array",
"$",
"items",
")",
":",
"array",
"{",
"// merge item properties with defaults",
"$",
"items",
"=",
"self",
"::",
"applyDefaults",
"(",
"$",
"items",
")",
";",
"// merge duplicated labels recursively",
"... | Normalises the provided array menu items for the given module
Part of the normalisation is to
- merge duplicated labels, recursively
- apply defaults defined in Menu.defaults, recursively
@param mixed[] $items Menu items
@return mixed[] | [
"Normalises",
"the",
"provided",
"array",
"menu",
"items",
"for",
"the",
"given",
"module",
"Part",
"of",
"the",
"normalisation",
"is",
"to",
"-",
"merge",
"duplicated",
"labels",
"recursively",
"-",
"apply",
"defaults",
"defined",
"in",
"Menu",
".",
"defaults... | 1b987b5a82727e3f19cd0036341ca4f3c276fa8c | https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/MenuBuilder/MenuFactory.php#L356-L376 | train |
QoboLtd/cakephp-menu | src/MenuBuilder/MenuFactory.php | MenuFactory.sortItems | protected function sortItems(array $items, string $key = 'order'): array
{
$cmp = function (&$a, &$b) use (&$cmp, $key) {
if (!empty($a['children'])) {
usort($a['children'], $cmp);
}
if (!empty($b['children'])) {
usort($b['children'], $cmp);
}
return $a[$key] > $b[$key];
};
usort($items, $cmp);
return $items;
} | php | protected function sortItems(array $items, string $key = 'order'): array
{
$cmp = function (&$a, &$b) use (&$cmp, $key) {
if (!empty($a['children'])) {
usort($a['children'], $cmp);
}
if (!empty($b['children'])) {
usort($b['children'], $cmp);
}
return $a[$key] > $b[$key];
};
usort($items, $cmp);
return $items;
} | [
"protected",
"function",
"sortItems",
"(",
"array",
"$",
"items",
",",
"string",
"$",
"key",
"=",
"'order'",
")",
":",
"array",
"{",
"$",
"cmp",
"=",
"function",
"(",
"&",
"$",
"a",
",",
"&",
"$",
"b",
")",
"use",
"(",
"&",
"$",
"cmp",
",",
"$"... | Method for sorting array items by specified key.
@param mixed[] $items List of items to be sorted
@param string $key Sort-by key
@return mixed[] | [
"Method",
"for",
"sorting",
"array",
"items",
"by",
"specified",
"key",
"."
] | 1b987b5a82727e3f19cd0036341ca4f3c276fa8c | https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/MenuBuilder/MenuFactory.php#L385-L402 | train |
usemarkup/contentful | src/Filter/ClassBasedNameTrait.php | ClassBasedNameTrait.getName | public function getName()
{
//generate snake case name based on class name
preg_match('/\\\?(\w+)Filter$/', get_class($this), $matches);
return ltrim(strtolower(strval(preg_replace('/[A-Z]/', '_$0', $matches[1]))), '_');
} | php | public function getName()
{
//generate snake case name based on class name
preg_match('/\\\?(\w+)Filter$/', get_class($this), $matches);
return ltrim(strtolower(strval(preg_replace('/[A-Z]/', '_$0', $matches[1]))), '_');
} | [
"public",
"function",
"getName",
"(",
")",
"{",
"//generate snake case name based on class name",
"preg_match",
"(",
"'/\\\\\\?(\\w+)Filter$/'",
",",
"get_class",
"(",
"$",
"this",
")",
",",
"$",
"matches",
")",
";",
"return",
"ltrim",
"(",
"strtolower",
"(",
"str... | Gets the name for the filter.
@return string | [
"Gets",
"the",
"name",
"for",
"the",
"filter",
"."
] | ac5902bf891c52fd00d349bd5aae78d516dcd601 | https://github.com/usemarkup/contentful/blob/ac5902bf891c52fd00d349bd5aae78d516dcd601/src/Filter/ClassBasedNameTrait.php#L12-L18 | train |
FriendsOfCake/process-mq | src/Shell/Task/RabbitMQWorkerTask.php | RabbitMQWorkerTask.consume | public function consume($config, callable $callable)
{
$this->ProcessManager->handleKillSignals();
$this->eventManager()->attach([$this, 'signalHandler'], 'CLI.signal', ['priority' => 100]);
$this->_consume(Queue::consume($config), $callable);
} | php | public function consume($config, callable $callable)
{
$this->ProcessManager->handleKillSignals();
$this->eventManager()->attach([$this, 'signalHandler'], 'CLI.signal', ['priority' => 100]);
$this->_consume(Queue::consume($config), $callable);
} | [
"public",
"function",
"consume",
"(",
"$",
"config",
",",
"callable",
"$",
"callable",
")",
"{",
"$",
"this",
"->",
"ProcessManager",
"->",
"handleKillSignals",
"(",
")",
";",
"$",
"this",
"->",
"eventManager",
"(",
")",
"->",
"attach",
"(",
"[",
"$",
... | Consume a queue by the RabbitMQ queue configuration
@param string $config
@param callable $callable
@return void | [
"Consume",
"a",
"queue",
"by",
"the",
"RabbitMQ",
"queue",
"configuration"
] | 184a868c2415781ebf4de48f85c45b93dfb60552 | https://github.com/FriendsOfCake/process-mq/blob/184a868c2415781ebf4de48f85c45b93dfb60552/src/Shell/Task/RabbitMQWorkerTask.php#L50-L56 | train |
FriendsOfCake/process-mq | src/Shell/Task/RabbitMQWorkerTask.php | RabbitMQWorkerTask._callback | protected function _callback(callable $callable, AMQPEnvelope $envelope, AMQPQueue $queue)
{
if ($this->stop) {
return false;
}
if ($envelope === false) {
return false;
}
if ($this->stop) {
$this->log('-> Putting job back into the queue', 'warning');
$queue->nack($envelope->getDeliveryTag(), AMQP_REQUEUE);
return false;
}
$result = false;
try {
$this->_working = true;
$body = $envelope->getBody();
$compressed = $envelope->getContentEncoding() === 'gzip';
if ($compressed) {
$body = gzuncompress($body);
}
switch ($envelope->getContentType()) {
case 'application/json':
$result = $callable(json_decode($body, true), $envelope, $queue);
break;
case 'application/text':
$result = $callable($body, $envelope, $queue);
break;
default:
throw new RuntimeException('Unknown serializer: ' . $envelope->getContentType());
}
} catch (Exception $e) {
$queue->nack($envelope->getDeliveryTag(), AMQP_REQUEUE);
throw $e;
} finally {
$this->_working = false;
}
if ($result !== false) {
return $queue->ack($envelope->getDeliveryTag());
}
return $queue->nack($envelope->getDeliveryTag(), AMQP_REQUEUE);
} | php | protected function _callback(callable $callable, AMQPEnvelope $envelope, AMQPQueue $queue)
{
if ($this->stop) {
return false;
}
if ($envelope === false) {
return false;
}
if ($this->stop) {
$this->log('-> Putting job back into the queue', 'warning');
$queue->nack($envelope->getDeliveryTag(), AMQP_REQUEUE);
return false;
}
$result = false;
try {
$this->_working = true;
$body = $envelope->getBody();
$compressed = $envelope->getContentEncoding() === 'gzip';
if ($compressed) {
$body = gzuncompress($body);
}
switch ($envelope->getContentType()) {
case 'application/json':
$result = $callable(json_decode($body, true), $envelope, $queue);
break;
case 'application/text':
$result = $callable($body, $envelope, $queue);
break;
default:
throw new RuntimeException('Unknown serializer: ' . $envelope->getContentType());
}
} catch (Exception $e) {
$queue->nack($envelope->getDeliveryTag(), AMQP_REQUEUE);
throw $e;
} finally {
$this->_working = false;
}
if ($result !== false) {
return $queue->ack($envelope->getDeliveryTag());
}
return $queue->nack($envelope->getDeliveryTag(), AMQP_REQUEUE);
} | [
"protected",
"function",
"_callback",
"(",
"callable",
"$",
"callable",
",",
"AMQPEnvelope",
"$",
"envelope",
",",
"AMQPQueue",
"$",
"queue",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"stop",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"envelo... | Actual callback method
@param callable $callable
@param \AMQPEnvelope $envelope
@param \AMQPQueue $queue
@return boolean
@throws \Exception
@throws \RuntimeException | [
"Actual",
"callback",
"method"
] | 184a868c2415781ebf4de48f85c45b93dfb60552 | https://github.com/FriendsOfCake/process-mq/blob/184a868c2415781ebf4de48f85c45b93dfb60552/src/Shell/Task/RabbitMQWorkerTask.php#L87-L140 | train |
FriendsOfCake/process-mq | src/Shell/Task/RabbitMQWorkerTask.php | RabbitMQWorkerTask.signalHandler | public function signalHandler()
{
if (!$this->_working) {
$this->log('Not doing any jobs, going to die now...', 'warning');
$this->_stop();
return;
}
$this->stop = true;
} | php | public function signalHandler()
{
if (!$this->_working) {
$this->log('Not doing any jobs, going to die now...', 'warning');
$this->_stop();
return;
}
$this->stop = true;
} | [
"public",
"function",
"signalHandler",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_working",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'Not doing any jobs, going to die now...'",
",",
"'warning'",
")",
";",
"$",
"this",
"->",
"_stop",
"(",
")",
"... | Handle signals from the OS
@return void | [
"Handle",
"signals",
"from",
"the",
"OS"
] | 184a868c2415781ebf4de48f85c45b93dfb60552 | https://github.com/FriendsOfCake/process-mq/blob/184a868c2415781ebf4de48f85c45b93dfb60552/src/Shell/Task/RabbitMQWorkerTask.php#L147-L156 | train |
cleaniquecoders/laravel-observers | src/Observers/Kernel.php | Kernel.observes | public function observes()
{
foreach (config('observers') as $observer => $models) {
foreach ($models as $model) {
if (class_exists($model) && class_exists($observer)) {
$model::observe($observer);
}
}
}
} | php | public function observes()
{
foreach (config('observers') as $observer => $models) {
foreach ($models as $model) {
if (class_exists($model) && class_exists($observer)) {
$model::observe($observer);
}
}
}
} | [
"public",
"function",
"observes",
"(",
")",
"{",
"foreach",
"(",
"config",
"(",
"'observers'",
")",
"as",
"$",
"observer",
"=>",
"$",
"models",
")",
"{",
"foreach",
"(",
"$",
"models",
"as",
"$",
"model",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$"... | Register observers. | [
"Register",
"observers",
"."
] | ec6f9f0de7a1277a29c0956bd881f972f5a1847c | https://github.com/cleaniquecoders/laravel-observers/blob/ec6f9f0de7a1277a29c0956bd881f972f5a1847c/src/Observers/Kernel.php#L20-L29 | train |
kenarkose/Transit | src/Service/UploadService.php | UploadService.validatesUploadedFile | public function validatesUploadedFile($validate = null)
{
if (func_num_args() === 0)
{
return $this->validatesUploadedFile;
}
return $this->validatesUploadedFile = (bool)$validate;
} | php | public function validatesUploadedFile($validate = null)
{
if (func_num_args() === 0)
{
return $this->validatesUploadedFile;
}
return $this->validatesUploadedFile = (bool)$validate;
} | [
"public",
"function",
"validatesUploadedFile",
"(",
"$",
"validate",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"validatesUploadedFile",
";",
"}",
"return",
"$",
"this",
"->",
"validatesU... | Sets and gets validation mode
@param bool $validate
@return bool | [
"Sets",
"and",
"gets",
"validation",
"mode"
] | de8e1cd23d0f5814a5d3a6c1795d6f414046adbb | https://github.com/kenarkose/Transit/blob/de8e1cd23d0f5814a5d3a6c1795d6f414046adbb/src/Service/UploadService.php#L81-L89 | train |
kenarkose/Transit | src/Service/UploadService.php | UploadService.prepareUploadData | protected function prepareUploadData(UploadedFile $uploadedFile)
{
return [
'extension' => $uploadedFile->getClientOriginalExtension(),
'mimetype' => $uploadedFile->getMimeType(),
'size' => $uploadedFile->getSize(),
'name' => $uploadedFile->getClientOriginalName(),
];
} | php | protected function prepareUploadData(UploadedFile $uploadedFile)
{
return [
'extension' => $uploadedFile->getClientOriginalExtension(),
'mimetype' => $uploadedFile->getMimeType(),
'size' => $uploadedFile->getSize(),
'name' => $uploadedFile->getClientOriginalName(),
];
} | [
"protected",
"function",
"prepareUploadData",
"(",
"UploadedFile",
"$",
"uploadedFile",
")",
"{",
"return",
"[",
"'extension'",
"=>",
"$",
"uploadedFile",
"->",
"getClientOriginalExtension",
"(",
")",
",",
"'mimetype'",
"=>",
"$",
"uploadedFile",
"->",
"getMimeType"... | Returns an array of data for upload model
@param UploadedFile $uploadedFile
@return array | [
"Returns",
"an",
"array",
"of",
"data",
"for",
"upload",
"model"
] | de8e1cd23d0f5814a5d3a6c1795d6f414046adbb | https://github.com/kenarkose/Transit/blob/de8e1cd23d0f5814a5d3a6c1795d6f414046adbb/src/Service/UploadService.php#L219-L227 | train |
kenarkose/Transit | src/Service/UploadService.php | UploadService.getUploadPath | public function getUploadPath()
{
$relativePath = date('Y/m');
$fullPath = upload_path($relativePath);
$this->makeUploadPath($fullPath);
return [$fullPath, $relativePath];
} | php | public function getUploadPath()
{
$relativePath = date('Y/m');
$fullPath = upload_path($relativePath);
$this->makeUploadPath($fullPath);
return [$fullPath, $relativePath];
} | [
"public",
"function",
"getUploadPath",
"(",
")",
"{",
"$",
"relativePath",
"=",
"date",
"(",
"'Y/m'",
")",
";",
"$",
"fullPath",
"=",
"upload_path",
"(",
"$",
"relativePath",
")",
";",
"$",
"this",
"->",
"makeUploadPath",
"(",
"$",
"fullPath",
")",
";",
... | Returns the current upload directory
@return string | [
"Returns",
"the",
"current",
"upload",
"directory"
] | de8e1cd23d0f5814a5d3a6c1795d6f414046adbb | https://github.com/kenarkose/Transit/blob/de8e1cd23d0f5814a5d3a6c1795d6f414046adbb/src/Service/UploadService.php#L262-L270 | train |
kenarkose/Transit | src/Service/UploadService.php | UploadService.getNewUploadModel | protected function getNewUploadModel($id = null)
{
$uploadModel = $this->modelName();
$upload = new $uploadModel;
if ( ! $upload instanceof Uploadable)
{
throw new RuntimeException('The upload model must implement the "Kenarkose\Transit\Contract\Uploadable" interface.');
}
if ($id)
{
$upload->setKey($id);
}
return $upload;
} | php | protected function getNewUploadModel($id = null)
{
$uploadModel = $this->modelName();
$upload = new $uploadModel;
if ( ! $upload instanceof Uploadable)
{
throw new RuntimeException('The upload model must implement the "Kenarkose\Transit\Contract\Uploadable" interface.');
}
if ($id)
{
$upload->setKey($id);
}
return $upload;
} | [
"protected",
"function",
"getNewUploadModel",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"uploadModel",
"=",
"$",
"this",
"->",
"modelName",
"(",
")",
";",
"$",
"upload",
"=",
"new",
"$",
"uploadModel",
";",
"if",
"(",
"!",
"$",
"upload",
"instanceof"... | Creates a new upload model
@param int|null $id
@return mixed | [
"Creates",
"a",
"new",
"upload",
"model"
] | de8e1cd23d0f5814a5d3a6c1795d6f414046adbb | https://github.com/kenarkose/Transit/blob/de8e1cd23d0f5814a5d3a6c1795d6f414046adbb/src/Service/UploadService.php#L309-L326 | train |
wikiworldorder/survloop | src/Controllers/Tree/TreeSurvFormVarieties.php | TreeSurvFormVarieties.widgetCust | public function widgetCust(Request $request, $nID = -3)
{
$this->survLoopInit($request, '');
$this->loadAllSessData();
//$this->loadTree();
$txt = (($request->has('txt')) ? trim($request->get('txt')) : '');
$nIDtxt = $nID . $txt;
$branches = (($request->has('branch')) ? trim($request->get('branch')) : '');
$this->sessData->loadDataBranchFromUrl($branches);
return $this->widgetCustomRun($nID, $nIDtxt);
} | php | public function widgetCust(Request $request, $nID = -3)
{
$this->survLoopInit($request, '');
$this->loadAllSessData();
//$this->loadTree();
$txt = (($request->has('txt')) ? trim($request->get('txt')) : '');
$nIDtxt = $nID . $txt;
$branches = (($request->has('branch')) ? trim($request->get('branch')) : '');
$this->sessData->loadDataBranchFromUrl($branches);
return $this->widgetCustomRun($nID, $nIDtxt);
} | [
"public",
"function",
"widgetCust",
"(",
"Request",
"$",
"request",
",",
"$",
"nID",
"=",
"-",
"3",
")",
"{",
"$",
"this",
"->",
"survLoopInit",
"(",
"$",
"request",
",",
"''",
")",
";",
"$",
"this",
"->",
"loadAllSessData",
"(",
")",
";",
"//$this->... | customizable function for what content is loaded in the widget's div | [
"customizable",
"function",
"for",
"what",
"content",
"is",
"loaded",
"in",
"the",
"widget",
"s",
"div"
] | 7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a | https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/Tree/TreeSurvFormVarieties.php#L218-L228 | train |
thelia-modules/AttributeType | Model/Base/AttributeAttributeTypeQuery.php | AttributeAttributeTypeQuery.filterByAttributeId | public function filterByAttributeId($attributeId = null, $comparison = null)
{
if (is_array($attributeId)) {
$useMinMax = false;
if (isset($attributeId['min'])) {
$this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($attributeId['max'])) {
$this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attributeId, $comparison);
} | php | public function filterByAttributeId($attributeId = null, $comparison = null)
{
if (is_array($attributeId)) {
$useMinMax = false;
if (isset($attributeId['min'])) {
$this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($attributeId['max'])) {
$this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attributeId, $comparison);
} | [
"public",
"function",
"filterByAttributeId",
"(",
"$",
"attributeId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"attributeId",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(... | Filter the query on the attribute_id column
Example usage:
<code>
$query->filterByAttributeId(1234); // WHERE attribute_id = 1234
$query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34)
$query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12
</code>
@see filterByAttribute()
@param mixed $attributeId The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return ChildAttributeAttributeTypeQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"attribute_id",
"column"
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeTypeQuery.php#L297-L318 | train |
thelia-modules/AttributeType | Model/Base/AttributeAttributeTypeQuery.php | AttributeAttributeTypeQuery.filterByAttributeTypeId | public function filterByAttributeTypeId($attributeTypeId = null, $comparison = null)
{
if (is_array($attributeTypeId)) {
$useMinMax = false;
if (isset($attributeTypeId['min'])) {
$this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_TYPE_ID, $attributeTypeId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($attributeTypeId['max'])) {
$this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_TYPE_ID, $attributeTypeId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_TYPE_ID, $attributeTypeId, $comparison);
} | php | public function filterByAttributeTypeId($attributeTypeId = null, $comparison = null)
{
if (is_array($attributeTypeId)) {
$useMinMax = false;
if (isset($attributeTypeId['min'])) {
$this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_TYPE_ID, $attributeTypeId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($attributeTypeId['max'])) {
$this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_TYPE_ID, $attributeTypeId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_TYPE_ID, $attributeTypeId, $comparison);
} | [
"public",
"function",
"filterByAttributeTypeId",
"(",
"$",
"attributeTypeId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"attributeTypeId",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"... | Filter the query on the attribute_type_id column
Example usage:
<code>
$query->filterByAttributeTypeId(1234); // WHERE attribute_type_id = 1234
$query->filterByAttributeTypeId(array(12, 34)); // WHERE attribute_type_id IN (12, 34)
$query->filterByAttributeTypeId(array('min' => 12)); // WHERE attribute_type_id > 12
</code>
@see filterByAttributeType()
@param mixed $attributeTypeId The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return ChildAttributeAttributeTypeQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"attribute_type_id",
"column"
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeTypeQuery.php#L340-L361 | train |
thelia-modules/AttributeType | Model/Base/AttributeAttributeTypeQuery.php | AttributeAttributeTypeQuery.filterByAttribute | public function filterByAttribute($attribute, $comparison = null)
{
if ($attribute instanceof \Thelia\Model\Attribute) {
return $this
->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison);
} elseif ($attribute instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection');
}
} | php | public function filterByAttribute($attribute, $comparison = null)
{
if ($attribute instanceof \Thelia\Model\Attribute) {
return $this
->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison);
} elseif ($attribute instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection');
}
} | [
"public",
"function",
"filterByAttribute",
"(",
"$",
"attribute",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"attribute",
"instanceof",
"\\",
"Thelia",
"\\",
"Model",
"\\",
"Attribute",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingAl... | Filter the query by a related \Thelia\Model\Attribute object
@param \Thelia\Model\Attribute|ObjectCollection $attribute The related object(s) to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return ChildAttributeAttributeTypeQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"by",
"a",
"related",
"\\",
"Thelia",
"\\",
"Model",
"\\",
"Attribute",
"object"
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeTypeQuery.php#L371-L386 | train |
thelia-modules/AttributeType | Model/Base/AttributeAttributeTypeQuery.php | AttributeAttributeTypeQuery.useAttributeQuery | public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinAttribute($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery');
} | php | public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinAttribute($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery');
} | [
"public",
"function",
"useAttributeQuery",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"INNER_JOIN",
")",
"{",
"return",
"$",
"this",
"->",
"joinAttribute",
"(",
"$",
"relationAlias",
",",
"$",
"joinType",
")",
"->",
... | Use the Attribute relation Attribute object
@see useQuery()
@param string $relationAlias optional alias for the relation,
to be used as main alias in the secondary query
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return \Thelia\Model\AttributeQuery A secondary query class using the current class as primary query | [
"Use",
"the",
"Attribute",
"relation",
"Attribute",
"object"
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeTypeQuery.php#L431-L436 | train |
thelia-modules/AttributeType | Model/Base/AttributeAttributeTypeQuery.php | AttributeAttributeTypeQuery.joinAttributeType | public function joinAttributeType($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('AttributeType');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'AttributeType');
}
return $this;
} | php | public function joinAttributeType($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('AttributeType');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'AttributeType');
}
return $this;
} | [
"public",
"function",
"joinAttributeType",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"INNER_JOIN",
")",
"{",
"$",
"tableMap",
"=",
"$",
"this",
"->",
"getTableMap",
"(",
")",
";",
"$",
"relationMap",
"=",
"$",
"... | Adds a JOIN clause to the query using the AttributeType relation
@param string $relationAlias optional alias for the relation
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return ChildAttributeAttributeTypeQuery The current query, for fluid interface | [
"Adds",
"a",
"JOIN",
"clause",
"to",
"the",
"query",
"using",
"the",
"AttributeType",
"relation"
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeTypeQuery.php#L471-L493 | train |
thelia-modules/AttributeType | Model/Base/AttributeAttributeTypeQuery.php | AttributeAttributeTypeQuery.filterByAttributeTypeAvMeta | public function filterByAttributeTypeAvMeta($attributeTypeAvMeta, $comparison = null)
{
if ($attributeTypeAvMeta instanceof \AttributeType\Model\AttributeTypeAvMeta) {
return $this
->addUsingAlias(AttributeAttributeTypeTableMap::ID, $attributeTypeAvMeta->getAttributeAttributeTypeId(), $comparison);
} elseif ($attributeTypeAvMeta instanceof ObjectCollection) {
return $this
->useAttributeTypeAvMetaQuery()
->filterByPrimaryKeys($attributeTypeAvMeta->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByAttributeTypeAvMeta() only accepts arguments of type \AttributeType\Model\AttributeTypeAvMeta or Collection');
}
} | php | public function filterByAttributeTypeAvMeta($attributeTypeAvMeta, $comparison = null)
{
if ($attributeTypeAvMeta instanceof \AttributeType\Model\AttributeTypeAvMeta) {
return $this
->addUsingAlias(AttributeAttributeTypeTableMap::ID, $attributeTypeAvMeta->getAttributeAttributeTypeId(), $comparison);
} elseif ($attributeTypeAvMeta instanceof ObjectCollection) {
return $this
->useAttributeTypeAvMetaQuery()
->filterByPrimaryKeys($attributeTypeAvMeta->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByAttributeTypeAvMeta() only accepts arguments of type \AttributeType\Model\AttributeTypeAvMeta or Collection');
}
} | [
"public",
"function",
"filterByAttributeTypeAvMeta",
"(",
"$",
"attributeTypeAvMeta",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"attributeTypeAvMeta",
"instanceof",
"\\",
"AttributeType",
"\\",
"Model",
"\\",
"AttributeTypeAvMeta",
")",
"{",
"... | Filter the query by a related \AttributeType\Model\AttributeTypeAvMeta object
@param \AttributeType\Model\AttributeTypeAvMeta|ObjectCollection $attributeTypeAvMeta the related object to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return ChildAttributeAttributeTypeQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"by",
"a",
"related",
"\\",
"AttributeType",
"\\",
"Model",
"\\",
"AttributeTypeAvMeta",
"object"
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeTypeQuery.php#L521-L534 | train |
thelia-modules/AttributeType | Model/Base/AttributeAttributeTypeQuery.php | AttributeAttributeTypeQuery.useAttributeTypeAvMetaQuery | public function useAttributeTypeAvMetaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinAttributeTypeAvMeta($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'AttributeTypeAvMeta', '\AttributeType\Model\AttributeTypeAvMetaQuery');
} | php | public function useAttributeTypeAvMetaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinAttributeTypeAvMeta($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'AttributeTypeAvMeta', '\AttributeType\Model\AttributeTypeAvMetaQuery');
} | [
"public",
"function",
"useAttributeTypeAvMetaQuery",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"INNER_JOIN",
")",
"{",
"return",
"$",
"this",
"->",
"joinAttributeTypeAvMeta",
"(",
"$",
"relationAlias",
",",
"$",
"joinTy... | Use the AttributeTypeAvMeta relation AttributeTypeAvMeta object
@see useQuery()
@param string $relationAlias optional alias for the relation,
to be used as main alias in the secondary query
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return \AttributeType\Model\AttributeTypeAvMetaQuery A secondary query class using the current class as primary query | [
"Use",
"the",
"AttributeTypeAvMeta",
"relation",
"AttributeTypeAvMeta",
"object"
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeTypeQuery.php#L579-L584 | train |
yangjian102621/herosphp | src/image/Image.php | Image.show | public function show() {
switch ( $this->extension ) {
case 'jpg':
case 'jpeg':
header("Content-type: image/jpeg");
imagejpeg($this->imgDst);
break;
case 'gif':
header("Content-type: image/gif");
imagegif($this->imgDst);
break;
case 'png':
header("Content-type: image/png");
imagepng($this->imgDst);
break;
default:
die("No image support in this PHP server");
}
return $this;
} | php | public function show() {
switch ( $this->extension ) {
case 'jpg':
case 'jpeg':
header("Content-type: image/jpeg");
imagejpeg($this->imgDst);
break;
case 'gif':
header("Content-type: image/gif");
imagegif($this->imgDst);
break;
case 'png':
header("Content-type: image/png");
imagepng($this->imgDst);
break;
default:
die("No image support in this PHP server");
}
return $this;
} | [
"public",
"function",
"show",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"extension",
")",
"{",
"case",
"'jpg'",
":",
"case",
"'jpeg'",
":",
"header",
"(",
"\"Content-type: image/jpeg\"",
")",
";",
"imagejpeg",
"(",
"$",
"this",
"->",
"imgDst",
")"... | show the image | [
"show",
"the",
"image"
] | dc0a7b1c73b005098fd627977cd787eb0ab4a4e2 | https://github.com/yangjian102621/herosphp/blob/dc0a7b1c73b005098fd627977cd787eb0ab4a4e2/src/image/Image.php#L434-L458 | train |
matteosister/GitElephantBundle | Collection/GitElephantRepositoryCollection.php | GitElephantRepositoryCollection.get | public function get($name)
{
/** @var Repository $repository */
foreach ($this->repositories as $repository) {
if ($repository->getName() == $name) {
return $repository;
}
}
return null;
} | php | public function get($name)
{
/** @var Repository $repository */
foreach ($this->repositories as $repository) {
if ($repository->getName() == $name) {
return $repository;
}
}
return null;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"/** @var Repository $repository */",
"foreach",
"(",
"$",
"this",
"->",
"repositories",
"as",
"$",
"repository",
")",
"{",
"if",
"(",
"$",
"repository",
"->",
"getName",
"(",
")",
"==",
"$",
"name",... | Retrieve a repository by its name
@param string $name the repository name
@return Repository $repository | [
"Retrieve",
"a",
"repository",
"by",
"its",
"name"
] | 8235b9ed91a62bb6acf685f6b71cce3db73de6ef | https://github.com/matteosister/GitElephantBundle/blob/8235b9ed91a62bb6acf685f6b71cce3db73de6ef/Collection/GitElephantRepositoryCollection.php#L56-L66 | train |
glavweb/GlavwebRestBundle | Action/RestFormAction.php | RestFormAction.cleanForm | private function cleanForm($requestData, Form $form)
{
$allowedField = array_keys($requestData);
/** @var FormInterface[] $formFields */
$formFields = $form->all();
foreach ($formFields as $formField) {
$fieldName = $formField->getName();
if (!in_array($fieldName, $allowedField)) {
$form->remove($fieldName);
}
}
} | php | private function cleanForm($requestData, Form $form)
{
$allowedField = array_keys($requestData);
/** @var FormInterface[] $formFields */
$formFields = $form->all();
foreach ($formFields as $formField) {
$fieldName = $formField->getName();
if (!in_array($fieldName, $allowedField)) {
$form->remove($fieldName);
}
}
} | [
"private",
"function",
"cleanForm",
"(",
"$",
"requestData",
",",
"Form",
"$",
"form",
")",
"{",
"$",
"allowedField",
"=",
"array_keys",
"(",
"$",
"requestData",
")",
";",
"/** @var FormInterface[] $formFields */",
"$",
"formFields",
"=",
"$",
"form",
"->",
"a... | Remove unnecessary fields from form
@param array $requestData
@param Form $form | [
"Remove",
"unnecessary",
"fields",
"from",
"form"
] | e6e60969419eac22d3949005ddf7170a20b10a9d | https://github.com/glavweb/GlavwebRestBundle/blob/e6e60969419eac22d3949005ddf7170a20b10a9d/Action/RestFormAction.php#L198-L211 | train |
apioo/psx-framework | src/Dependency/DefaultContainer.php | DefaultContainer.newLoggerHandlerImpl | protected function newLoggerHandlerImpl()
{
$config = $this->get('config');
$factory = $config->get('psx_logger_factory');
if ($factory instanceof \Closure) {
return $factory($config);
} else {
$level = $config->get('psx_log_level');
$level = !empty($level) ? $level : Logger::ERROR;
$handler = new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, $level, true, true);
$handler->setFormatter(new ErrorFormatter());
return $handler;
}
} | php | protected function newLoggerHandlerImpl()
{
$config = $this->get('config');
$factory = $config->get('psx_logger_factory');
if ($factory instanceof \Closure) {
return $factory($config);
} else {
$level = $config->get('psx_log_level');
$level = !empty($level) ? $level : Logger::ERROR;
$handler = new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, $level, true, true);
$handler->setFormatter(new ErrorFormatter());
return $handler;
}
} | [
"protected",
"function",
"newLoggerHandlerImpl",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"get",
"(",
"'config'",
")",
";",
"$",
"factory",
"=",
"$",
"config",
"->",
"get",
"(",
"'psx_logger_factory'",
")",
";",
"if",
"(",
"$",
"factory",
... | Returns the default log handler
@return \Monolog\Handler\HandlerInterface | [
"Returns",
"the",
"default",
"log",
"handler"
] | e8e550a1a87dae49b615b42a05583395088c1efb | https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Dependency/DefaultContainer.php#L256-L272 | train |
apioo/psx-framework | src/Dependency/DefaultContainer.php | DefaultContainer.newDoctrineCacheImpl | protected function newDoctrineCacheImpl($namespace)
{
$config = $this->get('config');
$factory = $config->get('psx_cache_factory');
if ($factory instanceof \Closure) {
return $factory($config, $namespace);
} else {
return new DoctrineCache\FilesystemCache($this->get('config')->get('psx_path_cache') . '/' . $namespace);
}
} | php | protected function newDoctrineCacheImpl($namespace)
{
$config = $this->get('config');
$factory = $config->get('psx_cache_factory');
if ($factory instanceof \Closure) {
return $factory($config, $namespace);
} else {
return new DoctrineCache\FilesystemCache($this->get('config')->get('psx_path_cache') . '/' . $namespace);
}
} | [
"protected",
"function",
"newDoctrineCacheImpl",
"(",
"$",
"namespace",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"get",
"(",
"'config'",
")",
";",
"$",
"factory",
"=",
"$",
"config",
"->",
"get",
"(",
"'psx_cache_factory'",
")",
";",
"if",
"(",
... | Returns the default doctrine cache
@param string $namespace
@return \Doctrine\Common\Cache\Cache | [
"Returns",
"the",
"default",
"doctrine",
"cache"
] | e8e550a1a87dae49b615b42a05583395088c1efb | https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Dependency/DefaultContainer.php#L280-L290 | train |
paysera/lib-dependency-injection | src/AddTaggedCompilerPass.php | AddTaggedCompilerPass.getServiceArgument | private function getServiceArgument(ContainerBuilder $container, string $id)
{
if ($this->callMode === self::CALL_MODE_ID) {
$container->getDefinition($id)->setPublic(true);
return $id;
}
if ($this->callMode === self::CALL_MODE_LAZY_SERVICE) {
$container->getDefinition($id)->setLazy(true);
}
return new Reference($id);
} | php | private function getServiceArgument(ContainerBuilder $container, string $id)
{
if ($this->callMode === self::CALL_MODE_ID) {
$container->getDefinition($id)->setPublic(true);
return $id;
}
if ($this->callMode === self::CALL_MODE_LAZY_SERVICE) {
$container->getDefinition($id)->setLazy(true);
}
return new Reference($id);
} | [
"private",
"function",
"getServiceArgument",
"(",
"ContainerBuilder",
"$",
"container",
",",
"string",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"callMode",
"===",
"self",
"::",
"CALL_MODE_ID",
")",
"{",
"$",
"container",
"->",
"getDefinition",
"(",... | Can be overwritten in extended classes
@param ContainerBuilder $container
@param string $id
@return mixed returns argument to pass to the collector service | [
"Can",
"be",
"overwritten",
"in",
"extended",
"classes"
] | 6aa4164ea31547010c795c58720d5d57df1c930f | https://github.com/paysera/lib-dependency-injection/blob/6aa4164ea31547010c795c58720d5d57df1c930f/src/AddTaggedCompilerPass.php#L132-L145 | train |
dreamfactorysoftware/df-script | src/Services/Script.php | Script.getRequestData | protected function getRequestData()
{
return [
'request' => $this->request->toArray(),
'response' => [
'content' => null,
'content_type' => null,
'status_code' => ServiceResponseInterface::HTTP_OK
],
'resource' => $this->resourcePath
];
} | php | protected function getRequestData()
{
return [
'request' => $this->request->toArray(),
'response' => [
'content' => null,
'content_type' => null,
'status_code' => ServiceResponseInterface::HTTP_OK
],
'resource' => $this->resourcePath
];
} | [
"protected",
"function",
"getRequestData",
"(",
")",
"{",
"return",
"[",
"'request'",
"=>",
"$",
"this",
"->",
"request",
"->",
"toArray",
"(",
")",
",",
"'response'",
"=>",
"[",
"'content'",
"=>",
"null",
",",
"'content_type'",
"=>",
"null",
",",
"'status... | Returns all request data.
@return array | [
"Returns",
"all",
"request",
"data",
"."
] | 14941f5dada6077286a0d992d6aa8c3d9243d5a0 | https://github.com/dreamfactorysoftware/df-script/blob/14941f5dada6077286a0d992d6aa8c3d9243d5a0/src/Services/Script.php#L154-L165 | train |
autowp/zf-components | src/ConfigProvider.php | ConfigProvider.getFilterConfig | public function getFilterConfig(): array
{
return [
'aliases' => [
'singlespaces' => Filter\SingleSpaces::class,
'singleSpaces' => Filter\SingleSpaces::class,
'SingleSpaces' => Filter\SingleSpaces::class,
'transliteration' => Filter\Transliteration::class,
'Transliteration' => Filter\Transliteration::class,
'filenamesafe' => Filter\FilenameSafe::class,
'filenameSafe' => Filter\FilenameSafe::class,
'FilenameSafe' => Filter\FilenameSafe::class,
],
'factories' => [
Filter\SingleSpaces::class => InvokableFactory::class,
Filter\Transliteration::class => InvokableFactory::class,
Filter\FilenameSafe::class => InvokableFactory::class,
],
];
} | php | public function getFilterConfig(): array
{
return [
'aliases' => [
'singlespaces' => Filter\SingleSpaces::class,
'singleSpaces' => Filter\SingleSpaces::class,
'SingleSpaces' => Filter\SingleSpaces::class,
'transliteration' => Filter\Transliteration::class,
'Transliteration' => Filter\Transliteration::class,
'filenamesafe' => Filter\FilenameSafe::class,
'filenameSafe' => Filter\FilenameSafe::class,
'FilenameSafe' => Filter\FilenameSafe::class,
],
'factories' => [
Filter\SingleSpaces::class => InvokableFactory::class,
Filter\Transliteration::class => InvokableFactory::class,
Filter\FilenameSafe::class => InvokableFactory::class,
],
];
} | [
"public",
"function",
"getFilterConfig",
"(",
")",
":",
"array",
"{",
"return",
"[",
"'aliases'",
"=>",
"[",
"'singlespaces'",
"=>",
"Filter",
"\\",
"SingleSpaces",
"::",
"class",
",",
"'singleSpaces'",
"=>",
"Filter",
"\\",
"SingleSpaces",
"::",
"class",
",",... | Return zend-filter configuration. | [
"Return",
"zend",
"-",
"filter",
"configuration",
"."
] | fc02e7e734ff694a57a3540f0342af8b4a47717e | https://github.com/autowp/zf-components/blob/fc02e7e734ff694a57a3540f0342af8b4a47717e/src/ConfigProvider.php#L50-L69 | train |
QoboLtd/cakephp-menu | src/Type/TypeFactory.php | TypeFactory.create | public static function create(string $type): \Menu\Type\TypeInterface
{
if (empty($type)) {
throw new InvalidArgumentException('Type must be a non-empty string.');
}
$className = __NAMESPACE__ . '\\Types\\' . Inflector::camelize($type);
if (!class_exists($className)) {
throw new RuntimeException('Class [' . $className . '] does not exist.');
}
$interface = __NAMESPACE__ . '\\' . static::INTERFACE_CLASS;
if (!in_array($interface, class_implements($className))) {
throw new RuntimeException('Class [' . $className . '] must implement [' . $interface . '] interface.');
}
return new $className();
} | php | public static function create(string $type): \Menu\Type\TypeInterface
{
if (empty($type)) {
throw new InvalidArgumentException('Type must be a non-empty string.');
}
$className = __NAMESPACE__ . '\\Types\\' . Inflector::camelize($type);
if (!class_exists($className)) {
throw new RuntimeException('Class [' . $className . '] does not exist.');
}
$interface = __NAMESPACE__ . '\\' . static::INTERFACE_CLASS;
if (!in_array($interface, class_implements($className))) {
throw new RuntimeException('Class [' . $className . '] must implement [' . $interface . '] interface.');
}
return new $className();
} | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"type",
")",
":",
"\\",
"Menu",
"\\",
"Type",
"\\",
"TypeInterface",
"{",
"if",
"(",
"empty",
"(",
"$",
"type",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Type must be a n... | Create and return menu item type object.
@param string $type Type name
@return \Menu\Type\TypeInterface
@throws \InvalidArgumentException
@throws \RuntimeException | [
"Create",
"and",
"return",
"menu",
"item",
"type",
"object",
"."
] | 1b987b5a82727e3f19cd0036341ca4f3c276fa8c | https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/Type/TypeFactory.php#L31-L48 | train |
QoboLtd/cakephp-menu | src/Type/TypeFactory.php | TypeFactory.getList | public static function getList(): array
{
$result = [];
$path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Types';
$dir = new Folder($path);
$files = $dir->find('.*\.php');
if (empty($files)) {
return $result;
}
foreach ($files as $file) {
$name = str_replace('.php', '', $file);
$value = Inflector::underscore($name);
$result[$value] = $name;
}
return $result;
} | php | public static function getList(): array
{
$result = [];
$path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Types';
$dir = new Folder($path);
$files = $dir->find('.*\.php');
if (empty($files)) {
return $result;
}
foreach ($files as $file) {
$name = str_replace('.php', '', $file);
$value = Inflector::underscore($name);
$result[$value] = $name;
}
return $result;
} | [
"public",
"static",
"function",
"getList",
"(",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"path",
"=",
"dirname",
"(",
"__FILE__",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"'Types'",
";",
"$",
"dir",
"=",
"new",
"Folder",
"(",
"$",... | Menu item types getter.
@return mixed[] | [
"Menu",
"item",
"types",
"getter",
"."
] | 1b987b5a82727e3f19cd0036341ca4f3c276fa8c | https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/Type/TypeFactory.php#L55-L74 | train |
apioo/psx-framework | src/Http/ResponseWriter.php | ResponseWriter.setBody | public function setBody(ResponseInterface $response, $data, $writerType = null)
{
if ($data instanceof HttpResponseInterface) {
$statusCode = $data->getStatusCode();
if (!empty($statusCode)) {
$response->setStatus($statusCode);
}
$headers = $data->getHeaders();
if (!empty($headers)) {
$response->setHeaders($headers);
}
$body = $data->getBody();
} else {
$body = $data;
}
if (!GraphTraverser::isEmpty($body)) {
if ($writerType instanceof WriterOptions) {
$options = $writerType;
} elseif ($writerType instanceof RequestInterface) {
$options = $this->getWriterOptions($writerType);
} elseif (is_string($writerType)) {
$options = new WriterOptions();
$options->setWriterType($writerType);
} else {
$options = new WriterOptions();
$options->setWriterType(WriterInterface::JSON);
}
$writer = null;
if ($body instanceof HttpWriter\WriterInterface) {
$writer = $body;
} elseif ($body instanceof \DOMDocument) {
$writer = new HttpWriter\Xml($body);
} elseif ($body instanceof \SimpleXMLElement) {
$writer = new HttpWriter\Xml($body);
} elseif ($body instanceof StreamInterface) {
$writer = new HttpWriter\Stream($body);
} elseif (is_string($body)) {
$writer = new HttpWriter\Writer($body);
}
// set new response body since we want to discard every data which
// was written before because this could corrupt our output format
$response->setBody(new StringStream());
if ($writer instanceof HttpWriter\WriterInterface) {
$writer->writeTo($response);
} else {
$this->setResponse($response, $body, $options ?? new WriterOptions());
}
} else {
$response->setStatus(204);
$response->setBody(new StringStream(''));
}
} | php | public function setBody(ResponseInterface $response, $data, $writerType = null)
{
if ($data instanceof HttpResponseInterface) {
$statusCode = $data->getStatusCode();
if (!empty($statusCode)) {
$response->setStatus($statusCode);
}
$headers = $data->getHeaders();
if (!empty($headers)) {
$response->setHeaders($headers);
}
$body = $data->getBody();
} else {
$body = $data;
}
if (!GraphTraverser::isEmpty($body)) {
if ($writerType instanceof WriterOptions) {
$options = $writerType;
} elseif ($writerType instanceof RequestInterface) {
$options = $this->getWriterOptions($writerType);
} elseif (is_string($writerType)) {
$options = new WriterOptions();
$options->setWriterType($writerType);
} else {
$options = new WriterOptions();
$options->setWriterType(WriterInterface::JSON);
}
$writer = null;
if ($body instanceof HttpWriter\WriterInterface) {
$writer = $body;
} elseif ($body instanceof \DOMDocument) {
$writer = new HttpWriter\Xml($body);
} elseif ($body instanceof \SimpleXMLElement) {
$writer = new HttpWriter\Xml($body);
} elseif ($body instanceof StreamInterface) {
$writer = new HttpWriter\Stream($body);
} elseif (is_string($body)) {
$writer = new HttpWriter\Writer($body);
}
// set new response body since we want to discard every data which
// was written before because this could corrupt our output format
$response->setBody(new StringStream());
if ($writer instanceof HttpWriter\WriterInterface) {
$writer->writeTo($response);
} else {
$this->setResponse($response, $body, $options ?? new WriterOptions());
}
} else {
$response->setStatus(204);
$response->setBody(new StringStream(''));
}
} | [
"public",
"function",
"setBody",
"(",
"ResponseInterface",
"$",
"response",
",",
"$",
"data",
",",
"$",
"writerType",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"data",
"instanceof",
"HttpResponseInterface",
")",
"{",
"$",
"statusCode",
"=",
"$",
"data",
"->",... | Uses the internal response writer to serialize arbitrary PHP data to
string representation. If writer type is a HTTP request object the write
will look at the provided header to send the fitting data format which
the client has requested. If writer type is a writer class name the
specified writer will be used. Otherwise we use JSON as default data
format
@param \PSX\Http\ResponseInterface $response
@param mixed $data
@param \PSX\Framework\Http\WriterOptions|\PSX\Http\RequestInterface|string|null $writerType | [
"Uses",
"the",
"internal",
"response",
"writer",
"to",
"serialize",
"arbitrary",
"PHP",
"data",
"to",
"string",
"representation",
".",
"If",
"writer",
"type",
"is",
"a",
"HTTP",
"request",
"object",
"the",
"write",
"will",
"look",
"at",
"the",
"provided",
"h... | e8e550a1a87dae49b615b42a05583395088c1efb | https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Http/ResponseWriter.php#L76-L133 | train |
apioo/psx-framework | src/Http/ResponseWriter.php | ResponseWriter.getWriterOptions | protected function getWriterOptions(RequestInterface $request)
{
$options = new WriterOptions();
$options->setContentType($request->getHeader('Accept'));
$options->setFormat($request->getUri()->getParameter('format'));
$options->setSupportedWriter($this->supportedWriter);
$options->setWriterCallback(function(WriterInterface $writer) use ($request){
if ($writer instanceof Writer\Jsonp) {
if (!$writer->getCallbackName()) {
$writer->setCallbackName($request->getUri()->getParameter('callback'));
}
}
});
return $options;
} | php | protected function getWriterOptions(RequestInterface $request)
{
$options = new WriterOptions();
$options->setContentType($request->getHeader('Accept'));
$options->setFormat($request->getUri()->getParameter('format'));
$options->setSupportedWriter($this->supportedWriter);
$options->setWriterCallback(function(WriterInterface $writer) use ($request){
if ($writer instanceof Writer\Jsonp) {
if (!$writer->getCallbackName()) {
$writer->setCallbackName($request->getUri()->getParameter('callback'));
}
}
});
return $options;
} | [
"protected",
"function",
"getWriterOptions",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"options",
"=",
"new",
"WriterOptions",
"(",
")",
";",
"$",
"options",
"->",
"setContentType",
"(",
"$",
"request",
"->",
"getHeader",
"(",
"'Accept'",
")",
... | Returns the writer options for the provided request and the current
context of the controller
@param \PSX\Http\RequestInterface $request
@return \PSX\Framework\Http\WriterOptions | [
"Returns",
"the",
"writer",
"options",
"for",
"the",
"provided",
"request",
"and",
"the",
"current",
"context",
"of",
"the",
"controller"
] | e8e550a1a87dae49b615b42a05583395088c1efb | https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Http/ResponseWriter.php#L197-L212 | train |
crysalead/chaos-orm | src/Relationship.php | Relationship.counterpart | public function counterpart()
{
if ($this->_counterpart) {
return $this->_counterpart;
}
$to = $this->to();
$from = $this->from();
$relations = $to::definition()->relations();
$result = [];
foreach ($relations as $relation) {
$rel = $to::definition()->relation($relation);
if ($rel->to() === $this->from()) {
$result[] = $rel;
}
}
if (count($result) === 1) {
return $this->_counterpart = reset($result);
} elseif (count($result) > 1) {
throw new ORMException("Ambiguous {$this->type()} counterpart relationship for `{$from}`. Apply the Single Table Inheritance pattern to get unique models.");
}
throw new ORMException("Missing {$this->type()} counterpart relationship for `{$from}`. Add one in the `{$to}` model.");
} | php | public function counterpart()
{
if ($this->_counterpart) {
return $this->_counterpart;
}
$to = $this->to();
$from = $this->from();
$relations = $to::definition()->relations();
$result = [];
foreach ($relations as $relation) {
$rel = $to::definition()->relation($relation);
if ($rel->to() === $this->from()) {
$result[] = $rel;
}
}
if (count($result) === 1) {
return $this->_counterpart = reset($result);
} elseif (count($result) > 1) {
throw new ORMException("Ambiguous {$this->type()} counterpart relationship for `{$from}`. Apply the Single Table Inheritance pattern to get unique models.");
}
throw new ORMException("Missing {$this->type()} counterpart relationship for `{$from}`. Add one in the `{$to}` model.");
} | [
"public",
"function",
"counterpart",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_counterpart",
")",
"{",
"return",
"$",
"this",
"->",
"_counterpart",
";",
"}",
"$",
"to",
"=",
"$",
"this",
"->",
"to",
"(",
")",
";",
"$",
"from",
"=",
"$",
"thi... | Returns the counterpart relation.
@return object | [
"Returns",
"the",
"counterpart",
"relation",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Relationship.php#L205-L229 | train |
crysalead/chaos-orm | src/Relationship.php | Relationship._find | protected function _find($id, $options = [])
{
$defaults = [
'query' => [],
'fetchOptions' => []
];
$options += $defaults;
$fetchOptions = $options['fetchOptions'];
unset($options['fetchOptions']);
if ($this->link() !== static::LINK_KEY) {
throw new ORMException("This relation is not based on a foreign key.");
}
$to = $this->to();
$schema = $to::definition();
if (!$id) {
return $to::create([], ['type' => 'set']);
}
$ids = is_array($id) ? $id : [$id];
$key = $schema->key();
$column = $schema->column($key);
foreach ($ids as $i => $value) {
$ids[$i] = $schema->convert('cast', $column['type'], $value, $column);
}
if (count($ids) === 1) {
$ids = reset($ids);
}
$conditions = [$this->keys('to') => $ids];
if ($this->conditions()) {
$conditions = [
':and()' => [
[$this->keys('to') => $ids],
$this->conditions()
]
];
}
$query = Set::extend($options['query'], ['conditions' => $conditions]);
return $to::all($query, $fetchOptions);
} | php | protected function _find($id, $options = [])
{
$defaults = [
'query' => [],
'fetchOptions' => []
];
$options += $defaults;
$fetchOptions = $options['fetchOptions'];
unset($options['fetchOptions']);
if ($this->link() !== static::LINK_KEY) {
throw new ORMException("This relation is not based on a foreign key.");
}
$to = $this->to();
$schema = $to::definition();
if (!$id) {
return $to::create([], ['type' => 'set']);
}
$ids = is_array($id) ? $id : [$id];
$key = $schema->key();
$column = $schema->column($key);
foreach ($ids as $i => $value) {
$ids[$i] = $schema->convert('cast', $column['type'], $value, $column);
}
if (count($ids) === 1) {
$ids = reset($ids);
}
$conditions = [$this->keys('to') => $ids];
if ($this->conditions()) {
$conditions = [
':and()' => [
[$this->keys('to') => $ids],
$this->conditions()
]
];
}
$query = Set::extend($options['query'], ['conditions' => $conditions]);
return $to::all($query, $fetchOptions);
} | [
"protected",
"function",
"_find",
"(",
"$",
"id",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'query'",
"=>",
"[",
"]",
",",
"'fetchOptions'",
"=>",
"[",
"]",
"]",
";",
"$",
"options",
"+=",
"$",
"defaults",
";",
"$"... | Gets all entities attached to a collection en entities.
@param mixed $id An id or an array of ids.
@return object A collection of items matching the id/ids. | [
"Gets",
"all",
"entities",
"attached",
"to",
"a",
"collection",
"en",
"entities",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Relationship.php#L346-L389 | train |
crysalead/chaos-orm | src/Relationship.php | Relationship._index | protected function _index($collection, $name)
{
$indexes = [];
foreach ($collection as $key => $entity) {
if (is_object($entity)) {
if ($entity->{$name}) {
$indexes[(string) $entity->{$name}] = $key;
}
} else {
if (isset($entity[$name])) {
$indexes[(string) $entity[$name]] = $key;
}
}
}
return $indexes;
} | php | protected function _index($collection, $name)
{
$indexes = [];
foreach ($collection as $key => $entity) {
if (is_object($entity)) {
if ($entity->{$name}) {
$indexes[(string) $entity->{$name}] = $key;
}
} else {
if (isset($entity[$name])) {
$indexes[(string) $entity[$name]] = $key;
}
}
}
return $indexes;
} | [
"protected",
"function",
"_index",
"(",
"$",
"collection",
",",
"$",
"name",
")",
"{",
"$",
"indexes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"key",
"=>",
"$",
"entity",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"entity... | Indexes a collection.
@param mixed $collection An collection to extract index from.
@param string $name The field name to build index for.
@return Array An array of indexes where keys are `$name` values and
values the corresponding index in the collection. | [
"Indexes",
"a",
"collection",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Relationship.php#L399-L414 | train |
crysalead/chaos-orm | src/Relationship.php | Relationship._cleanup | public function _cleanup(&$collection)
{
$name = $this->name();
if ($this->isMany()) {
foreach ($collection as $index => $entity) {
if (is_object($entity)) {
$entity->{$name} = [];
} else {
$collection[$index][$name] = [];
}
}
return;
}
foreach ($collection as $index => $entity) {
if (is_object($entity)) {
unset($entity->{$name});
} else {
unset($entity[$name]);
}
}
} | php | public function _cleanup(&$collection)
{
$name = $this->name();
if ($this->isMany()) {
foreach ($collection as $index => $entity) {
if (is_object($entity)) {
$entity->{$name} = [];
} else {
$collection[$index][$name] = [];
}
}
return;
}
foreach ($collection as $index => $entity) {
if (is_object($entity)) {
unset($entity->{$name});
} else {
unset($entity[$name]);
}
}
} | [
"public",
"function",
"_cleanup",
"(",
"&",
"$",
"collection",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"name",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isMany",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"index"... | Unsets the relationship attached to a collection en entities.
@param mixed $collection An collection to "clean up". | [
"Unsets",
"the",
"relationship",
"attached",
"to",
"a",
"collection",
"en",
"entities",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Relationship.php#L421-L443 | train |
crysalead/chaos-orm | src/Relationship.php | Relationship.validates | public function validates($entity, $options = [])
{
$fieldname = $this->name();
if (!isset($entity->{$fieldname})) {
return true;
}
return $entity->{$fieldname}->validates($options);
} | php | public function validates($entity, $options = [])
{
$fieldname = $this->name();
if (!isset($entity->{$fieldname})) {
return true;
}
return $entity->{$fieldname}->validates($options);
} | [
"public",
"function",
"validates",
"(",
"$",
"entity",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"fieldname",
"=",
"$",
"this",
"->",
"name",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"entity",
"->",
"{",
"$",
"fieldname",
"}",
... | Check if an entity is valid or not.
@param object $entity The relation's entity.
@param array $options The validation options.
@return boolean | [
"Check",
"if",
"an",
"entity",
"is",
"valid",
"or",
"not",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Relationship.php#L452-L460 | train |
wikiworldorder/survloop | src/Controllers/Middleware/Authenticate.php | Authenticate.redirectTo | protected function redirectTo($request)
{
session()->put('loginRedir', $_SERVER["REQUEST_URI"]);
session()->put('loginRedirTime', time());
if (!$request->expectsJson()) {
return route('login');
}
} | php | protected function redirectTo($request)
{
session()->put('loginRedir', $_SERVER["REQUEST_URI"]);
session()->put('loginRedirTime', time());
if (!$request->expectsJson()) {
return route('login');
}
} | [
"protected",
"function",
"redirectTo",
"(",
"$",
"request",
")",
"{",
"session",
"(",
")",
"->",
"put",
"(",
"'loginRedir'",
",",
"$",
"_SERVER",
"[",
"\"REQUEST_URI\"",
"]",
")",
";",
"session",
"(",
")",
"->",
"put",
"(",
"'loginRedirTime'",
",",
"time... | Get the path the user should be redirected to when they are not authenticated.
@param \Illuminate\Http\Request $request
@return string | [
"Get",
"the",
"path",
"the",
"user",
"should",
"be",
"redirected",
"to",
"when",
"they",
"are",
"not",
"authenticated",
"."
] | 7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a | https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/Middleware/Authenticate.php#L12-L19 | train |
kenarkose/Transit | src/Console/CreateModelCommand.php | CreateModelCommand.promptMigration | protected function promptMigration($name)
{
$this->line('');
if ($this->confirm('Would you like to create the migration for the model? [Yes|no]'))
{
$this->call('transit:migration', ['table' => str_plural($name)]);
}
} | php | protected function promptMigration($name)
{
$this->line('');
if ($this->confirm('Would you like to create the migration for the model? [Yes|no]'))
{
$this->call('transit:migration', ['table' => str_plural($name)]);
}
} | [
"protected",
"function",
"promptMigration",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"line",
"(",
"''",
")",
";",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"'Would you like to create the migration for the model? [Yes|no]'",
")",
")",
"{",
"$",
"this"... | Prompts for migration
@param $name | [
"Prompts",
"for",
"migration"
] | de8e1cd23d0f5814a5d3a6c1795d6f414046adbb | https://github.com/kenarkose/Transit/blob/de8e1cd23d0f5814a5d3a6c1795d6f414046adbb/src/Console/CreateModelCommand.php#L119-L127 | train |
usemarkup/contentful | src/Decorator/CompositeAssetDecorator.php | CompositeAssetDecorator.decorate | public function decorate(AssetInterface $asset)
{
foreach ($this->decorators as $decorator) {
/**
* @var AssetDecoratorInterface $decorator
*/
$asset = $decorator->decorate($asset);
}
return $asset;
} | php | public function decorate(AssetInterface $asset)
{
foreach ($this->decorators as $decorator) {
/**
* @var AssetDecoratorInterface $decorator
*/
$asset = $decorator->decorate($asset);
}
return $asset;
} | [
"public",
"function",
"decorate",
"(",
"AssetInterface",
"$",
"asset",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"decorators",
"as",
"$",
"decorator",
")",
"{",
"/**\n * @var AssetDecoratorInterface $decorator\n */",
"$",
"asset",
"=",
"$",
... | Decorates an asset.
@param AssetInterface $asset
@return AssetInterface | [
"Decorates",
"an",
"asset",
"."
] | ac5902bf891c52fd00d349bd5aae78d516dcd601 | https://github.com/usemarkup/contentful/blob/ac5902bf891c52fd00d349bd5aae78d516dcd601/src/Decorator/CompositeAssetDecorator.php#L25-L35 | train |
yangjian102621/herosphp | src/http/HttpRequest.php | HttpRequest.getParameter | public function getParameter( $name, $func_str=null, $setParam=true ) {
if ( !$func_str ) return urldecode($this->parameters[$name]) ? urldecode($this->parameters[$name]) : $this->parameters[$name];
$funcs = explode("|", $func_str);
$args = urldecode($this->parameters[$name]);
foreach ( $funcs as $func ) {
$args = call_user_func($func, $args);
}
if ( $setParam ) {
$this->parameters[$name] = $args;
}
return $args;
} | php | public function getParameter( $name, $func_str=null, $setParam=true ) {
if ( !$func_str ) return urldecode($this->parameters[$name]) ? urldecode($this->parameters[$name]) : $this->parameters[$name];
$funcs = explode("|", $func_str);
$args = urldecode($this->parameters[$name]);
foreach ( $funcs as $func ) {
$args = call_user_func($func, $args);
}
if ( $setParam ) {
$this->parameters[$name] = $args;
}
return $args;
} | [
"public",
"function",
"getParameter",
"(",
"$",
"name",
",",
"$",
"func_str",
"=",
"null",
",",
"$",
"setParam",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"func_str",
")",
"return",
"urldecode",
"(",
"$",
"this",
"->",
"parameters",
"[",
"$",
"name... | Get a parameter's value.
@param string $name
参数名称
@param $func_str
函数名称,参数需要用哪些函数去处理
@param boolean $setParam 是否重置参数
@return int|string | [
"Get",
"a",
"parameter",
"s",
"value",
"."
] | dc0a7b1c73b005098fd627977cd787eb0ab4a4e2 | https://github.com/yangjian102621/herosphp/blob/dc0a7b1c73b005098fd627977cd787eb0ab4a4e2/src/http/HttpRequest.php#L150-L164 | train |
yangjian102621/herosphp | src/files/FileUpload.php | FileUpload.upload | public function upload($_field, $_base64 = false) {
if ( !$this->checkUploadDir() ) {
$this->errNum = 6;
return false;
}
if ( $_base64 ) {
$_data = $_POST[$_field];
return $this->makeBase64Image( $_data );
}
$_localFile = $_FILES[$_field]['name'];
if ( !$_localFile ) {
$this->errNum = 10;
return false;
}
$_tempFile = $_FILES[$_field]['tmp_name'];//原来是这样
//$_tempFile = str_replace('\\\\', '\\', $_FILES[$_field]['tmp_name']);//MAGIC_QUOTES_GPC=OFF时,做了这样处理:$_FILES = daddslashes($_FILES);图片上传后tmp_name值变成 X:\\Temp\\php668E.tmp,结果move_uploaded_file() 函数判断为不合法的文件而返回FALSE。
$_error_no = $_FILES[$_field]['error'];
$this->fileInfo['file_type'] = $_FILES[$_field]['type'];
$this->fileInfo['local_name'] = $_localFile;
$this->fileInfo['file_size'] = $_FILES[$_field]['size'];
$this->errNum = $_error_no;
if ( $this->errNum == 0 ) {
$this->checkFileType($_localFile);
if ( $this->errNum == 0 ) {
$this->checkFileSize($_tempFile);
if ( $this->errNum == 0 ) {
if ( is_uploaded_file($_tempFile) ) {
$_new_filename = $this->getFileName($_localFile);
$this->fileInfo['file_path'] = $this->config['upload_dir'].DIRECTORY_SEPARATOR.$_new_filename;
if ( move_uploaded_file($_tempFile, $this->fileInfo['file_path']) ) {
$_filename = $_new_filename;
$this->fileInfo['file_name'] = $_filename;
$pathinfo = pathinfo($this->fileInfo['file_path']);
$this->fileInfo['file_ext'] = $pathinfo['extension'];
$this->fileInfo['raw_name'] = $pathinfo['filename'];
return $this->fileInfo;
} else {
$this->errNum = 7;
}
}
}
}
}
return false;
} | php | public function upload($_field, $_base64 = false) {
if ( !$this->checkUploadDir() ) {
$this->errNum = 6;
return false;
}
if ( $_base64 ) {
$_data = $_POST[$_field];
return $this->makeBase64Image( $_data );
}
$_localFile = $_FILES[$_field]['name'];
if ( !$_localFile ) {
$this->errNum = 10;
return false;
}
$_tempFile = $_FILES[$_field]['tmp_name'];//原来是这样
//$_tempFile = str_replace('\\\\', '\\', $_FILES[$_field]['tmp_name']);//MAGIC_QUOTES_GPC=OFF时,做了这样处理:$_FILES = daddslashes($_FILES);图片上传后tmp_name值变成 X:\\Temp\\php668E.tmp,结果move_uploaded_file() 函数判断为不合法的文件而返回FALSE。
$_error_no = $_FILES[$_field]['error'];
$this->fileInfo['file_type'] = $_FILES[$_field]['type'];
$this->fileInfo['local_name'] = $_localFile;
$this->fileInfo['file_size'] = $_FILES[$_field]['size'];
$this->errNum = $_error_no;
if ( $this->errNum == 0 ) {
$this->checkFileType($_localFile);
if ( $this->errNum == 0 ) {
$this->checkFileSize($_tempFile);
if ( $this->errNum == 0 ) {
if ( is_uploaded_file($_tempFile) ) {
$_new_filename = $this->getFileName($_localFile);
$this->fileInfo['file_path'] = $this->config['upload_dir'].DIRECTORY_SEPARATOR.$_new_filename;
if ( move_uploaded_file($_tempFile, $this->fileInfo['file_path']) ) {
$_filename = $_new_filename;
$this->fileInfo['file_name'] = $_filename;
$pathinfo = pathinfo($this->fileInfo['file_path']);
$this->fileInfo['file_ext'] = $pathinfo['extension'];
$this->fileInfo['raw_name'] = $pathinfo['filename'];
return $this->fileInfo;
} else {
$this->errNum = 7;
}
}
}
}
}
return false;
} | [
"public",
"function",
"upload",
"(",
"$",
"_field",
",",
"$",
"_base64",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"checkUploadDir",
"(",
")",
")",
"{",
"$",
"this",
"->",
"errNum",
"=",
"6",
";",
"return",
"false",
";",
"}",
"if... | upload file method.
@param sting $_field name of form elements.
@param bool $_base64
@return mixed false or file info array. | [
"upload",
"file",
"method",
"."
] | dc0a7b1c73b005098fd627977cd787eb0ab4a4e2 | https://github.com/yangjian102621/herosphp/blob/dc0a7b1c73b005098fd627977cd787eb0ab4a4e2/src/files/FileUpload.php#L91-L144 | train |
thelia-modules/AttributeType | Model/Base/AttributeTypeAvMeta.php | AttributeTypeAvMeta.setAttributeAv | public function setAttributeAv(ChildAttributeAv $v = null)
{
if ($v === null) {
$this->setAttributeAvId(NULL);
} else {
$this->setAttributeAvId($v->getId());
}
$this->aAttributeAv = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildAttributeAv object, it will not be re-added.
if ($v !== null) {
$v->addAttributeTypeAvMeta($this);
}
return $this;
} | php | public function setAttributeAv(ChildAttributeAv $v = null)
{
if ($v === null) {
$this->setAttributeAvId(NULL);
} else {
$this->setAttributeAvId($v->getId());
}
$this->aAttributeAv = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildAttributeAv object, it will not be re-added.
if ($v !== null) {
$v->addAttributeTypeAvMeta($this);
}
return $this;
} | [
"public",
"function",
"setAttributeAv",
"(",
"ChildAttributeAv",
"$",
"v",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setAttributeAvId",
"(",
"NULL",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setAtt... | Declares an association between this object and a ChildAttributeAv object.
@param ChildAttributeAv $v
@return \AttributeType\Model\AttributeTypeAvMeta The current object (for fluent API support)
@throws PropelException | [
"Declares",
"an",
"association",
"between",
"this",
"object",
"and",
"a",
"ChildAttributeAv",
"object",
"."
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeTypeAvMeta.php#L1358-L1376 | train |
thelia-modules/AttributeType | Model/Base/AttributeTypeAvMeta.php | AttributeTypeAvMeta.getAttributeAv | public function getAttributeAv(ConnectionInterface $con = null)
{
if ($this->aAttributeAv === null && ($this->attribute_av_id !== null)) {
$this->aAttributeAv = AttributeAvQuery::create()->findPk($this->attribute_av_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aAttributeAv->addAttributeTypeAvMetas($this);
*/
}
return $this->aAttributeAv;
} | php | public function getAttributeAv(ConnectionInterface $con = null)
{
if ($this->aAttributeAv === null && ($this->attribute_av_id !== null)) {
$this->aAttributeAv = AttributeAvQuery::create()->findPk($this->attribute_av_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aAttributeAv->addAttributeTypeAvMetas($this);
*/
}
return $this->aAttributeAv;
} | [
"public",
"function",
"getAttributeAv",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aAttributeAv",
"===",
"null",
"&&",
"(",
"$",
"this",
"->",
"attribute_av_id",
"!==",
"null",
")",
")",
"{",
"$",
"this"... | Get the associated ChildAttributeAv object
@param ConnectionInterface $con Optional Connection object.
@return ChildAttributeAv The associated ChildAttributeAv object.
@throws PropelException | [
"Get",
"the",
"associated",
"ChildAttributeAv",
"object"
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeTypeAvMeta.php#L1386-L1400 | train |
thelia-modules/AttributeType | Model/Base/AttributeTypeAvMeta.php | AttributeTypeAvMeta.setAttributeAttributeType | public function setAttributeAttributeType(ChildAttributeAttributeType $v = null)
{
if ($v === null) {
$this->setAttributeAttributeTypeId(NULL);
} else {
$this->setAttributeAttributeTypeId($v->getId());
}
$this->aAttributeAttributeType = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildAttributeAttributeType object, it will not be re-added.
if ($v !== null) {
$v->addAttributeTypeAvMeta($this);
}
return $this;
} | php | public function setAttributeAttributeType(ChildAttributeAttributeType $v = null)
{
if ($v === null) {
$this->setAttributeAttributeTypeId(NULL);
} else {
$this->setAttributeAttributeTypeId($v->getId());
}
$this->aAttributeAttributeType = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildAttributeAttributeType object, it will not be re-added.
if ($v !== null) {
$v->addAttributeTypeAvMeta($this);
}
return $this;
} | [
"public",
"function",
"setAttributeAttributeType",
"(",
"ChildAttributeAttributeType",
"$",
"v",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setAttributeAttributeTypeId",
"(",
"NULL",
")",
";",
"}",
"else",
"{",
... | Declares an association between this object and a ChildAttributeAttributeType object.
@param ChildAttributeAttributeType $v
@return \AttributeType\Model\AttributeTypeAvMeta The current object (for fluent API support)
@throws PropelException | [
"Declares",
"an",
"association",
"between",
"this",
"object",
"and",
"a",
"ChildAttributeAttributeType",
"object",
"."
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeTypeAvMeta.php#L1409-L1427 | train |
thelia-modules/AttributeType | Model/Base/AttributeTypeAvMeta.php | AttributeTypeAvMeta.getAttributeAttributeType | public function getAttributeAttributeType(ConnectionInterface $con = null)
{
if ($this->aAttributeAttributeType === null && ($this->attribute_attribute_type_id !== null)) {
$this->aAttributeAttributeType = ChildAttributeAttributeTypeQuery::create()->findPk($this->attribute_attribute_type_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aAttributeAttributeType->addAttributeTypeAvMetas($this);
*/
}
return $this->aAttributeAttributeType;
} | php | public function getAttributeAttributeType(ConnectionInterface $con = null)
{
if ($this->aAttributeAttributeType === null && ($this->attribute_attribute_type_id !== null)) {
$this->aAttributeAttributeType = ChildAttributeAttributeTypeQuery::create()->findPk($this->attribute_attribute_type_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aAttributeAttributeType->addAttributeTypeAvMetas($this);
*/
}
return $this->aAttributeAttributeType;
} | [
"public",
"function",
"getAttributeAttributeType",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aAttributeAttributeType",
"===",
"null",
"&&",
"(",
"$",
"this",
"->",
"attribute_attribute_type_id",
"!==",
"null",
... | Get the associated ChildAttributeAttributeType object
@param ConnectionInterface $con Optional Connection object.
@return ChildAttributeAttributeType The associated ChildAttributeAttributeType object.
@throws PropelException | [
"Get",
"the",
"associated",
"ChildAttributeAttributeType",
"object"
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeTypeAvMeta.php#L1437-L1451 | train |
orchestral/model | src/Concerns/Owns.php | Owns.scopeOwns | public function scopeOwns(Builder $query, Model $related, ?string $foreignKey = null): Builder
{
if (\is_null($foreignKey)) {
$foreignKey = $this->getForeignKey();
}
return $query->where(
$this->getKeyName(), $related->getAttribute($foreignKey)
);
} | php | public function scopeOwns(Builder $query, Model $related, ?string $foreignKey = null): Builder
{
if (\is_null($foreignKey)) {
$foreignKey = $this->getForeignKey();
}
return $query->where(
$this->getKeyName(), $related->getAttribute($foreignKey)
);
} | [
"public",
"function",
"scopeOwns",
"(",
"Builder",
"$",
"query",
",",
"Model",
"$",
"related",
",",
"?",
"string",
"$",
"foreignKey",
"=",
"null",
")",
":",
"Builder",
"{",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"foreignKey",
")",
")",
"{",
"$",
"fore... | Scope query to get model which related model actually owns the relationship.
@param \Illuminate\Database\Eloquent\Builder $query
@param \Illuminate\Database\Eloquent\Model $related
@param string|null $foreignKey
@return \Illuminate\Database\Eloquent\Builder | [
"Scope",
"query",
"to",
"get",
"model",
"which",
"related",
"model",
"actually",
"owns",
"the",
"relationship",
"."
] | 59eb60a022afb3caa0ac5824d6faac85f3255c0d | https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/Concerns/Owns.php#L19-L28 | train |
crysalead/chaos-orm | src/Collection/Collection.php | Collection.setAt | public function setAt($offset, $data, $options = [])
{
$keys = is_array($offset) ? $offset : ($offset !== null ? explode('.', $offset) : []);
$name = array_shift($keys);
if ($keys) {
$this->get($name)->setAt($keys, $data, $options);
}
if ($schema = $this->schema()) {
$data = $schema->cast(null, $data, [
'exists' => isset($options['exists']) ? $options['exists'] : null,
'parent' => $this,
'basePath' => $this->basePath(),
'defaults' => true
]);
}
if ($name !== null) {
if (!is_numeric($name)) {
throw new ORMException("Invalid index `" . $name . "` for a collection, must be a numeric value.");
}
$previous = isset($this->_data[$name]) ? $this->_data[$name] : null;
$this->_data[$name] = $data;
if ($previous instanceof HasParentsInterface) {
$previous->unsetParent($this);
}
} else {
$this->_data[] = $data;
$name = key($this->_data);
}
if ($data instanceof HasParentsInterface) {
$data->setParent($this, $name);
}
$this->_modified = true;
return $this;
} | php | public function setAt($offset, $data, $options = [])
{
$keys = is_array($offset) ? $offset : ($offset !== null ? explode('.', $offset) : []);
$name = array_shift($keys);
if ($keys) {
$this->get($name)->setAt($keys, $data, $options);
}
if ($schema = $this->schema()) {
$data = $schema->cast(null, $data, [
'exists' => isset($options['exists']) ? $options['exists'] : null,
'parent' => $this,
'basePath' => $this->basePath(),
'defaults' => true
]);
}
if ($name !== null) {
if (!is_numeric($name)) {
throw new ORMException("Invalid index `" . $name . "` for a collection, must be a numeric value.");
}
$previous = isset($this->_data[$name]) ? $this->_data[$name] : null;
$this->_data[$name] = $data;
if ($previous instanceof HasParentsInterface) {
$previous->unsetParent($this);
}
} else {
$this->_data[] = $data;
$name = key($this->_data);
}
if ($data instanceof HasParentsInterface) {
$data->setParent($this, $name);
}
$this->_modified = true;
return $this;
} | [
"public",
"function",
"setAt",
"(",
"$",
"offset",
",",
"$",
"data",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"keys",
"=",
"is_array",
"(",
"$",
"offset",
")",
"?",
"$",
"offset",
":",
"(",
"$",
"offset",
"!==",
"null",
"?",
"explode",
... | Sets data inside the `Collection` instance.
@param mixed $offset The offset.
@param mixed $data The entity object or data to set.
@param array $options Method options:
- `'exists'` _boolean_: Determines whether or not this entity exists
@return mixed Returns `$this`. | [
"Sets",
"data",
"inside",
"the",
"Collection",
"instance",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Collection/Collection.php#L300-L336 | train |
crysalead/chaos-orm | src/Collection/Collection.php | Collection.offsetExists | public function offsetExists($offset)
{
$keys = is_array($offset) ? $offset : explode('.', $offset);
if (!$keys) {
return false;
}
$name = array_shift($keys);
if ($keys) {
if (!array_key_exists($name, $this->_data)) {
return false;
}
$value = $this->_data[$name];
if ($value instanceof ArrayAccess) {
return $value->offsetExists($keys);
}
return false;
}
return array_key_exists($name, $this->_data);
} | php | public function offsetExists($offset)
{
$keys = is_array($offset) ? $offset : explode('.', $offset);
if (!$keys) {
return false;
}
$name = array_shift($keys);
if ($keys) {
if (!array_key_exists($name, $this->_data)) {
return false;
}
$value = $this->_data[$name];
if ($value instanceof ArrayAccess) {
return $value->offsetExists($keys);
}
return false;
}
return array_key_exists($name, $this->_data);
} | [
"public",
"function",
"offsetExists",
"(",
"$",
"offset",
")",
"{",
"$",
"keys",
"=",
"is_array",
"(",
"$",
"offset",
")",
"?",
"$",
"offset",
":",
"explode",
"(",
"'.'",
",",
"$",
"offset",
")",
";",
"if",
"(",
"!",
"$",
"keys",
")",
"{",
"retur... | Returns a boolean indicating whether an offset exists for the current `Collection`.
@param string $offset String or integer indicating the offset or index of an entity in the set.
@return boolean Result. | [
"Returns",
"a",
"boolean",
"indicating",
"whether",
"an",
"offset",
"exists",
"for",
"the",
"current",
"Collection",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Collection/Collection.php#L380-L400 | train |
crysalead/chaos-orm | src/Collection/Collection.php | Collection.modified | public function modified($options = [])
{
$options += ['embed' => false];
if ($this->_modified) {
return true;
}
foreach ($this->_data as $index => $entity) {
if (is_object($entity) && method_exists($entity, 'modified') && $entity->modified($options)) {
return true;
}
}
return false;
} | php | public function modified($options = [])
{
$options += ['embed' => false];
if ($this->_modified) {
return true;
}
foreach ($this->_data as $index => $entity) {
if (is_object($entity) && method_exists($entity, 'modified') && $entity->modified($options)) {
return true;
}
}
return false;
} | [
"public",
"function",
"modified",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"[",
"'embed'",
"=>",
"false",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"_modified",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"... | Get the modified state of the collection.
@return boolean | [
"Get",
"the",
"modified",
"state",
"of",
"the",
"collection",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Collection/Collection.php#L467-L481 | train |
crysalead/chaos-orm | src/Collection/Collection.php | Collection.errors | public function errors($options = [])
{
$errors = [];
$errored = false;
foreach ($this as $entity) {
$result = $entity->errors($options);
$errors[] = $result;
if ($result) {
$errored = true;
}
}
return $errored ? $errors : [];
} | php | public function errors($options = [])
{
$errors = [];
$errored = false;
foreach ($this as $entity) {
$result = $entity->errors($options);
$errors[] = $result;
if ($result) {
$errored = true;
}
}
return $errored ? $errors : [];
} | [
"public",
"function",
"errors",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"$",
"errored",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"entity",
")",
"{",
"$",
"result",
"=",
"$",
"entity",
"... | Returns the errors from the last validate call.
@return array The occured errors. | [
"Returns",
"the",
"errors",
"from",
"the",
"last",
"validate",
"call",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Collection/Collection.php#L924-L936 | train |
crysalead/chaos-orm | src/Collection/Collection.php | Collection.hierarchy | public function hierarchy($prefix = '', &$ignore = [], $index = false)
{
$hash = spl_object_hash($this);
if (isset($ignore[$hash])) {
return false;
}
$ignore[$hash] = true;
$result = [];
foreach ($this as $entity) {
if ($hierarchy = $entity->hierarchy($prefix, $ignore, true)) {
$result += $hierarchy;
}
}
return $index ? $result : array_keys($result);
} | php | public function hierarchy($prefix = '', &$ignore = [], $index = false)
{
$hash = spl_object_hash($this);
if (isset($ignore[$hash])) {
return false;
}
$ignore[$hash] = true;
$result = [];
foreach ($this as $entity) {
if ($hierarchy = $entity->hierarchy($prefix, $ignore, true)) {
$result += $hierarchy;
}
}
return $index ? $result : array_keys($result);
} | [
"public",
"function",
"hierarchy",
"(",
"$",
"prefix",
"=",
"''",
",",
"&",
"$",
"ignore",
"=",
"[",
"]",
",",
"$",
"index",
"=",
"false",
")",
"{",
"$",
"hash",
"=",
"spl_object_hash",
"(",
"$",
"this",
")",
";",
"if",
"(",
"isset",
"(",
"$",
... | Returns an array of all external relations and nested relations names.
@param string $prefix The parent relation path.
@param array $ignore The already processed entities to ignore (address circular dependencies).
@param boolean $index Returns an indexed array or not.
@return array|false Returns an array of relation names or `false` when a circular loop is reached. | [
"Returns",
"an",
"array",
"of",
"all",
"external",
"relations",
"and",
"nested",
"relations",
"names",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Collection/Collection.php#L946-L963 | train |
noetix/pin-php | src/Pin/Handler.php | Handler.setDefaultOptions | protected function setDefaultOptions(OptionsResolver $resolver)
{
$resolver
->setDefaults(array(
'host' => function(Options $options) {
if (isset($options['test']) && $options['test']) {
return 'https://test-api.pin.net.au';
}
return 'https://api.pin.net.au';
}
))
->setRequired(array(
'key'
))
->setDefined(array(
'host',
'test',
'timeout',
))
->setAllowedTypes('host', 'string')
->setAllowedTypes('key', 'string')
->setAllowedTypes('test', 'bool')
->setAllowedTypes('timeout', 'int')
;
} | php | protected function setDefaultOptions(OptionsResolver $resolver)
{
$resolver
->setDefaults(array(
'host' => function(Options $options) {
if (isset($options['test']) && $options['test']) {
return 'https://test-api.pin.net.au';
}
return 'https://api.pin.net.au';
}
))
->setRequired(array(
'key'
))
->setDefined(array(
'host',
'test',
'timeout',
))
->setAllowedTypes('host', 'string')
->setAllowedTypes('key', 'string')
->setAllowedTypes('test', 'bool')
->setAllowedTypes('timeout', 'int')
;
} | [
"protected",
"function",
"setDefaultOptions",
"(",
"OptionsResolver",
"$",
"resolver",
")",
"{",
"$",
"resolver",
"->",
"setDefaults",
"(",
"array",
"(",
"'host'",
"=>",
"function",
"(",
"Options",
"$",
"options",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"o... | Set our default options.
@param OptionsResolver $resolver | [
"Set",
"our",
"default",
"options",
"."
] | a7a31cdca7c52a199e40e50dc54af58acb8b9e83 | https://github.com/noetix/pin-php/blob/a7a31cdca7c52a199e40e50dc54af58acb8b9e83/src/Pin/Handler.php#L35-L60 | train |
apioo/psx-framework | src/Util/Annotation/DocBlock.php | DocBlock.addAnnotation | public function addAnnotation($key, $value)
{
if (!isset($this->annotations[$key])) {
$this->annotations[$key] = array();
}
$this->annotations[$key][] = $value;
} | php | public function addAnnotation($key, $value)
{
if (!isset($this->annotations[$key])) {
$this->annotations[$key] = array();
}
$this->annotations[$key][] = $value;
} | [
"public",
"function",
"addAnnotation",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"annotations",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"annotations",
"[",
"$",
"key",
"]",
"=",... | Adds an annotation
@param string $key
@param string $value
@return void | [
"Adds",
"an",
"annotation"
] | e8e550a1a87dae49b615b42a05583395088c1efb | https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Util/Annotation/DocBlock.php#L41-L48 | train |
fsi-open/doctrine-extensions | lib/FSi/DoctrineExtensions/Uploadable/UploadableListener.php | UploadableListener.postLoad | public function postLoad(LifecycleEventArgs $eventArgs)
{
$entityManager = $eventArgs->getEntityManager();
$object = $eventArgs->getEntity();
$uploadableMeta = $this->getObjectExtendedMetadata($entityManager, $object);
if ($uploadableMeta->hasUploadableProperties()) {
$this->loadFiles($entityManager, $object, $uploadableMeta);
}
} | php | public function postLoad(LifecycleEventArgs $eventArgs)
{
$entityManager = $eventArgs->getEntityManager();
$object = $eventArgs->getEntity();
$uploadableMeta = $this->getObjectExtendedMetadata($entityManager, $object);
if ($uploadableMeta->hasUploadableProperties()) {
$this->loadFiles($entityManager, $object, $uploadableMeta);
}
} | [
"public",
"function",
"postLoad",
"(",
"LifecycleEventArgs",
"$",
"eventArgs",
")",
"{",
"$",
"entityManager",
"=",
"$",
"eventArgs",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"object",
"=",
"$",
"eventArgs",
"->",
"getEntity",
"(",
")",
";",
"$",
"upl... | After loading the entity load file if any.
@param LifecycleEventArgs $eventArgs | [
"After",
"loading",
"the",
"entity",
"load",
"file",
"if",
"any",
"."
] | eb4fd3e8706b8dafe039e52cb0d1515cc7586fcc | https://github.com/fsi-open/doctrine-extensions/blob/eb4fd3e8706b8dafe039e52cb0d1515cc7586fcc/lib/FSi/DoctrineExtensions/Uploadable/UploadableListener.php#L174-L183 | train |
fsi-open/doctrine-extensions | lib/FSi/DoctrineExtensions/Uploadable/UploadableListener.php | UploadableListener.preFlush | public function preFlush(PreFlushEventArgs $eventArgs)
{
$entityManager = $eventArgs->getEntityManager();
$unitOfWork = $entityManager->getUnitOfWork();
foreach ($unitOfWork->getIdentityMap() as $entities) {
foreach ($entities as $object) {
$uploadableMeta = $this->getObjectExtendedMetadata($entityManager, $object);
if (!$uploadableMeta->hasUploadableProperties()) {
continue;
}
$this->updateFiles($entityManager, $object, $uploadableMeta);
}
}
} | php | public function preFlush(PreFlushEventArgs $eventArgs)
{
$entityManager = $eventArgs->getEntityManager();
$unitOfWork = $entityManager->getUnitOfWork();
foreach ($unitOfWork->getIdentityMap() as $entities) {
foreach ($entities as $object) {
$uploadableMeta = $this->getObjectExtendedMetadata($entityManager, $object);
if (!$uploadableMeta->hasUploadableProperties()) {
continue;
}
$this->updateFiles($entityManager, $object, $uploadableMeta);
}
}
} | [
"public",
"function",
"preFlush",
"(",
"PreFlushEventArgs",
"$",
"eventArgs",
")",
"{",
"$",
"entityManager",
"=",
"$",
"eventArgs",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"unitOfWork",
"=",
"$",
"entityManager",
"->",
"getUnitOfWork",
"(",
")",
";",
... | Check and eventually update files keys.
@param PreFlushEventArgs $eventArgs | [
"Check",
"and",
"eventually",
"update",
"files",
"keys",
"."
] | eb4fd3e8706b8dafe039e52cb0d1515cc7586fcc | https://github.com/fsi-open/doctrine-extensions/blob/eb4fd3e8706b8dafe039e52cb0d1515cc7586fcc/lib/FSi/DoctrineExtensions/Uploadable/UploadableListener.php#L211-L225 | train |
fsi-open/doctrine-extensions | lib/FSi/DoctrineExtensions/Uploadable/UploadableListener.php | UploadableListener.loadFiles | protected function loadFiles(
EntityManagerInterface $entityManager,
$object,
UploadableClassMetadata $uploadableMeta
): void {
$this->assertIsObject($object);
$propertyManipulator = $this->getPropertyManipulator($entityManager);
foreach ($uploadableMeta->getUploadableProperties() as $property => $config) {
$key = $propertyManipulator->getPropertyValue($object, $property);
if (!empty($key)) {
$propertyManipulator->setAndSaveValue(
$object,
$config['targetField'],
new File($key, $this->computeFilesystem($config))
);
}
}
} | php | protected function loadFiles(
EntityManagerInterface $entityManager,
$object,
UploadableClassMetadata $uploadableMeta
): void {
$this->assertIsObject($object);
$propertyManipulator = $this->getPropertyManipulator($entityManager);
foreach ($uploadableMeta->getUploadableProperties() as $property => $config) {
$key = $propertyManipulator->getPropertyValue($object, $property);
if (!empty($key)) {
$propertyManipulator->setAndSaveValue(
$object,
$config['targetField'],
new File($key, $this->computeFilesystem($config))
);
}
}
} | [
"protected",
"function",
"loadFiles",
"(",
"EntityManagerInterface",
"$",
"entityManager",
",",
"$",
"object",
",",
"UploadableClassMetadata",
"$",
"uploadableMeta",
")",
":",
"void",
"{",
"$",
"this",
"->",
"assertIsObject",
"(",
"$",
"object",
")",
";",
"$",
... | Load object files and attach observers for key fields.
@param EntityManagerInterface $entityManager
@param object $object
@param UploadableClassMetadata $uploadableMeta
@return void | [
"Load",
"object",
"files",
"and",
"attach",
"observers",
"for",
"key",
"fields",
"."
] | eb4fd3e8706b8dafe039e52cb0d1515cc7586fcc | https://github.com/fsi-open/doctrine-extensions/blob/eb4fd3e8706b8dafe039e52cb0d1515cc7586fcc/lib/FSi/DoctrineExtensions/Uploadable/UploadableListener.php#L307-L325 | train |
fsi-open/doctrine-extensions | lib/FSi/DoctrineExtensions/Uploadable/UploadableListener.php | UploadableListener.getPropertyManipulator | private function getPropertyManipulator(EntityManagerInterface $entityManager): PropertyManipulator
{
$oid = spl_object_hash($entityManager);
if (!isset($this->propertyManipulators[$oid])) {
$this->propertyManipulators[$oid] = new PropertyManipulator();
}
return $this->propertyManipulators[$oid];
} | php | private function getPropertyManipulator(EntityManagerInterface $entityManager): PropertyManipulator
{
$oid = spl_object_hash($entityManager);
if (!isset($this->propertyManipulators[$oid])) {
$this->propertyManipulators[$oid] = new PropertyManipulator();
}
return $this->propertyManipulators[$oid];
} | [
"private",
"function",
"getPropertyManipulator",
"(",
"EntityManagerInterface",
"$",
"entityManager",
")",
":",
"PropertyManipulator",
"{",
"$",
"oid",
"=",
"spl_object_hash",
"(",
"$",
"entityManager",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
... | Returns PropertyManipulator for specified ObjectManager
@param EntityManagerInterface $entityManager
@return PropertyManipulator | [
"Returns",
"PropertyManipulator",
"for",
"specified",
"ObjectManager"
] | eb4fd3e8706b8dafe039e52cb0d1515cc7586fcc | https://github.com/fsi-open/doctrine-extensions/blob/eb4fd3e8706b8dafe039e52cb0d1515cc7586fcc/lib/FSi/DoctrineExtensions/Uploadable/UploadableListener.php#L626-L634 | train |
thelia-modules/AttributeType | Model/Map/AttributeTypeI18nTableMap.php | AttributeTypeI18nTableMap.doDelete | public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(AttributeTypeI18nTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \AttributeType\Model\AttributeTypeI18n) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(AttributeTypeI18nTableMap::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey values
if (count($values) == count($values, COUNT_RECURSIVE)) {
// array is not multi-dimensional
$values = array($values);
}
foreach ($values as $value) {
$criterion = $criteria->getNewCriterion(AttributeTypeI18nTableMap::ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(AttributeTypeI18nTableMap::LOCALE, $value[1]));
$criteria->addOr($criterion);
}
}
$query = AttributeTypeI18nQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { AttributeTypeI18nTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { AttributeTypeI18nTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
} | php | public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(AttributeTypeI18nTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \AttributeType\Model\AttributeTypeI18n) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(AttributeTypeI18nTableMap::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey values
if (count($values) == count($values, COUNT_RECURSIVE)) {
// array is not multi-dimensional
$values = array($values);
}
foreach ($values as $value) {
$criterion = $criteria->getNewCriterion(AttributeTypeI18nTableMap::ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(AttributeTypeI18nTableMap::LOCALE, $value[1]));
$criteria->addOr($criterion);
}
}
$query = AttributeTypeI18nQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { AttributeTypeI18nTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { AttributeTypeI18nTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
} | [
"public",
"static",
"function",
"doDelete",
"(",
"$",
"values",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getW... | Performs a DELETE on the database, given a AttributeTypeI18n or Criteria object OR a primary key value.
@param mixed $values Criteria or AttributeTypeI18n object or primary key or array of primary keys
which is used to create the DELETE statement
@param ConnectionInterface $con the connection to use
@return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
if supported by native driver or if emulated using Propel.
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Performs",
"a",
"DELETE",
"on",
"the",
"database",
"given",
"a",
"AttributeTypeI18n",
"or",
"Criteria",
"object",
"OR",
"a",
"primary",
"key",
"value",
"."
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Map/AttributeTypeI18nTableMap.php#L391-L427 | train |
thelia-modules/AttributeType | Model/Map/AttributeTypeI18nTableMap.php | AttributeTypeI18nTableMap.doInsert | public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(AttributeTypeI18nTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from AttributeTypeI18n object
}
// Set the correct dbName
$query = AttributeTypeI18nQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
} | php | public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(AttributeTypeI18nTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from AttributeTypeI18n object
}
// Set the correct dbName
$query = AttributeTypeI18nQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
} | [
"public",
"static",
"function",
"doInsert",
"(",
"$",
"criteria",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"ge... | Performs an INSERT on the database, given a AttributeTypeI18n or Criteria object.
@param mixed $criteria Criteria or AttributeTypeI18n object containing data that is used to create the INSERT statement.
@param ConnectionInterface $con the ConnectionInterface connection to use
@return mixed The new primary key.
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Performs",
"an",
"INSERT",
"on",
"the",
"database",
"given",
"a",
"AttributeTypeI18n",
"or",
"Criteria",
"object",
"."
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Map/AttributeTypeI18nTableMap.php#L449-L477 | train |
neutrinobg/yii2-oci2pdo | OciPdoAdapter.php | OciPdoAdapter.closeConnection | public function closeConnection() {
if (is_resource($this->_dbh)) {
$res = @oci_close($this->_dbh);
$this->checkError($res);
}
else {
$res = true;
}
return $res;
} | php | public function closeConnection() {
if (is_resource($this->_dbh)) {
$res = @oci_close($this->_dbh);
$this->checkError($res);
}
else {
$res = true;
}
return $res;
} | [
"public",
"function",
"closeConnection",
"(",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"_dbh",
")",
")",
"{",
"$",
"res",
"=",
"@",
"oci_close",
"(",
"$",
"this",
"->",
"_dbh",
")",
";",
"$",
"this",
"->",
"checkError",
"(",
"$",... | Close connection and free resources
@return boolean | [
"Close",
"connection",
"and",
"free",
"resources"
] | d0170a2722c72521c510f8dddf8028185506e465 | https://github.com/neutrinobg/yii2-oci2pdo/blob/d0170a2722c72521c510f8dddf8028185506e465/OciPdoAdapter.php#L339-L349 | train |
neutrinobg/yii2-oci2pdo | OciPdoAdapter.php | OciPdoAdapter.getError | protected function getError() {
if ($this->_error === false) {
if (is_resource($this->_dbh)) {
$this->_error = @oci_error($this->_dbh);
}
else {
$this->_error = @oci_error();
}
}
return $this->_error;
} | php | protected function getError() {
if ($this->_error === false) {
if (is_resource($this->_dbh)) {
$this->_error = @oci_error($this->_dbh);
}
else {
$this->_error = @oci_error();
}
}
return $this->_error;
} | [
"protected",
"function",
"getError",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_error",
"===",
"false",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"_dbh",
")",
")",
"{",
"$",
"this",
"->",
"_error",
"=",
"@",
"oci_error",
"(",
... | Retrieve OCI error of the connection | [
"Retrieve",
"OCI",
"error",
"of",
"the",
"connection"
] | d0170a2722c72521c510f8dddf8028185506e465 | https://github.com/neutrinobg/yii2-oci2pdo/blob/d0170a2722c72521c510f8dddf8028185506e465/OciPdoAdapter.php#L426-L437 | train |
neutrinobg/yii2-oci2pdo | OciPdoAdapter.php | OciPdoAdapter.raiseError | public function raiseError() {
$error = $this->getError();
if ($error === false) {
return;
}
$this->_error = false;
if ($error['offset'] == 0) {
$message = sprintf('%s', $error['message']);
}
else {
$message = sprintf('%s in %s at %s', $error['message'], $error['sqltext'], $error['offset']);
}
switch($this->getAttribute(PDO::ATTR_ERRMODE)) {
case PDO::ERRMODE_SILENT:
$message = sprintf('(%s) Error ' . $message, date('Y-m-d H:i:s'));
error_log($message);
break;
case PDO::ERRMODE_WARNING:
$message = 'Error ' . $message;
$message = htmlentities($message, ENT_QUOTES);
trigger_error($message, E_USER_ERROR);
break;
case PDO::ERRMODE_EXCEPTION:
default:
throw new Exception($message, $error['code']);
}
} | php | public function raiseError() {
$error = $this->getError();
if ($error === false) {
return;
}
$this->_error = false;
if ($error['offset'] == 0) {
$message = sprintf('%s', $error['message']);
}
else {
$message = sprintf('%s in %s at %s', $error['message'], $error['sqltext'], $error['offset']);
}
switch($this->getAttribute(PDO::ATTR_ERRMODE)) {
case PDO::ERRMODE_SILENT:
$message = sprintf('(%s) Error ' . $message, date('Y-m-d H:i:s'));
error_log($message);
break;
case PDO::ERRMODE_WARNING:
$message = 'Error ' . $message;
$message = htmlentities($message, ENT_QUOTES);
trigger_error($message, E_USER_ERROR);
break;
case PDO::ERRMODE_EXCEPTION:
default:
throw new Exception($message, $error['code']);
}
} | [
"public",
"function",
"raiseError",
"(",
")",
"{",
"$",
"error",
"=",
"$",
"this",
"->",
"getError",
"(",
")",
";",
"if",
"(",
"$",
"error",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"_error",
"=",
"false",
";",
"if",
"(",
... | If there is an error writes to log or triggers error or throws an exception
@throws Exception | [
"If",
"there",
"is",
"an",
"error",
"writes",
"to",
"log",
"or",
"triggers",
"error",
"or",
"throws",
"an",
"exception"
] | d0170a2722c72521c510f8dddf8028185506e465 | https://github.com/neutrinobg/yii2-oci2pdo/blob/d0170a2722c72521c510f8dddf8028185506e465/OciPdoAdapter.php#L479-L507 | train |
crysalead/chaos-orm | src/Buffer.php | Buffer.first | public function first($options = [])
{
$result = $this->get($options);
return is_object($result) ? $result->rewind() : reset($result);
} | php | public function first($options = [])
{
$result = $this->get($options);
return is_object($result) ? $result->rewind() : reset($result);
} | [
"public",
"function",
"first",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"options",
")",
";",
"return",
"is_object",
"(",
"$",
"result",
")",
"?",
"$",
"result",
"->",
"rewind",
"(",
")"... | Executes the query and returns the first result only.
@return object An entity instance. | [
"Executes",
"the",
"query",
"and",
"returns",
"the",
"first",
"result",
"only",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Buffer.php#L77-L81 | train |
fsi-open/doctrine-extensions | lib/FSi/DoctrineExtensions/Translatable/TranslatableListener.php | TranslatableListener.postLoad | public function postLoad(LifecycleEventArgs $eventArgs)
{
$this->loadTranslation(
$eventArgs->getEntityManager(),
$eventArgs->getEntity(),
$this->getLocale()
);
} | php | public function postLoad(LifecycleEventArgs $eventArgs)
{
$this->loadTranslation(
$eventArgs->getEntityManager(),
$eventArgs->getEntity(),
$this->getLocale()
);
} | [
"public",
"function",
"postLoad",
"(",
"LifecycleEventArgs",
"$",
"eventArgs",
")",
"{",
"$",
"this",
"->",
"loadTranslation",
"(",
"$",
"eventArgs",
"->",
"getEntityManager",
"(",
")",
",",
"$",
"eventArgs",
"->",
"getEntity",
"(",
")",
",",
"$",
"this",
... | After loading the entity copy the current translation fields into non-persistent
translatable properties | [
"After",
"loading",
"the",
"entity",
"copy",
"the",
"current",
"translation",
"fields",
"into",
"non",
"-",
"persistent",
"translatable",
"properties"
] | eb4fd3e8706b8dafe039e52cb0d1515cc7586fcc | https://github.com/fsi-open/doctrine-extensions/blob/eb4fd3e8706b8dafe039e52cb0d1515cc7586fcc/lib/FSi/DoctrineExtensions/Translatable/TranslatableListener.php#L91-L98 | train |
fsi-open/doctrine-extensions | lib/FSi/DoctrineExtensions/Translatable/TranslatableListener.php | TranslatableListener.preFlush | public function preFlush(PreFlushEventArgs $eventArgs)
{
$entityManager = $eventArgs->getEntityManager();
$unitOfWork = $entityManager->getUnitOfWork();
foreach ($unitOfWork->getScheduledEntityInsertions() as $object) {
$this->updateObjectTranslations($entityManager, $object);
}
foreach ($unitOfWork->getIdentityMap() as $entities) {
foreach ($entities as $object) {
$this->updateObjectTranslations($entityManager, $object);
}
}
} | php | public function preFlush(PreFlushEventArgs $eventArgs)
{
$entityManager = $eventArgs->getEntityManager();
$unitOfWork = $entityManager->getUnitOfWork();
foreach ($unitOfWork->getScheduledEntityInsertions() as $object) {
$this->updateObjectTranslations($entityManager, $object);
}
foreach ($unitOfWork->getIdentityMap() as $entities) {
foreach ($entities as $object) {
$this->updateObjectTranslations($entityManager, $object);
}
}
} | [
"public",
"function",
"preFlush",
"(",
"PreFlushEventArgs",
"$",
"eventArgs",
")",
"{",
"$",
"entityManager",
"=",
"$",
"eventArgs",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"unitOfWork",
"=",
"$",
"entityManager",
"->",
"getUnitOfWork",
"(",
")",
";",
... | This event handler will update, insert or remove translation entities if
main object's translatable properties change.
@param PreFlushEventArgs $eventArgs | [
"This",
"event",
"handler",
"will",
"update",
"insert",
"or",
"remove",
"translation",
"entities",
"if",
"main",
"object",
"s",
"translatable",
"properties",
"change",
"."
] | eb4fd3e8706b8dafe039e52cb0d1515cc7586fcc | https://github.com/fsi-open/doctrine-extensions/blob/eb4fd3e8706b8dafe039e52cb0d1515cc7586fcc/lib/FSi/DoctrineExtensions/Translatable/TranslatableListener.php#L106-L120 | train |
fsi-open/doctrine-extensions | lib/FSi/DoctrineExtensions/Translatable/TranslatableListener.php | TranslatableListener.updateObjectTranslations | private function updateObjectTranslations(EntityManagerInterface $entityManager, $object): void
{
$translatableMeta = $this->getTranslatableMetadata($entityManager, $object);
if (!$translatableMeta->hasTranslatableProperties()) {
return;
}
foreach ($translatableMeta->getTranslationAssociationMetadatas() as $associationMeta) {
$context = $this->getTranslationContext($entityManager, $associationMeta, $object);
$locale = $this->translationHelper->getObjectLocale($context, $object);
if (is_null($locale) || $locale === '') {
$locale = $this->getLocale();
}
$hasTranslatedProperties = $this->translationHelper->hasTranslatedProperties($context, $object);
if (!isset($locale) && $hasTranslatedProperties) {
throw new Exception\RuntimeException(
"Neither object's locale nor the current locale was set for translatable properties"
);
}
if ($hasTranslatedProperties) {
$this->translationHelper->copyPropertiesToTranslation(
$context,
$object,
$locale
);
} else {
$this->translationHelper->removeEmptyTranslation($context, $object);
}
}
} | php | private function updateObjectTranslations(EntityManagerInterface $entityManager, $object): void
{
$translatableMeta = $this->getTranslatableMetadata($entityManager, $object);
if (!$translatableMeta->hasTranslatableProperties()) {
return;
}
foreach ($translatableMeta->getTranslationAssociationMetadatas() as $associationMeta) {
$context = $this->getTranslationContext($entityManager, $associationMeta, $object);
$locale = $this->translationHelper->getObjectLocale($context, $object);
if (is_null($locale) || $locale === '') {
$locale = $this->getLocale();
}
$hasTranslatedProperties = $this->translationHelper->hasTranslatedProperties($context, $object);
if (!isset($locale) && $hasTranslatedProperties) {
throw new Exception\RuntimeException(
"Neither object's locale nor the current locale was set for translatable properties"
);
}
if ($hasTranslatedProperties) {
$this->translationHelper->copyPropertiesToTranslation(
$context,
$object,
$locale
);
} else {
$this->translationHelper->removeEmptyTranslation($context, $object);
}
}
} | [
"private",
"function",
"updateObjectTranslations",
"(",
"EntityManagerInterface",
"$",
"entityManager",
",",
"$",
"object",
")",
":",
"void",
"{",
"$",
"translatableMeta",
"=",
"$",
"this",
"->",
"getTranslatableMetadata",
"(",
"$",
"entityManager",
",",
"$",
"obj... | Helper method to insert, remove or update translations entities associated
with specified object.
@param EntityManagerInterface $entityManager
@param object $object
@return void
@throws Exception\RuntimeException | [
"Helper",
"method",
"to",
"insert",
"remove",
"or",
"update",
"translations",
"entities",
"associated",
"with",
"specified",
"object",
"."
] | eb4fd3e8706b8dafe039e52cb0d1515cc7586fcc | https://github.com/fsi-open/doctrine-extensions/blob/eb4fd3e8706b8dafe039e52cb0d1515cc7586fcc/lib/FSi/DoctrineExtensions/Translatable/TranslatableListener.php#L260-L291 | train |
JBZoo/Data | src/Data.php | Data.get | public function get($key, $default = null, $filter = null)
{
$result = $default;
if ($this->has($key)) {
$result = $this->offsetGet($key);
}
return $this->filter($result, $filter);
} | php | public function get($key, $default = null, $filter = null)
{
$result = $default;
if ($this->has($key)) {
$result = $this->offsetGet($key);
}
return $this->filter($result, $filter);
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
",",
"$",
"filter",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"default",
";",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"$",
"res... | Get a value from the data given its key
@param string $key The key used to fetch the data
@param mixed $default The default value
@param mixed $filter Filter returned value
@return mixed | [
"Get",
"a",
"value",
"from",
"the",
"data",
"given",
"its",
"key"
] | 1e1238e915b942b4147ea8746760423f3cbdf20b | https://github.com/JBZoo/Data/blob/1e1238e915b942b4147ea8746760423f3cbdf20b/src/Data.php#L85-L93 | train |
JBZoo/Data | src/Data.php | Data.filter | protected function filter($value, $filter)
{
if (null !== $filter) {
$value = Filter::_($value, $filter);
}
return $value;
} | php | protected function filter($value, $filter)
{
if (null !== $filter) {
$value = Filter::_($value, $filter);
}
return $value;
} | [
"protected",
"function",
"filter",
"(",
"$",
"value",
",",
"$",
"filter",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"filter",
")",
"{",
"$",
"value",
"=",
"Filter",
"::",
"_",
"(",
"$",
"value",
",",
"$",
"filter",
")",
";",
"}",
"return",
"$",
... | Filter value before return
@param mixed $value
@param mixed $filter
@return mixed
@throws \JBZoo\Utils\Exception | [
"Filter",
"value",
"before",
"return"
] | 1e1238e915b942b4147ea8746760423f3cbdf20b | https://github.com/JBZoo/Data/blob/1e1238e915b942b4147ea8746760423f3cbdf20b/src/Data.php#L195-L202 | train |
JBZoo/Data | src/Data.php | Data.is | public function is($key, $compareWith = true, $strictMode = false)
{
if (strpos($key, '.') === false) {
$value = $this->get($key);
} else {
$value = $this->find($key);
}
if ($strictMode) {
return $value === $compareWith;
}
/** @noinspection TypeUnsafeComparisonInspection */
return $value == $compareWith;
} | php | public function is($key, $compareWith = true, $strictMode = false)
{
if (strpos($key, '.') === false) {
$value = $this->get($key);
} else {
$value = $this->find($key);
}
if ($strictMode) {
return $value === $compareWith;
}
/** @noinspection TypeUnsafeComparisonInspection */
return $value == $compareWith;
} | [
"public",
"function",
"is",
"(",
"$",
"key",
",",
"$",
"compareWith",
"=",
"true",
",",
"$",
"strictMode",
"=",
"false",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'.'",
")",
"===",
"false",
")",
"{",
"$",
"value",
"=",
"$",
"this",
... | Compare value by key with somethig
@param string $key
@param mixed $compareWith
@param bool $strictMode
@return bool
@SuppressWarnings(PHPMD.ShortMethodName) | [
"Compare",
"value",
"by",
"key",
"with",
"somethig"
] | 1e1238e915b942b4147ea8746760423f3cbdf20b | https://github.com/JBZoo/Data/blob/1e1238e915b942b4147ea8746760423f3cbdf20b/src/Data.php#L294-L308 | train |
misd-service-development/php-highcharts | src/Misd/Highcharts/Renderer/Renderer.php | Renderer.renderAxis | protected function renderAxis(AxisInterface $axis)
{
$options = array(
'opposite' => $axis->isOpposite(),
'showFirstLabel' => $axis->getLabel()->isShowFirst(),
'showLastLabel' => $axis->getLabel()->isShowLast(),
);
if (0 < count($axis->getCategories())) {
$options['categories'] = array_values($axis->getCategories());
}
if (null !== $axis->getMaxValue()) {
$options['max'] = $axis->getMaxValue();
}
if (null !== $axis->getMinValue()) {
$options['min'] = $axis->getMinValue();
}
if (false === $axis->getTitle()->isEnabled()) {
$options['title']['text'] = null;
} else {
if (null !== $axis->getTitle()->getText()) {
$options['title']['text'] = $axis->getTitle()->getText();
}
if (0 < count($axis->getTitle()->getStyles())) {
$options['title']['style'] = $axis->getTitle()->getStyles();
}
}
$options['labels'] = array(
'enabled' => $axis->getLabel()->isEnabled(),
);
if (null !== $axis->getLabel()->getAlign()) {
$options['labels']['align'] = $axis->getLabel()->getAlign();
}
if (0 < count($axis->getLabel()->getStyles())) {
$options['labels']['style'] = $axis->getLabel()->getStyles();
}
if (null !== $axis->getLabel()->getXOffset()) {
$options['labels']['x'] = $axis->getLabel()->getXOffset();
}
if (null !== $axis->getLabel()->getYOffset()) {
$options['labels']['y'] = $axis->getLabel()->getYOffset();
}
if (null !== $axis->getLabel()->getFormatter()) {
$options['labels']['formatter'] = $axis->getLabel()->getFormatter();
}
$options['tickWidth'] = $axis->getTickWidth();
$options['gridLineWidth'] = $axis->getGridLineWidth();
return $options;
} | php | protected function renderAxis(AxisInterface $axis)
{
$options = array(
'opposite' => $axis->isOpposite(),
'showFirstLabel' => $axis->getLabel()->isShowFirst(),
'showLastLabel' => $axis->getLabel()->isShowLast(),
);
if (0 < count($axis->getCategories())) {
$options['categories'] = array_values($axis->getCategories());
}
if (null !== $axis->getMaxValue()) {
$options['max'] = $axis->getMaxValue();
}
if (null !== $axis->getMinValue()) {
$options['min'] = $axis->getMinValue();
}
if (false === $axis->getTitle()->isEnabled()) {
$options['title']['text'] = null;
} else {
if (null !== $axis->getTitle()->getText()) {
$options['title']['text'] = $axis->getTitle()->getText();
}
if (0 < count($axis->getTitle()->getStyles())) {
$options['title']['style'] = $axis->getTitle()->getStyles();
}
}
$options['labels'] = array(
'enabled' => $axis->getLabel()->isEnabled(),
);
if (null !== $axis->getLabel()->getAlign()) {
$options['labels']['align'] = $axis->getLabel()->getAlign();
}
if (0 < count($axis->getLabel()->getStyles())) {
$options['labels']['style'] = $axis->getLabel()->getStyles();
}
if (null !== $axis->getLabel()->getXOffset()) {
$options['labels']['x'] = $axis->getLabel()->getXOffset();
}
if (null !== $axis->getLabel()->getYOffset()) {
$options['labels']['y'] = $axis->getLabel()->getYOffset();
}
if (null !== $axis->getLabel()->getFormatter()) {
$options['labels']['formatter'] = $axis->getLabel()->getFormatter();
}
$options['tickWidth'] = $axis->getTickWidth();
$options['gridLineWidth'] = $axis->getGridLineWidth();
return $options;
} | [
"protected",
"function",
"renderAxis",
"(",
"AxisInterface",
"$",
"axis",
")",
"{",
"$",
"options",
"=",
"array",
"(",
"'opposite'",
"=>",
"$",
"axis",
"->",
"isOpposite",
"(",
")",
",",
"'showFirstLabel'",
"=>",
"$",
"axis",
"->",
"getLabel",
"(",
")",
... | Renders an axis.
@param AxisInterface $axis Axis.
@return array Options. | [
"Renders",
"an",
"axis",
"."
] | 1b4d6574f55f012325e313fab51e43fe47b2089b | https://github.com/misd-service-development/php-highcharts/blob/1b4d6574f55f012325e313fab51e43fe47b2089b/src/Misd/Highcharts/Renderer/Renderer.php#L267-L318 | train |
misd-service-development/php-highcharts | src/Misd/Highcharts/Renderer/Renderer.php | Renderer.renderDataPoint | protected function renderDataPoint(DataPointInterface $dataPoint)
{
$options = array();
if (null !== $dataPoint->getName()) {
$options['name'] = $dataPoint->getName();
}
if ($dataPoint instanceof PieDataPointInterface) {
$options['sliced'] = $dataPoint->isSliced();
}
if (null !== $dataPoint->getXValue()) {
$options['x'] = $dataPoint->getXValue();
}
$options['y'] = $dataPoint->getYValue();
return $options;
} | php | protected function renderDataPoint(DataPointInterface $dataPoint)
{
$options = array();
if (null !== $dataPoint->getName()) {
$options['name'] = $dataPoint->getName();
}
if ($dataPoint instanceof PieDataPointInterface) {
$options['sliced'] = $dataPoint->isSliced();
}
if (null !== $dataPoint->getXValue()) {
$options['x'] = $dataPoint->getXValue();
}
$options['y'] = $dataPoint->getYValue();
return $options;
} | [
"protected",
"function",
"renderDataPoint",
"(",
"DataPointInterface",
"$",
"dataPoint",
")",
"{",
"$",
"options",
"=",
"array",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"dataPoint",
"->",
"getName",
"(",
")",
")",
"{",
"$",
"options",
"[",
"'name'"... | Renders a data point.
@param DataPointInterface $dataPoint Data point.
@return array Options. | [
"Renders",
"a",
"data",
"point",
"."
] | 1b4d6574f55f012325e313fab51e43fe47b2089b | https://github.com/misd-service-development/php-highcharts/blob/1b4d6574f55f012325e313fab51e43fe47b2089b/src/Misd/Highcharts/Renderer/Renderer.php#L501-L517 | train |
hostnet/phpcs-tool | src/Hostnet/Sniffs/Functions/ReturnTypeDeclarationSniff.php | ReturnTypeDeclarationSniff.getClosingParenthesis | private function getClosingParenthesis(File $phpcs_file, array $tokens, $stack_ptr): int
{
$closing_parenthesis = $tokens[$stack_ptr]['parenthesis_closer'];
// In case the function is a closure, the closing parenthesis
// may be positioned after a use language construct.
if ($tokens[$stack_ptr]['code'] === T_CLOSURE) {
$use = $phpcs_file->findNext(T_USE, $closing_parenthesis + 1, $tokens[$stack_ptr]['scope_opener']);
if ($use !== false) {
$open_bracket = $phpcs_file->findNext(T_OPEN_PARENTHESIS, $use + 1);
$closing_parenthesis = $tokens[$open_bracket]['parenthesis_closer'];
}
}
return $closing_parenthesis;
} | php | private function getClosingParenthesis(File $phpcs_file, array $tokens, $stack_ptr): int
{
$closing_parenthesis = $tokens[$stack_ptr]['parenthesis_closer'];
// In case the function is a closure, the closing parenthesis
// may be positioned after a use language construct.
if ($tokens[$stack_ptr]['code'] === T_CLOSURE) {
$use = $phpcs_file->findNext(T_USE, $closing_parenthesis + 1, $tokens[$stack_ptr]['scope_opener']);
if ($use !== false) {
$open_bracket = $phpcs_file->findNext(T_OPEN_PARENTHESIS, $use + 1);
$closing_parenthesis = $tokens[$open_bracket]['parenthesis_closer'];
}
}
return $closing_parenthesis;
} | [
"private",
"function",
"getClosingParenthesis",
"(",
"File",
"$",
"phpcs_file",
",",
"array",
"$",
"tokens",
",",
"$",
"stack_ptr",
")",
":",
"int",
"{",
"$",
"closing_parenthesis",
"=",
"$",
"tokens",
"[",
"$",
"stack_ptr",
"]",
"[",
"'parenthesis_closer'",
... | Get the position of a function's closing parenthesis within the token stack.
@param File $phpcs_file
@param array $tokens
@param int $stack_ptr
@return int | [
"Get",
"the",
"position",
"of",
"a",
"function",
"s",
"closing",
"parenthesis",
"within",
"the",
"token",
"stack",
"."
] | 0d50d253493f7b596faeccf47898fecabfbb2c88 | https://github.com/hostnet/phpcs-tool/blob/0d50d253493f7b596faeccf47898fecabfbb2c88/src/Hostnet/Sniffs/Functions/ReturnTypeDeclarationSniff.php#L129-L144 | train |
hostnet/phpcs-tool | src/Hostnet/Sniffs/Functions/ReturnTypeDeclarationSniff.php | ReturnTypeDeclarationSniff.fixSpacing | private function fixSpacing(File $phpcs_file, $tokens, $required_spacing, $start, $end): void
{
if (($start + 1) === $end && empty($required_spacing) === false) {
//insert whitespace if there is no whitespace, and whitespace is required
$phpcs_file->fixer->addContent($start, $required_spacing);
return;
}
//otherwise, if there is whitespace, change the whitespace to the required spacing
for ($i = ($start + 1); $i < $end; $i++) {
if ($tokens[$i]['code'] !== T_WHITESPACE) {
continue;
}
if (($i + 1) === $end) {
$phpcs_file->fixer->replaceToken($i, $required_spacing);
continue;
}
$phpcs_file->fixer->replaceToken($i, '');
}
} | php | private function fixSpacing(File $phpcs_file, $tokens, $required_spacing, $start, $end): void
{
if (($start + 1) === $end && empty($required_spacing) === false) {
//insert whitespace if there is no whitespace, and whitespace is required
$phpcs_file->fixer->addContent($start, $required_spacing);
return;
}
//otherwise, if there is whitespace, change the whitespace to the required spacing
for ($i = ($start + 1); $i < $end; $i++) {
if ($tokens[$i]['code'] !== T_WHITESPACE) {
continue;
}
if (($i + 1) === $end) {
$phpcs_file->fixer->replaceToken($i, $required_spacing);
continue;
}
$phpcs_file->fixer->replaceToken($i, '');
}
} | [
"private",
"function",
"fixSpacing",
"(",
"File",
"$",
"phpcs_file",
",",
"$",
"tokens",
",",
"$",
"required_spacing",
",",
"$",
"start",
",",
"$",
"end",
")",
":",
"void",
"{",
"if",
"(",
"(",
"$",
"start",
"+",
"1",
")",
"===",
"$",
"end",
"&&",
... | Fix the spacing between start and end
@param File $phpcs_file The file being scanned.
@param array $tokens Token stack for this file
@param string $required_spacing Required spacing between start and end
@param int $start Position of the start in the token stack
@param int $end Position of the end in the token stack
@return void | [
"Fix",
"the",
"spacing",
"between",
"start",
"and",
"end"
] | 0d50d253493f7b596faeccf47898fecabfbb2c88 | https://github.com/hostnet/phpcs-tool/blob/0d50d253493f7b596faeccf47898fecabfbb2c88/src/Hostnet/Sniffs/Functions/ReturnTypeDeclarationSniff.php#L174-L196 | train |
wikiworldorder/survloop | src/Controllers/Tree/UserProfile.php | UserProfile.updateProfile | public function updateProfile()
{
if ($this->v["uID"] > 0) {
// $GLOBALS["SL"]->user() returns an instance of the authenticated user...
if ($this->v["uID"] == $GLOBALS["SL"]->REQ->uID || $this->v["user"]->hasRole('administrator')) {
$user = User::find($GLOBALS["SL"]->REQ->uID);
$user->name = $GLOBALS["SL"]->REQ->name;
$user->email = $GLOBALS["SL"]->REQ->email;
$user->save();
$user->loadRoles();
if ($this->v["user"]->hasRole('administrator')) {
if ($GLOBALS["SL"]->REQ->has('roles') && is_array($GLOBALS["SL"]->REQ->roles)
&& sizeof($GLOBALS["SL"]->REQ->roles) > 0) {
foreach ($user->roles as $i => $role) {
if (in_array($role->DefID, $GLOBALS["SL"]->REQ->roles)) {
if (!$user->hasRole($role->DefSubset)) {
$user->assignRole($role->DefSubset);
}
} elseif ($user->hasRole($role->DefSubset)) {
$user->revokeRole($role->DefSubset);
}
}
} else { // no roles selected, delete all that exist
foreach ($user->roles as $i => $role) {
if ($user->hasRole($role->DefSubset)) {
$user->revokeRole($role->DefSubset);
}
}
}
}
$this->redir('/profile/' . urlencode($user->name), true);
return true;
}
}
return false;
} | php | public function updateProfile()
{
if ($this->v["uID"] > 0) {
// $GLOBALS["SL"]->user() returns an instance of the authenticated user...
if ($this->v["uID"] == $GLOBALS["SL"]->REQ->uID || $this->v["user"]->hasRole('administrator')) {
$user = User::find($GLOBALS["SL"]->REQ->uID);
$user->name = $GLOBALS["SL"]->REQ->name;
$user->email = $GLOBALS["SL"]->REQ->email;
$user->save();
$user->loadRoles();
if ($this->v["user"]->hasRole('administrator')) {
if ($GLOBALS["SL"]->REQ->has('roles') && is_array($GLOBALS["SL"]->REQ->roles)
&& sizeof($GLOBALS["SL"]->REQ->roles) > 0) {
foreach ($user->roles as $i => $role) {
if (in_array($role->DefID, $GLOBALS["SL"]->REQ->roles)) {
if (!$user->hasRole($role->DefSubset)) {
$user->assignRole($role->DefSubset);
}
} elseif ($user->hasRole($role->DefSubset)) {
$user->revokeRole($role->DefSubset);
}
}
} else { // no roles selected, delete all that exist
foreach ($user->roles as $i => $role) {
if ($user->hasRole($role->DefSubset)) {
$user->revokeRole($role->DefSubset);
}
}
}
}
$this->redir('/profile/' . urlencode($user->name), true);
return true;
}
}
return false;
} | [
"public",
"function",
"updateProfile",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"v",
"[",
"\"uID\"",
"]",
">",
"0",
")",
"{",
"// $GLOBALS[\"SL\"]->user() returns an instance of the authenticated user...",
"if",
"(",
"$",
"this",
"->",
"v",
"[",
"\"uID\"",
... | Update the user's profile.
@param Request $request
@return Response | [
"Update",
"the",
"user",
"s",
"profile",
"."
] | 7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a | https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/Tree/UserProfile.php#L133-L168 | train |
neutrinobg/yii2-oci2pdo | OciPdoLobStreamWrapper.php | OciPdoLobStreamWrapper.getContext | public static function getContext(&$lob) {
if (!self::$_isRegistered) {
stream_wrapper_register(self::WRAPPER_NAME, get_class());
self::$_isRegistered = true;
}
return stream_context_create(array(self::WRAPPER_NAME => array('lob' => &$lob)));
} | php | public static function getContext(&$lob) {
if (!self::$_isRegistered) {
stream_wrapper_register(self::WRAPPER_NAME, get_class());
self::$_isRegistered = true;
}
return stream_context_create(array(self::WRAPPER_NAME => array('lob' => &$lob)));
} | [
"public",
"static",
"function",
"getContext",
"(",
"&",
"$",
"lob",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"_isRegistered",
")",
"{",
"stream_wrapper_register",
"(",
"self",
"::",
"WRAPPER_NAME",
",",
"get_class",
"(",
")",
")",
";",
"self",
"::",
... | Create stream context
@param OCI-Lob $lob
@return resource | [
"Create",
"stream",
"context"
] | d0170a2722c72521c510f8dddf8028185506e465 | https://github.com/neutrinobg/yii2-oci2pdo/blob/d0170a2722c72521c510f8dddf8028185506e465/OciPdoLobStreamWrapper.php#L46-L53 | train |
neutrinobg/yii2-oci2pdo | OciPdoLobStreamWrapper.php | OciPdoLobStreamWrapper.stream_open | public function stream_open($path, $mode, $options, &$opened_path) {
if (!preg_match('/^r[bt]?$/', $mode) || is_null($this->context)) {
return false;
}
$opt = stream_context_get_options($this->context);
if (!is_array($opt[self::WRAPPER_NAME]) || !isset($opt[self::WRAPPER_NAME]['lob'])) {
return false;
}
if (!is_object($opt[self::WRAPPER_NAME]['lob']) && get_class($opt[self::WRAPPER_NAME]['lob']) != 'OCI-Lob') {
return false;
}
$this->_lob = &$opt[self::WRAPPER_NAME]['lob'];
$this->_lob->rewind();
return true;
} | php | public function stream_open($path, $mode, $options, &$opened_path) {
if (!preg_match('/^r[bt]?$/', $mode) || is_null($this->context)) {
return false;
}
$opt = stream_context_get_options($this->context);
if (!is_array($opt[self::WRAPPER_NAME]) || !isset($opt[self::WRAPPER_NAME]['lob'])) {
return false;
}
if (!is_object($opt[self::WRAPPER_NAME]['lob']) && get_class($opt[self::WRAPPER_NAME]['lob']) != 'OCI-Lob') {
return false;
}
$this->_lob = &$opt[self::WRAPPER_NAME]['lob'];
$this->_lob->rewind();
return true;
} | [
"public",
"function",
"stream_open",
"(",
"$",
"path",
",",
"$",
"mode",
",",
"$",
"options",
",",
"&",
"$",
"opened_path",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^r[bt]?$/'",
",",
"$",
"mode",
")",
"||",
"is_null",
"(",
"$",
"this",
"->",
... | Prepare OCI LOB for stream
@param string $path
@param string $mode
@param int $options
@param string $opened_path
@return boolean | [
"Prepare",
"OCI",
"LOB",
"for",
"stream"
] | d0170a2722c72521c510f8dddf8028185506e465 | https://github.com/neutrinobg/yii2-oci2pdo/blob/d0170a2722c72521c510f8dddf8028185506e465/OciPdoLobStreamWrapper.php#L71-L88 | train |
wikiworldorder/survloop | src/Controllers/Tree/TreeSurvAPI.php | TreeSurvAPI.checkViewDataPerms | public function checkViewDataPerms($fld)
{
if ($fld && isset($fld->FldOpts) && intVal($fld->FldOpts) > 0) {
if ($fld->FldOpts%7 > 0 && $fld->FldOpts%11 > 0 && $fld->FldOpts%13 > 0) {
return true;
}
if (in_array($GLOBALS["SL"]->x["pageView"], ['full', 'full-pdf', 'full-xml'])) {
return true;
}
if ($fld->FldOpts%13 == 0 || $fld->FldOpts%11 == 0) {
return false;
}
return true;
}
return false;
} | php | public function checkViewDataPerms($fld)
{
if ($fld && isset($fld->FldOpts) && intVal($fld->FldOpts) > 0) {
if ($fld->FldOpts%7 > 0 && $fld->FldOpts%11 > 0 && $fld->FldOpts%13 > 0) {
return true;
}
if (in_array($GLOBALS["SL"]->x["pageView"], ['full', 'full-pdf', 'full-xml'])) {
return true;
}
if ($fld->FldOpts%13 == 0 || $fld->FldOpts%11 == 0) {
return false;
}
return true;
}
return false;
} | [
"public",
"function",
"checkViewDataPerms",
"(",
"$",
"fld",
")",
"{",
"if",
"(",
"$",
"fld",
"&&",
"isset",
"(",
"$",
"fld",
"->",
"FldOpts",
")",
"&&",
"intVal",
"(",
"$",
"fld",
"->",
"FldOpts",
")",
">",
"0",
")",
"{",
"if",
"(",
"$",
"fld",
... | FldOpts %1 XML Public Data; %7 XML Private Data; %11 XML Sensitive Data; %13 XML Internal Use Data | [
"FldOpts",
"%1",
"XML",
"Public",
"Data",
";",
"%7",
"XML",
"Private",
"Data",
";",
"%11",
"XML",
"Sensitive",
"Data",
";",
"%13",
"XML",
"Internal",
"Use",
"Data"
] | 7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a | https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/Tree/TreeSurvAPI.php#L354-L369 | train |
matteosister/GitElephantBundle | Command/CommitCommand.php | CommitCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
// Welcome
$output->writeln(
'<info>Welcome to the Cypress GitElephantBundle commit command.</info>'
);
if ($input->getOption('no-push')) {
$output->writeln(
'<comment>--no-push option enabled (this option disable push commit to remotes)</comment>'
);
}
/** @var GitElephantRepositoryCollection $rc */
$rc = $this->getContainer()->get('git_repositories');
if ($rc->count() == 0) {
throw new \Exception('Must have at least one Git repository. See https://github.com/matteosister/GitElephantBundle#how-to-use');
}
/** @var Repository $repository */
foreach ($rc as $key => $repository) {
if ($key == 0 || $key > 0 && $input->getOption('all')) {
$repository->commit($input->getArgument('message'), !$input->getOption('no-stage-all'));
if (!$input->getOption('no-push')) {
/** @var Remote $remote */
foreach ($repository->getRemotes() as $remote) {
$repository->push($remote->getName(), $repository->getMainBranch()->getName()); // Push last current branch commit to all remotes
}
}
$output->writeln('New commit to local repository created ' . $repository->getName() . (!$input->getOption('no-push') ? ' and pushed to all remotes.' : ''));
}
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
// Welcome
$output->writeln(
'<info>Welcome to the Cypress GitElephantBundle commit command.</info>'
);
if ($input->getOption('no-push')) {
$output->writeln(
'<comment>--no-push option enabled (this option disable push commit to remotes)</comment>'
);
}
/** @var GitElephantRepositoryCollection $rc */
$rc = $this->getContainer()->get('git_repositories');
if ($rc->count() == 0) {
throw new \Exception('Must have at least one Git repository. See https://github.com/matteosister/GitElephantBundle#how-to-use');
}
/** @var Repository $repository */
foreach ($rc as $key => $repository) {
if ($key == 0 || $key > 0 && $input->getOption('all')) {
$repository->commit($input->getArgument('message'), !$input->getOption('no-stage-all'));
if (!$input->getOption('no-push')) {
/** @var Remote $remote */
foreach ($repository->getRemotes() as $remote) {
$repository->push($remote->getName(), $repository->getMainBranch()->getName()); // Push last current branch commit to all remotes
}
}
$output->writeln('New commit to local repository created ' . $repository->getName() . (!$input->getOption('no-push') ? ' and pushed to all remotes.' : ''));
}
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"// Welcome",
"$",
"output",
"->",
"writeln",
"(",
"'<info>Welcome to the Cypress GitElephantBundle commit command.</info>'",
")",
";",
"if",
"(",
... | Execute commit command
@param InputInterface $input
@param OutputInterface $output
@throws \Exception
@return int|null|void | [
"Execute",
"commit",
"command"
] | 8235b9ed91a62bb6acf685f6b71cce3db73de6ef | https://github.com/matteosister/GitElephantBundle/blob/8235b9ed91a62bb6acf685f6b71cce3db73de6ef/Command/CommitCommand.php#L74-L106 | train |
crysalead/chaos-orm | src/Schema.php | Schema.lock | public function lock($locked = true)
{
$this->_locked = $locked === false ? false : true;
return $this;
} | php | public function lock($locked = true)
{
$this->_locked = $locked === false ? false : true;
return $this;
} | [
"public",
"function",
"lock",
"(",
"$",
"locked",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"_locked",
"=",
"$",
"locked",
"===",
"false",
"?",
"false",
":",
"true",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the schema lock type. When Locked all extra fields which
are not part of the schema should be filtered out before saving.
@param boolean $locked The locked value to set.
@return self Return `$this`. | [
"Sets",
"the",
"schema",
"lock",
"type",
".",
"When",
"Locked",
"all",
"extra",
"fields",
"which",
"are",
"not",
"part",
"of",
"the",
"schema",
"should",
"be",
"filtered",
"out",
"before",
"saving",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Schema.php#L229-L233 | train |
crysalead/chaos-orm | src/Schema.php | Schema.fields | public function fields($basePath = '')
{
$fields = [];
foreach ($this->names() as $name) {
$fields[$name] = null;
}
$names = Set::expand($fields);
if ($basePath) {
$parts = explode('.', $basePath);
foreach ($parts as $part) {
if (!isset($names[$part])) {
return [];
}
$names = $names[$part];
}
}
return array_keys($names);
} | php | public function fields($basePath = '')
{
$fields = [];
foreach ($this->names() as $name) {
$fields[$name] = null;
}
$names = Set::expand($fields);
if ($basePath) {
$parts = explode('.', $basePath);
foreach ($parts as $part) {
if (!isset($names[$part])) {
return [];
}
$names = $names[$part];
}
}
return array_keys($names);
} | [
"public",
"function",
"fields",
"(",
"$",
"basePath",
"=",
"''",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"names",
"(",
")",
"as",
"$",
"name",
")",
"{",
"$",
"fields",
"[",
"$",
"name",
"]",
"=",
"null",
... | Gets all fields.
@param String basePath The dotted base path to extract fields from.
@return array | [
"Gets",
"all",
"fields",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Schema.php#L302-L319 | train |
crysalead/chaos-orm | src/Schema.php | Schema.defaults | public function defaults($basePath = null)
{
$defaults = [];
foreach ($this->_columns as $key => $value) {
if ($basePath) {
$fieldName = strpos($key, $basePath . '.') === 0 ? substr($key, strlen($basePath) + 1) : null;
} else {
$fieldName = $key;
}
if (!$fieldName || $fieldName === '*' || strpos($fieldName, '.') !== false) {
continue;
}
if (isset($value['default'])) {
$defaults[$fieldName] = $value['default'];
}
}
return $defaults;
} | php | public function defaults($basePath = null)
{
$defaults = [];
foreach ($this->_columns as $key => $value) {
if ($basePath) {
$fieldName = strpos($key, $basePath . '.') === 0 ? substr($key, strlen($basePath) + 1) : null;
} else {
$fieldName = $key;
}
if (!$fieldName || $fieldName === '*' || strpos($fieldName, '.') !== false) {
continue;
}
if (isset($value['default'])) {
$defaults[$fieldName] = $value['default'];
}
}
return $defaults;
} | [
"public",
"function",
"defaults",
"(",
"$",
"basePath",
"=",
"null",
")",
"{",
"$",
"defaults",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_columns",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"basePath",
")",
"{... | Returns the schema default values.
@param array $basePath The basePath to extract default values from.
@return mixed Returns all default values . | [
"Returns",
"the",
"schema",
"default",
"values",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Schema.php#L346-L363 | train |
crysalead/chaos-orm | src/Schema.php | Schema.type | public function type($name)
{
if (!$this->has($name)) {
return;
}
$column = $this->column($name);
return isset($column['type']) ? $column['type'] : null;
} | php | public function type($name)
{
if (!$this->has($name)) {
return;
}
$column = $this->column($name);
return isset($column['type']) ? $column['type'] : null;
} | [
"public",
"function",
"type",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"return",
";",
"}",
"$",
"column",
"=",
"$",
"this",
"->",
"column",
"(",
"$",
"name",
")",
";",
"return",
"i... | Returns the type value of a field name.
@param string $name The field name.
@return array The type value or `null` if not found. | [
"Returns",
"the",
"type",
"value",
"of",
"a",
"field",
"name",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Schema.php#L371-L378 | train |
crysalead/chaos-orm | src/Schema.php | Schema.column | public function column($name, $params = [])
{
if (func_num_args() === 1) {
if (!isset($this->_columns[$name])) {
throw new ORMException("Unexisting column `'{$name}'`");
}
return $this->_columns[$name];
}
$column = $this->_initColumn($params);
if ($column['type'] !== 'object' && !$column['array']) {
$this->_columns[$name] = $column;
return $this;
}
$relationship = $this->_classes['relationship'];
$this->bind($name, [
'type' => $column['array'] ? 'set' : 'entity',
'relation' => $column['array'] ? 'hasMany' : 'hasOne',
'to' => isset($column['class']) ? $column['class'] : Document::class,
'link' => $relationship::LINK_EMBEDDED,
'config' => isset($column['config']) ? $column['config'] : []
]);
$this->_columns[$name] = $column;
return $this;
} | php | public function column($name, $params = [])
{
if (func_num_args() === 1) {
if (!isset($this->_columns[$name])) {
throw new ORMException("Unexisting column `'{$name}'`");
}
return $this->_columns[$name];
}
$column = $this->_initColumn($params);
if ($column['type'] !== 'object' && !$column['array']) {
$this->_columns[$name] = $column;
return $this;
}
$relationship = $this->_classes['relationship'];
$this->bind($name, [
'type' => $column['array'] ? 'set' : 'entity',
'relation' => $column['array'] ? 'hasMany' : 'hasOne',
'to' => isset($column['class']) ? $column['class'] : Document::class,
'link' => $relationship::LINK_EMBEDDED,
'config' => isset($column['config']) ? $column['config'] : []
]);
$this->_columns[$name] = $column;
return $this;
} | [
"public",
"function",
"column",
"(",
"$",
"name",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"===",
"1",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_columns",
"[",
"$",
"name",
"]",
")",
... | Sets a field.
@param string $name The field name.
@return object Returns `$this`. | [
"Sets",
"a",
"field",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Schema.php#L386-L412 | train |
crysalead/chaos-orm | src/Schema.php | Schema._initColumn | protected function _initColumn($column)
{
$defaults = [
'type' => 'string',
'array' => false
];
if (is_string($column)) {
$column = ['type' => $column];
} elseif (isset($column[0])) {
$column['type'] = $column[0];
unset($column[0]);
}
$column += $defaults;
return $column + ['null' => false];
} | php | protected function _initColumn($column)
{
$defaults = [
'type' => 'string',
'array' => false
];
if (is_string($column)) {
$column = ['type' => $column];
} elseif (isset($column[0])) {
$column['type'] = $column[0];
unset($column[0]);
}
$column += $defaults;
return $column + ['null' => false];
} | [
"protected",
"function",
"_initColumn",
"(",
"$",
"column",
")",
"{",
"$",
"defaults",
"=",
"[",
"'type'",
"=>",
"'string'",
",",
"'array'",
"=>",
"false",
"]",
";",
"if",
"(",
"is_string",
"(",
"$",
"column",
")",
")",
"{",
"$",
"column",
"=",
"[",
... | Normalizes a column.
@param array $column A column definition.
@return array A normalized column array. | [
"Normalizes",
"a",
"column",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Schema.php#L420-L434 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.