repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
lokhman/silex-tools | src/Silex/Console/Command/Session/SchemaCreateCommand.php | SchemaCreateCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$app = $this->getApplication()->getContainer();
if (!isset($app['session.storage.handler']) || !$app['session.storage.handler'] instanceof PdoSessionHandler) {
throw new \RuntimeException('Parameter "session.storage.handler" must be instance of PdoSessionHandler.');
}
try {
$app['session.storage.handler']->createTable();
$output->writeln('<info>Session schema was created.</info>');
} catch (\RuntimeException $ex) {
$output->writeln('<comment>Session schema was not created.</comment>');
if (!$input->getOption('no-errors')) {
throw $ex;
}
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$app = $this->getApplication()->getContainer();
if (!isset($app['session.storage.handler']) || !$app['session.storage.handler'] instanceof PdoSessionHandler) {
throw new \RuntimeException('Parameter "session.storage.handler" must be instance of PdoSessionHandler.');
}
try {
$app['session.storage.handler']->createTable();
$output->writeln('<info>Session schema was created.</info>');
} catch (\RuntimeException $ex) {
$output->writeln('<comment>Session schema was not created.</comment>');
if (!$input->getOption('no-errors')) {
throw $ex;
}
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"getApplication",
"(",
")",
"->",
"getContainer",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"app",
"[",
"'session.storage.handler'",
"]",
")",
"||",
"!",
"$",
"app",
"[",
"'session.storage.handler'",
"]",
"instanceof",
"PdoSessionHandler",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Parameter \"session.storage.handler\" must be instance of PdoSessionHandler.'",
")",
";",
"}",
"try",
"{",
"$",
"app",
"[",
"'session.storage.handler'",
"]",
"->",
"createTable",
"(",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"'<info>Session schema was created.</info>'",
")",
";",
"}",
"catch",
"(",
"\\",
"RuntimeException",
"$",
"ex",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'<comment>Session schema was not created.</comment>'",
")",
";",
"if",
"(",
"!",
"$",
"input",
"->",
"getOption",
"(",
"'no-errors'",
")",
")",
"{",
"throw",
"$",
"ex",
";",
"}",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/lokhman/silex-tools/blob/91e84099479beb4e866abc88a55ed1e457a8a9e9/src/Silex/Console/Command/Session/SchemaCreateCommand.php#L61-L78 |
willhoffmann/domuserp-php | src/Resources/Categories/Secondary/Subcategories.php | Subcategories.getList | public function getList(array $query = [])
{
$list = $this->pagination(
self::DOMUSERP_API_OPERACIONAL . '/categorias/' . $this->categoryId . '/subcategorias',
$query
);
return $list;
} | php | public function getList(array $query = [])
{
$list = $this->pagination(
self::DOMUSERP_API_OPERACIONAL . '/categorias/' . $this->categoryId . '/subcategorias',
$query
);
return $list;
} | [
"public",
"function",
"getList",
"(",
"array",
"$",
"query",
"=",
"[",
"]",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"pagination",
"(",
"self",
"::",
"DOMUSERP_API_OPERACIONAL",
".",
"'/categorias/'",
".",
"$",
"this",
"->",
"categoryId",
".",
"'/subcategorias'",
",",
"$",
"query",
")",
";",
"return",
"$",
"list",
";",
"}"
] | List of subcategories
@param array $query
@return array|string
@throws \GuzzleHttp\Exception\GuzzleException | [
"List",
"of",
"subcategories"
] | train | https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/Categories/Secondary/Subcategories.php#L35-L43 |
FrenzelGmbH/cm-address | models/AddressSearch.php | AddressSearch.search | public function search($params,$entity=NULL,$entity_id=NULL)
{
$query = Address::find()->active()->related($entity, $entity_id);
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'country_id' => $this->country_id,
]);
$query->andFilterWhere(['like', 'cityName', $this->cityName])
->andFilterWhere(['like', 'zipCode', $this->zipCode])
->andFilterWhere(['like', 'postBox', $this->postBox])
->andFilterWhere(['like', 'addresslineOne', $this->addresslineOne])
->andFilterWhere(['like', 'addresslineTwo', $this->addresslineTwo])
->andFilterWhere(['like', 'regionName', $this->regionName]);
return $dataProvider;
} | php | public function search($params,$entity=NULL,$entity_id=NULL)
{
$query = Address::find()->active()->related($entity, $entity_id);
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'country_id' => $this->country_id,
]);
$query->andFilterWhere(['like', 'cityName', $this->cityName])
->andFilterWhere(['like', 'zipCode', $this->zipCode])
->andFilterWhere(['like', 'postBox', $this->postBox])
->andFilterWhere(['like', 'addresslineOne', $this->addresslineOne])
->andFilterWhere(['like', 'addresslineTwo', $this->addresslineTwo])
->andFilterWhere(['like', 'regionName', $this->regionName]);
return $dataProvider;
} | [
"public",
"function",
"search",
"(",
"$",
"params",
",",
"$",
"entity",
"=",
"NULL",
",",
"$",
"entity_id",
"=",
"NULL",
")",
"{",
"$",
"query",
"=",
"Address",
"::",
"find",
"(",
")",
"->",
"active",
"(",
")",
"->",
"related",
"(",
"$",
"entity",
",",
"$",
"entity_id",
")",
";",
"$",
"dataProvider",
"=",
"new",
"ActiveDataProvider",
"(",
"[",
"'query'",
"=>",
"$",
"query",
",",
"]",
")",
";",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"load",
"(",
"$",
"params",
")",
"&&",
"$",
"this",
"->",
"validate",
"(",
")",
")",
")",
"{",
"return",
"$",
"dataProvider",
";",
"}",
"$",
"query",
"->",
"andFilterWhere",
"(",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'created_at'",
"=>",
"$",
"this",
"->",
"created_at",
",",
"'updated_at'",
"=>",
"$",
"this",
"->",
"updated_at",
",",
"'country_id'",
"=>",
"$",
"this",
"->",
"country_id",
",",
"]",
")",
";",
"$",
"query",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'cityName'",
",",
"$",
"this",
"->",
"cityName",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'zipCode'",
",",
"$",
"this",
"->",
"zipCode",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'postBox'",
",",
"$",
"this",
"->",
"postBox",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'addresslineOne'",
",",
"$",
"this",
"->",
"addresslineOne",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'addresslineTwo'",
",",
"$",
"this",
"->",
"addresslineTwo",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'regionName'",
",",
"$",
"this",
"->",
"regionName",
"]",
")",
";",
"return",
"$",
"dataProvider",
";",
"}"
] | [search description]
@param array $params [description]
@param string $module [description]
@param integer $id [description]
@return [type] [description] | [
"[",
"search",
"description",
"]"
] | train | https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/models/AddressSearch.php#L36-L63 |
alevilar/ristorantino-vendor | Risto/Utility/WsPaxaposConnect.php | WsPaxaposConnect.__convertLindoArray | public static function __convertLindoArray($mesa){
$mesanew = $mesa['Mesa'];
unset($mesa['Mesa']);
foreach ( $mesa as $mkey=>$mvalue) {
$mesanew[$mkey] = $mvalue;
}
return $mesanew;
} | php | public static function __convertLindoArray($mesa){
$mesanew = $mesa['Mesa'];
unset($mesa['Mesa']);
foreach ( $mesa as $mkey=>$mvalue) {
$mesanew[$mkey] = $mvalue;
}
return $mesanew;
} | [
"public",
"static",
"function",
"__convertLindoArray",
"(",
"$",
"mesa",
")",
"{",
"$",
"mesanew",
"=",
"$",
"mesa",
"[",
"'Mesa'",
"]",
";",
"unset",
"(",
"$",
"mesa",
"[",
"'Mesa'",
"]",
")",
";",
"foreach",
"(",
"$",
"mesa",
"as",
"$",
"mkey",
"=>",
"$",
"mvalue",
")",
"{",
"$",
"mesanew",
"[",
"$",
"mkey",
"]",
"=",
"$",
"mvalue",
";",
"}",
"return",
"$",
"mesanew",
";",
"}"
] | Hace un array para que sea compatible con la versin anterior del ristorantino
donde se enviaba un js con interval | [
"Hace",
"un",
"array",
"para",
"que",
"sea",
"compatible",
"con",
"la",
"versin",
"anterior",
"del",
"ristorantino",
"donde",
"se",
"enviaba",
"un",
"js",
"con",
"interval"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Risto/Utility/WsPaxaposConnect.php#L18-L28 |
php-lug/lug | src/Bundle/LocaleBundle/DataFixtures/AbstractLocaleFixture.php | AbstractLocaleFixture.doLoad | protected function doLoad(ObjectManager $manager)
{
$defaultCode = $this->getContainer()->getParameter('lug.locale');
foreach (array_keys(Intl::getLocaleBundle()->getLocaleNames()) as $code) {
$locale = $this->getFactory()->create([
'code' => $code,
'enabled' => $code === $defaultCode,
'required' => $code === $defaultCode,
]);
$manager->persist($locale);
$this->setReference('lug.locale.'.$code, $locale);
}
$manager->flush();
} | php | protected function doLoad(ObjectManager $manager)
{
$defaultCode = $this->getContainer()->getParameter('lug.locale');
foreach (array_keys(Intl::getLocaleBundle()->getLocaleNames()) as $code) {
$locale = $this->getFactory()->create([
'code' => $code,
'enabled' => $code === $defaultCode,
'required' => $code === $defaultCode,
]);
$manager->persist($locale);
$this->setReference('lug.locale.'.$code, $locale);
}
$manager->flush();
} | [
"protected",
"function",
"doLoad",
"(",
"ObjectManager",
"$",
"manager",
")",
"{",
"$",
"defaultCode",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'lug.locale'",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"Intl",
"::",
"getLocaleBundle",
"(",
")",
"->",
"getLocaleNames",
"(",
")",
")",
"as",
"$",
"code",
")",
"{",
"$",
"locale",
"=",
"$",
"this",
"->",
"getFactory",
"(",
")",
"->",
"create",
"(",
"[",
"'code'",
"=>",
"$",
"code",
",",
"'enabled'",
"=>",
"$",
"code",
"===",
"$",
"defaultCode",
",",
"'required'",
"=>",
"$",
"code",
"===",
"$",
"defaultCode",
",",
"]",
")",
";",
"$",
"manager",
"->",
"persist",
"(",
"$",
"locale",
")",
";",
"$",
"this",
"->",
"setReference",
"(",
"'lug.locale.'",
".",
"$",
"code",
",",
"$",
"locale",
")",
";",
"}",
"$",
"manager",
"->",
"flush",
"(",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/LocaleBundle/DataFixtures/AbstractLocaleFixture.php#L26-L42 |
o2system/email | src/Address.php | Address.setEmail | public function setEmail($email)
{
$email = trim($email);
if (preg_match('/\<(.*)\>/', $email, $matches)) {
$email = trim(str_replace($matches[ 0 ], '', $email));
$name = $matches[ 1 ];
}
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$this->email = $email;
if (isset($name)) {
$this->setName($name);
}
}
return $this;
} | php | public function setEmail($email)
{
$email = trim($email);
if (preg_match('/\<(.*)\>/', $email, $matches)) {
$email = trim(str_replace($matches[ 0 ], '', $email));
$name = $matches[ 1 ];
}
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$this->email = $email;
if (isset($name)) {
$this->setName($name);
}
}
return $this;
} | [
"public",
"function",
"setEmail",
"(",
"$",
"email",
")",
"{",
"$",
"email",
"=",
"trim",
"(",
"$",
"email",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/\\<(.*)\\>/'",
",",
"$",
"email",
",",
"$",
"matches",
")",
")",
"{",
"$",
"email",
"=",
"trim",
"(",
"str_replace",
"(",
"$",
"matches",
"[",
"0",
"]",
",",
"''",
",",
"$",
"email",
")",
")",
";",
"$",
"name",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"filter_var",
"(",
"$",
"email",
",",
"FILTER_VALIDATE_EMAIL",
")",
")",
"{",
"$",
"this",
"->",
"email",
"=",
"$",
"email",
";",
"if",
"(",
"isset",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Address::setEmail
@param string $email
@return static | [
"Address",
"::",
"setEmail"
] | train | https://github.com/o2system/email/blob/7c64b73f539cac8df4b2aaef474b29b949067898/src/Address.php#L109-L127 |
o2system/email | src/Address.php | Address.setName | public function setName($name)
{
$name = trim($name);
if ($name !== '') {
$this->name = $name;
}
return $this;
} | php | public function setName($name)
{
$name = trim($name);
if ($name !== '') {
$this->name = $name;
}
return $this;
} | [
"public",
"function",
"setName",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"name",
"!==",
"''",
")",
"{",
"$",
"this",
"->",
"name",
"=",
"$",
"name",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Address::setName
@param string $name
@return static | [
"Address",
"::",
"setName"
] | train | https://github.com/o2system/email/blob/7c64b73f539cac8df4b2aaef474b29b949067898/src/Address.php#L156-L165 |
skmetaly/laravel-twitch-restful-api | src/Services/TwitchApiService.php | TwitchApiService.blocks | public function blocks($login, $token = null)
{
$token = $this->getToken($token);
$blocksApi = new Blocks($token);
return $blocksApi->blocks($login);
} | php | public function blocks($login, $token = null)
{
$token = $this->getToken($token);
$blocksApi = new Blocks($token);
return $blocksApi->blocks($login);
} | [
"public",
"function",
"blocks",
"(",
"$",
"login",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"blocksApi",
"=",
"new",
"Blocks",
"(",
"$",
"token",
")",
";",
"return",
"$",
"blocksApi",
"->",
"blocks",
"(",
"$",
"login",
")",
";",
"}"
] | Returns a list of blocks objects on :login's block list. List sorted by recency, newest first.
Authenticated, required scope: user_blocks_read
@param $login
@param null $token
@return json | [
"Returns",
"a",
"list",
"of",
"blocks",
"objects",
"on",
":",
"login",
"s",
"block",
"list",
".",
"List",
"sorted",
"by",
"recency",
"newest",
"first",
".",
"Authenticated",
"required",
"scope",
":",
"user_blocks_read"
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/Services/TwitchApiService.php#L69-L76 |
skmetaly/laravel-twitch-restful-api | src/Services/TwitchApiService.php | TwitchApiService.putBlock | public function putBlock($user, $target, $token = null)
{
$token = $this->getToken($token);
$blocksApi = new Blocks($token);
return $blocksApi->putBlock($user, $target);
} | php | public function putBlock($user, $target, $token = null)
{
$token = $this->getToken($token);
$blocksApi = new Blocks($token);
return $blocksApi->putBlock($user, $target);
} | [
"public",
"function",
"putBlock",
"(",
"$",
"user",
",",
"$",
"target",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"blocksApi",
"=",
"new",
"Blocks",
"(",
"$",
"token",
")",
";",
"return",
"$",
"blocksApi",
"->",
"putBlock",
"(",
"$",
"user",
",",
"$",
"target",
")",
";",
"}"
] | Adds :target to :user's block list. :user is the authenticated user and :target is user to be blocked. Returns a blocks object.
Authenticated, required scope: user_blocks_edit
@param $user
@param $target
@param null $token
@return json | [
"Adds",
":",
"target",
"to",
":",
"user",
"s",
"block",
"list",
".",
":",
"user",
"is",
"the",
"authenticated",
"user",
"and",
":",
"target",
"is",
"user",
"to",
"be",
"blocked",
".",
"Returns",
"a",
"blocks",
"object",
".",
"Authenticated",
"required",
"scope",
":",
"user_blocks_edit"
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/Services/TwitchApiService.php#L88-L95 |
skmetaly/laravel-twitch-restful-api | src/Services/TwitchApiService.php | TwitchApiService.authenticatedUser | public function authenticatedUser($token = null)
{
$token = $this->getToken($token);
$usersAPI = new Users($token);
return $usersAPI->authenticatedUser();
} | php | public function authenticatedUser($token = null)
{
$token = $this->getToken($token);
$usersAPI = new Users($token);
return $usersAPI->authenticatedUser();
} | [
"public",
"function",
"authenticatedUser",
"(",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"usersAPI",
"=",
"new",
"Users",
"(",
"$",
"token",
")",
";",
"return",
"$",
"usersAPI",
"->",
"authenticatedUser",
"(",
")",
";",
"}"
] | @param null $token
@return json | [
"@param",
"null",
"$token"
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/Services/TwitchApiService.php#L136-L143 |
skmetaly/laravel-twitch-restful-api | src/Services/TwitchApiService.php | TwitchApiService.streamsFollowed | public function streamsFollowed($token = null)
{
$token = $this->getToken($token);
$usersAPI = new Users($token);
return $usersAPI->streamsFollowed();
} | php | public function streamsFollowed($token = null)
{
$token = $this->getToken($token);
$usersAPI = new Users($token);
return $usersAPI->streamsFollowed();
} | [
"public",
"function",
"streamsFollowed",
"(",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"usersAPI",
"=",
"new",
"Users",
"(",
"$",
"token",
")",
";",
"return",
"$",
"usersAPI",
"->",
"streamsFollowed",
"(",
")",
";",
"}"
] | @param null $token
@return mixed
@throws \Skmetaly\TwitchApi\Exceptions\RequestRequiresAuthenticationException | [
"@param",
"null",
"$token"
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/Services/TwitchApiService.php#L151-L158 |
skmetaly/laravel-twitch-restful-api | src/Services/TwitchApiService.php | TwitchApiService.videosFollowed | public function videosFollowed($token = null)
{
$token = $this->getToken($token);
$usersAPI = new Users($token);
return $usersAPI->videosFollowed();
} | php | public function videosFollowed($token = null)
{
$token = $this->getToken($token);
$usersAPI = new Users($token);
return $usersAPI->videosFollowed();
} | [
"public",
"function",
"videosFollowed",
"(",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"usersAPI",
"=",
"new",
"Users",
"(",
"$",
"token",
")",
";",
"return",
"$",
"usersAPI",
"->",
"videosFollowed",
"(",
")",
";",
"}"
] | @param null $token
@return mixed
@throws \Skmetaly\TwitchApi\Exceptions\RequestRequiresAuthenticationException | [
"@param",
"null",
"$token"
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/Services/TwitchApiService.php#L166-L173 |
skmetaly/laravel-twitch-restful-api | src/Services/TwitchApiService.php | TwitchApiService.authenticatedChannel | public function authenticatedChannel($token = null)
{
$token = $this->getToken($token);
$channelAPI = new Channels($token);
return $channelAPI->authenticatedChannel();
} | php | public function authenticatedChannel($token = null)
{
$token = $this->getToken($token);
$channelAPI = new Channels($token);
return $channelAPI->authenticatedChannel();
} | [
"public",
"function",
"authenticatedChannel",
"(",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"channelAPI",
"=",
"new",
"Channels",
"(",
"$",
"token",
")",
";",
"return",
"$",
"channelAPI",
"->",
"authenticatedChannel",
"(",
")",
";",
"}"
] | Returns a channel object of authenticated user. Channel object includes stream key.
Authenticated, required scope: channel_read
@param null $token
@return mixed
@throws \Skmetaly\TwitchApi\Exceptions\RequestRequiresAuthenticationException | [
"Returns",
"a",
"channel",
"object",
"of",
"authenticated",
"user",
".",
"Channel",
"object",
"includes",
"stream",
"key",
"."
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/Services/TwitchApiService.php#L203-L210 |
skmetaly/laravel-twitch-restful-api | src/Services/TwitchApiService.php | TwitchApiService.putChannel | public function putChannel($channel, $options, $token = null)
{
$token = $this->getToken($token);
$channelAPI = new Channels($token);
return $channelAPI->putChannel($channel, $options);
} | php | public function putChannel($channel, $options, $token = null)
{
$token = $this->getToken($token);
$channelAPI = new Channels($token);
return $channelAPI->putChannel($channel, $options);
} | [
"public",
"function",
"putChannel",
"(",
"$",
"channel",
",",
"$",
"options",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"channelAPI",
"=",
"new",
"Channels",
"(",
"$",
"token",
")",
";",
"return",
"$",
"channelAPI",
"->",
"putChannel",
"(",
"$",
"channel",
",",
"$",
"options",
")",
";",
"}"
] | Update channel's status or game.
Authenticated, required scope: channel_editor
Name Required? Type Description
status optional string Channel's title.
game optional string Game category to be classified as.
delay optional string Channel delay in seconds. Requires the channel owner's OAuth token.
@param $channel
@param $options
@param null $token
@return json
@throws ClientException | [
"Update",
"channel",
"s",
"status",
"or",
"game",
".",
"Authenticated",
"required",
"scope",
":",
"channel_editor"
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/Services/TwitchApiService.php#L228-L235 |
skmetaly/laravel-twitch-restful-api | src/Services/TwitchApiService.php | TwitchApiService.deleteStreamKey | public function deleteStreamKey($channel, $token = null)
{
$token = $this->getToken($token);
$channelAPI = new Channels($token);
return $channelAPI->deleteStreamKey($channel);
} | php | public function deleteStreamKey($channel, $token = null)
{
$token = $this->getToken($token);
$channelAPI = new Channels($token);
return $channelAPI->deleteStreamKey($channel);
} | [
"public",
"function",
"deleteStreamKey",
"(",
"$",
"channel",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"channelAPI",
"=",
"new",
"Channels",
"(",
"$",
"token",
")",
";",
"return",
"$",
"channelAPI",
"->",
"deleteStreamKey",
"(",
"$",
"channel",
")",
";",
"}"
] | Resets channel's stream key.
Authenticated, required scope: channel_stream
@param $channel
@param null $token
@return json | [
"Resets",
"channel",
"s",
"stream",
"key",
".",
"Authenticated",
"required",
"scope",
":",
"channel_stream"
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/Services/TwitchApiService.php#L246-L253 |
skmetaly/laravel-twitch-restful-api | src/Services/TwitchApiService.php | TwitchApiService.postCommercial | public function postCommercial($channel, $length = 30, $token = null)
{
$token = $this->getToken($token);
$channelAPI = new Channels($token);
return $channelAPI->postCommercial($channel, $length);
} | php | public function postCommercial($channel, $length = 30, $token = null)
{
$token = $this->getToken($token);
$channelAPI = new Channels($token);
return $channelAPI->postCommercial($channel, $length);
} | [
"public",
"function",
"postCommercial",
"(",
"$",
"channel",
",",
"$",
"length",
"=",
"30",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"channelAPI",
"=",
"new",
"Channels",
"(",
"$",
"token",
")",
";",
"return",
"$",
"channelAPI",
"->",
"postCommercial",
"(",
"$",
"channel",
",",
"$",
"length",
")",
";",
"}"
] | Start commercial on channel.
Authenticated, required scope: channel_commercial
@param $channel
@param int $length
@param null $token | [
"Start",
"commercial",
"on",
"channel",
".",
"Authenticated",
"required",
"scope",
":",
"channel_commercial"
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/Services/TwitchApiService.php#L263-L270 |
skmetaly/laravel-twitch-restful-api | src/Services/TwitchApiService.php | TwitchApiService.authenticatedUserUnfollowsChannel | public function authenticatedUserUnfollowsChannel($user, $channel, $token = null)
{
$token = $this->getToken($token);
$followAPI = new Follow($token);
return $followAPI->authenticatedUserUnfollowsChannel($user, $channel);
} | php | public function authenticatedUserUnfollowsChannel($user, $channel, $token = null)
{
$token = $this->getToken($token);
$followAPI = new Follow($token);
return $followAPI->authenticatedUserUnfollowsChannel($user, $channel);
} | [
"public",
"function",
"authenticatedUserUnfollowsChannel",
"(",
"$",
"user",
",",
"$",
"channel",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"followAPI",
"=",
"new",
"Follow",
"(",
"$",
"token",
")",
";",
"return",
"$",
"followAPI",
"->",
"authenticatedUserUnfollowsChannel",
"(",
"$",
"user",
",",
"$",
"channel",
")",
";",
"}"
] | Removes :user from :target's followers. :user is the authenticated user's name and :target is the name of the channel to be unfollowed.
Authenticated, required scope: user_follows_edit
@param $user
@param $channel
@param null $token
@return boolean | [
"Removes",
":",
"user",
"from",
":",
"target",
"s",
"followers",
".",
":",
"user",
"is",
"the",
"authenticated",
"user",
"s",
"name",
"and",
":",
"target",
"is",
"the",
"name",
"of",
"the",
"channel",
"to",
"be",
"unfollowed",
"."
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/Services/TwitchApiService.php#L389-L396 |
skmetaly/laravel-twitch-restful-api | src/Services/TwitchApiService.php | TwitchApiService.channelsSubscriptions | public function channelsSubscriptions($channel, $options = [], $token = null)
{
$token = $this->getToken($token);
$subscriptionsAPI = new Subscriptions($token);
return $subscriptionsAPI->channelsSubscriptions($channel, $options);
} | php | public function channelsSubscriptions($channel, $options = [], $token = null)
{
$token = $this->getToken($token);
$subscriptionsAPI = new Subscriptions($token);
return $subscriptionsAPI->channelsSubscriptions($channel, $options);
} | [
"public",
"function",
"channelsSubscriptions",
"(",
"$",
"channel",
",",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"subscriptionsAPI",
"=",
"new",
"Subscriptions",
"(",
"$",
"token",
")",
";",
"return",
"$",
"subscriptionsAPI",
"->",
"channelsSubscriptions",
"(",
"$",
"channel",
",",
"$",
"options",
")",
";",
"}"
] | Returns a list of subscription objects sorted by subscription relationship creation date which contain users subscribed to :channel.
Authenticated, required scope: channel_subscriptions
@param $channel
@param $options
@param null $token
@return json | [
"Returns",
"a",
"list",
"of",
"subscription",
"objects",
"sorted",
"by",
"subscription",
"relationship",
"creation",
"date",
"which",
"contain",
"users",
"subscribed",
"to",
":",
"channel",
"."
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/Services/TwitchApiService.php#L540-L547 |
skmetaly/laravel-twitch-restful-api | src/Services/TwitchApiService.php | TwitchApiService.userSubscriptionChannel | public function userSubscriptionChannel($user, $channel, $token = null)
{
$token = $this->getToken($token);
$subscriptionsAPI = new Subscriptions($token);
return $subscriptionsAPI->userSubscriptionChannel($user, $channel);
} | php | public function userSubscriptionChannel($user, $channel, $token = null)
{
$token = $this->getToken($token);
$subscriptionsAPI = new Subscriptions($token);
return $subscriptionsAPI->userSubscriptionChannel($user, $channel);
} | [
"public",
"function",
"userSubscriptionChannel",
"(",
"$",
"user",
",",
"$",
"channel",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"subscriptionsAPI",
"=",
"new",
"Subscriptions",
"(",
"$",
"token",
")",
";",
"return",
"$",
"subscriptionsAPI",
"->",
"userSubscriptionChannel",
"(",
"$",
"user",
",",
"$",
"channel",
")",
";",
"}"
] | Returns a channel object that user subscribes to. Requires authentication for :user.
Authenticated, required scope: user_subscriptions
@param $user
@param $channel
@param null $token
@return json | [
"Returns",
"a",
"channel",
"object",
"that",
"user",
"subscribes",
"to",
".",
"Requires",
"authentication",
"for",
":",
"user",
"."
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/Services/TwitchApiService.php#L580-L587 |
skmetaly/laravel-twitch-restful-api | src/Services/TwitchApiService.php | TwitchApiService.channelsVideo | public function channelsVideo($channel, $options = null)
{
$videosApi = new Videos();
return $videosApi->channelsVideo($channel, $options);
} | php | public function channelsVideo($channel, $options = null)
{
$videosApi = new Videos();
return $videosApi->channelsVideo($channel, $options);
} | [
"public",
"function",
"channelsVideo",
"(",
"$",
"channel",
",",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"videosApi",
"=",
"new",
"Videos",
"(",
")",
";",
"return",
"$",
"videosApi",
"->",
"channelsVideo",
"(",
"$",
"channel",
",",
"$",
"options",
")",
";",
"}"
] | Returns a list of videos ordered by time of creation, starting with the most recent from :channel.
@param $channel
@param $options
@return json | [
"Returns",
"a",
"list",
"of",
"videos",
"ordered",
"by",
"time",
"of",
"creation",
"starting",
"with",
"the",
"most",
"recent",
"from",
":",
"channel",
"."
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/Services/TwitchApiService.php#L644-L649 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/multiparts/multipart_related.php | ezcMailMultipartRelated.addRelatedPart | public function addRelatedPart( ezcMailPart $part )
{
// it doesn't have a Content-ID, we must set one.
$contentId = '';
if ( $part->getHeader( 'Content-ID' ) == '' )
{
if ( $part instanceof ezcMailFile )
{
$part->contentId = ezcMailTools::generateContentId( basename( $part->fileName ) );
}
else
{
$part->setHeader( 'Content-ID', ezcMailTools::generateContentId( 'part' ) );
}
}
$contentId = trim( $part->getHeader( 'Content-ID' ), '<>' );
// Set the content ID property of the ezcMailFile if one was found
if ( $part instanceof ezcMailFile )
{
$part->contentId = $contentId;
}
if ( count( $this->parts ) > 0 )
{
$this->parts[] = $part;
}
else
{
$this->parts[1] = $part;
}
return $contentId;
} | php | public function addRelatedPart( ezcMailPart $part )
{
// it doesn't have a Content-ID, we must set one.
$contentId = '';
if ( $part->getHeader( 'Content-ID' ) == '' )
{
if ( $part instanceof ezcMailFile )
{
$part->contentId = ezcMailTools::generateContentId( basename( $part->fileName ) );
}
else
{
$part->setHeader( 'Content-ID', ezcMailTools::generateContentId( 'part' ) );
}
}
$contentId = trim( $part->getHeader( 'Content-ID' ), '<>' );
// Set the content ID property of the ezcMailFile if one was found
if ( $part instanceof ezcMailFile )
{
$part->contentId = $contentId;
}
if ( count( $this->parts ) > 0 )
{
$this->parts[] = $part;
}
else
{
$this->parts[1] = $part;
}
return $contentId;
} | [
"public",
"function",
"addRelatedPart",
"(",
"ezcMailPart",
"$",
"part",
")",
"{",
"// it doesn't have a Content-ID, we must set one.",
"$",
"contentId",
"=",
"''",
";",
"if",
"(",
"$",
"part",
"->",
"getHeader",
"(",
"'Content-ID'",
")",
"==",
"''",
")",
"{",
"if",
"(",
"$",
"part",
"instanceof",
"ezcMailFile",
")",
"{",
"$",
"part",
"->",
"contentId",
"=",
"ezcMailTools",
"::",
"generateContentId",
"(",
"basename",
"(",
"$",
"part",
"->",
"fileName",
")",
")",
";",
"}",
"else",
"{",
"$",
"part",
"->",
"setHeader",
"(",
"'Content-ID'",
",",
"ezcMailTools",
"::",
"generateContentId",
"(",
"'part'",
")",
")",
";",
"}",
"}",
"$",
"contentId",
"=",
"trim",
"(",
"$",
"part",
"->",
"getHeader",
"(",
"'Content-ID'",
")",
",",
"'<>'",
")",
";",
"// Set the content ID property of the ezcMailFile if one was found",
"if",
"(",
"$",
"part",
"instanceof",
"ezcMailFile",
")",
"{",
"$",
"part",
"->",
"contentId",
"=",
"$",
"contentId",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"parts",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"parts",
"[",
"]",
"=",
"$",
"part",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"parts",
"[",
"1",
"]",
"=",
"$",
"part",
";",
"}",
"return",
"$",
"contentId",
";",
"}"
] | Adds $part to the list of parts and returns the Content-ID of the part.
@param ezcMailPart $part
@return string | [
"Adds",
"$part",
"to",
"the",
"list",
"of",
"parts",
"and",
"returns",
"the",
"Content",
"-",
"ID",
"of",
"the",
"part",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/multiparts/multipart_related.php#L72-L104 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/multiparts/multipart_related.php | ezcMailMultipartRelated.getRelatedParts | public function getRelatedParts()
{
if ( is_null( $this->getMainPart() ) )
{
return array_slice( $this->parts, 0 );
}
return array_slice( $this->parts, 1 );
} | php | public function getRelatedParts()
{
if ( is_null( $this->getMainPart() ) )
{
return array_slice( $this->parts, 0 );
}
return array_slice( $this->parts, 1 );
} | [
"public",
"function",
"getRelatedParts",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"getMainPart",
"(",
")",
")",
")",
"{",
"return",
"array_slice",
"(",
"$",
"this",
"->",
"parts",
",",
"0",
")",
";",
"}",
"return",
"array_slice",
"(",
"$",
"this",
"->",
"parts",
",",
"1",
")",
";",
"}"
] | Returns the mail parts associated with this multipart.
@return array(ezcMailPart) | [
"Returns",
"the",
"mail",
"parts",
"associated",
"with",
"this",
"multipart",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/multiparts/multipart_related.php#L125-L132 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/multiparts/multipart_related.php | ezcMailMultipartRelated.getRelatedPartByID | public function getRelatedPartByID( $cid )
{
$parts = $this->getRelatedParts();
foreach ( $parts as $part )
{
if ( ( $part->getHeader( 'Content-ID' ) !== '' ) &&
( $part->getHeader( 'Content-ID' ) == "<$cid>" ) )
{
return $part;
}
}
return false;
} | php | public function getRelatedPartByID( $cid )
{
$parts = $this->getRelatedParts();
foreach ( $parts as $part )
{
if ( ( $part->getHeader( 'Content-ID' ) !== '' ) &&
( $part->getHeader( 'Content-ID' ) == "<$cid>" ) )
{
return $part;
}
}
return false;
} | [
"public",
"function",
"getRelatedPartByID",
"(",
"$",
"cid",
")",
"{",
"$",
"parts",
"=",
"$",
"this",
"->",
"getRelatedParts",
"(",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"(",
"$",
"part",
"->",
"getHeader",
"(",
"'Content-ID'",
")",
"!==",
"''",
")",
"&&",
"(",
"$",
"part",
"->",
"getHeader",
"(",
"'Content-ID'",
")",
"==",
"\"<$cid>\"",
")",
")",
"{",
"return",
"$",
"part",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns the part associated with the passed Content-ID.
@param string $cid
@return ezcMailPart | [
"Returns",
"the",
"part",
"associated",
"with",
"the",
"passed",
"Content",
"-",
"ID",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/multiparts/multipart_related.php#L140-L152 |
alevilar/ristorantino-vendor | Risto/Controller/IvaResponsabilidadesController.php | IvaResponsabilidadesController.index | public function index() {
$this->Prg->commonProcess();
$conds = $this->IvaResponsabilidad->parseCriteria( $this->Prg->parsedParams() );
$this->Paginator->settings['conditions'] = $conds;
$this->IvaResponsabilidad->recursive = 0;
$ivaResponsabilidades = $this->Paginator->paginate('IvaResponsabilidad');
$this->set('ivaResponsabilidades',$ivaResponsabilidades);
} | php | public function index() {
$this->Prg->commonProcess();
$conds = $this->IvaResponsabilidad->parseCriteria( $this->Prg->parsedParams() );
$this->Paginator->settings['conditions'] = $conds;
$this->IvaResponsabilidad->recursive = 0;
$ivaResponsabilidades = $this->Paginator->paginate('IvaResponsabilidad');
$this->set('ivaResponsabilidades',$ivaResponsabilidades);
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"this",
"->",
"Prg",
"->",
"commonProcess",
"(",
")",
";",
"$",
"conds",
"=",
"$",
"this",
"->",
"IvaResponsabilidad",
"->",
"parseCriteria",
"(",
"$",
"this",
"->",
"Prg",
"->",
"parsedParams",
"(",
")",
")",
";",
"$",
"this",
"->",
"Paginator",
"->",
"settings",
"[",
"'conditions'",
"]",
"=",
"$",
"conds",
";",
"$",
"this",
"->",
"IvaResponsabilidad",
"->",
"recursive",
"=",
"0",
";",
"$",
"ivaResponsabilidades",
"=",
"$",
"this",
"->",
"Paginator",
"->",
"paginate",
"(",
"'IvaResponsabilidad'",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'ivaResponsabilidades'",
",",
"$",
"ivaResponsabilidades",
")",
";",
"}"
] | index method
@return void | [
"index",
"method"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Risto/Controller/IvaResponsabilidadesController.php#L30-L37 |
alevilar/ristorantino-vendor | Risto/Controller/IvaResponsabilidadesController.php | IvaResponsabilidadesController.add | public function add() {
if ($this->request->is('post')) {
$this->IvaResponsabilidad->create();
if ($this->IvaResponsabilidad->save($this->request->data)) {
$this->Session->setFlash(__('The iva responsabilidad has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The iva responsabilidad could not be saved. Please, try again.'));
}
}
$tipoFacturas = $this->IvaResponsabilidad->TipoFactura->find('list');
$this->set(compact('tipoFacturas'));
} | php | public function add() {
if ($this->request->is('post')) {
$this->IvaResponsabilidad->create();
if ($this->IvaResponsabilidad->save($this->request->data)) {
$this->Session->setFlash(__('The iva responsabilidad has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The iva responsabilidad could not be saved. Please, try again.'));
}
}
$tipoFacturas = $this->IvaResponsabilidad->TipoFactura->find('list');
$this->set(compact('tipoFacturas'));
} | [
"public",
"function",
"add",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'post'",
")",
")",
"{",
"$",
"this",
"->",
"IvaResponsabilidad",
"->",
"create",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"IvaResponsabilidad",
"->",
"save",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
")",
")",
"{",
"$",
"this",
"->",
"Session",
"->",
"setFlash",
"(",
"__",
"(",
"'The iva responsabilidad has been saved.'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"array",
"(",
"'action'",
"=>",
"'index'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"Session",
"->",
"setFlash",
"(",
"__",
"(",
"'The iva responsabilidad could not be saved. Please, try again.'",
")",
")",
";",
"}",
"}",
"$",
"tipoFacturas",
"=",
"$",
"this",
"->",
"IvaResponsabilidad",
"->",
"TipoFactura",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'tipoFacturas'",
")",
")",
";",
"}"
] | add method
@return void | [
"add",
"method"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Risto/Controller/IvaResponsabilidadesController.php#L61-L73 |
alevilar/ristorantino-vendor | Risto/Controller/IvaResponsabilidadesController.php | IvaResponsabilidadesController.edit | public function edit($id = null) {
if (!$this->IvaResponsabilidad->exists($id)) {
throw new NotFoundException(__('Invalid iva responsabilidad'));
}
if ($this->request->is(array('post', 'put'))) {
if ($this->IvaResponsabilidad->save($this->request->data)) {
$this->Session->setFlash(__('The iva responsabilidad has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The iva responsabilidad could not be saved. Please, try again.'));
}
} else {
$options = array('conditions' => array('IvaResponsabilidad.' . $this->IvaResponsabilidad->primaryKey => $id));
$this->request->data = $this->IvaResponsabilidad->find('first', $options);
}
$tipoFacturas = $this->IvaResponsabilidad->TipoFactura->find('list');
$this->set(compact('tipoFacturas'));
} | php | public function edit($id = null) {
if (!$this->IvaResponsabilidad->exists($id)) {
throw new NotFoundException(__('Invalid iva responsabilidad'));
}
if ($this->request->is(array('post', 'put'))) {
if ($this->IvaResponsabilidad->save($this->request->data)) {
$this->Session->setFlash(__('The iva responsabilidad has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The iva responsabilidad could not be saved. Please, try again.'));
}
} else {
$options = array('conditions' => array('IvaResponsabilidad.' . $this->IvaResponsabilidad->primaryKey => $id));
$this->request->data = $this->IvaResponsabilidad->find('first', $options);
}
$tipoFacturas = $this->IvaResponsabilidad->TipoFactura->find('list');
$this->set(compact('tipoFacturas'));
} | [
"public",
"function",
"edit",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"IvaResponsabilidad",
"->",
"exists",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"__",
"(",
"'Invalid iva responsabilidad'",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"array",
"(",
"'post'",
",",
"'put'",
")",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"IvaResponsabilidad",
"->",
"save",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
")",
")",
"{",
"$",
"this",
"->",
"Session",
"->",
"setFlash",
"(",
"__",
"(",
"'The iva responsabilidad has been saved.'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"array",
"(",
"'action'",
"=>",
"'index'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"Session",
"->",
"setFlash",
"(",
"__",
"(",
"'The iva responsabilidad could not be saved. Please, try again.'",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"options",
"=",
"array",
"(",
"'conditions'",
"=>",
"array",
"(",
"'IvaResponsabilidad.'",
".",
"$",
"this",
"->",
"IvaResponsabilidad",
"->",
"primaryKey",
"=>",
"$",
"id",
")",
")",
";",
"$",
"this",
"->",
"request",
"->",
"data",
"=",
"$",
"this",
"->",
"IvaResponsabilidad",
"->",
"find",
"(",
"'first'",
",",
"$",
"options",
")",
";",
"}",
"$",
"tipoFacturas",
"=",
"$",
"this",
"->",
"IvaResponsabilidad",
"->",
"TipoFactura",
"->",
"find",
"(",
"'list'",
")",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'tipoFacturas'",
")",
")",
";",
"}"
] | edit method
@throws NotFoundException
@param string $id
@return void | [
"edit",
"method"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Risto/Controller/IvaResponsabilidadesController.php#L82-L99 |
dflydev/dflydev-stack-firewall | src/Dflydev/Stack/Firewall/Matcher.php | Matcher.match | public function match(Request $request)
{
foreach ($this->firewalls as $firewall) {
if ($firewall['method'] !== null && $request->getMethod() !== $firewall['method']) {
continue;
}
if ($firewall['exact_match']) {
if ($request->getPathInfo() === $firewall['path']) {
return $firewall;
}
} elseif (0 === strpos($request->getPathInfo(), $firewall['path'])) {
return $firewall;
}
}
return null;
} | php | public function match(Request $request)
{
foreach ($this->firewalls as $firewall) {
if ($firewall['method'] !== null && $request->getMethod() !== $firewall['method']) {
continue;
}
if ($firewall['exact_match']) {
if ($request->getPathInfo() === $firewall['path']) {
return $firewall;
}
} elseif (0 === strpos($request->getPathInfo(), $firewall['path'])) {
return $firewall;
}
}
return null;
} | [
"public",
"function",
"match",
"(",
"Request",
"$",
"request",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"firewalls",
"as",
"$",
"firewall",
")",
"{",
"if",
"(",
"$",
"firewall",
"[",
"'method'",
"]",
"!==",
"null",
"&&",
"$",
"request",
"->",
"getMethod",
"(",
")",
"!==",
"$",
"firewall",
"[",
"'method'",
"]",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"firewall",
"[",
"'exact_match'",
"]",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"getPathInfo",
"(",
")",
"===",
"$",
"firewall",
"[",
"'path'",
"]",
")",
"{",
"return",
"$",
"firewall",
";",
"}",
"}",
"elseif",
"(",
"0",
"===",
"strpos",
"(",
"$",
"request",
"->",
"getPathInfo",
"(",
")",
",",
"$",
"firewall",
"[",
"'path'",
"]",
")",
")",
"{",
"return",
"$",
"firewall",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Find the matching path | [
"Find",
"the",
"matching",
"path"
] | train | https://github.com/dflydev/dflydev-stack-firewall/blob/eecaf0f2cd63104c726539bf713c72659142a81e/src/Dflydev/Stack/Firewall/Matcher.php#L45-L62 |
kossmoss/yii2-google-maps-api | GoogleMaps.php | GoogleMaps.map | public static function map($options = null)
{
if (empty(self::$_google)) {
self::$_google = new GoogleMapAPI();
self::$_google->_minify_js = false;
// Apply options
if (is_array($options)) {
foreach ($options as $key => $value) {
self::$_google->$key = $value;
}
};
}
return self::$_google;
} | php | public static function map($options = null)
{
if (empty(self::$_google)) {
self::$_google = new GoogleMapAPI();
self::$_google->_minify_js = false;
// Apply options
if (is_array($options)) {
foreach ($options as $key => $value) {
self::$_google->$key = $value;
}
};
}
return self::$_google;
} | [
"public",
"static",
"function",
"map",
"(",
"$",
"options",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"_google",
")",
")",
"{",
"self",
"::",
"$",
"_google",
"=",
"new",
"GoogleMapAPI",
"(",
")",
";",
"self",
"::",
"$",
"_google",
"->",
"_minify_js",
"=",
"false",
";",
"// Apply options\r",
"if",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"self",
"::",
"$",
"_google",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"}",
";",
"}",
"return",
"self",
"::",
"$",
"_google",
";",
"}"
] | Returns GoogleMaps instance to work with
@param mixed $options Map options array
@return GoogleMapAPI | [
"Returns",
"GoogleMaps",
"instance",
"to",
"work",
"with"
] | train | https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/GoogleMaps.php#L57-L72 |
kossmoss/yii2-google-maps-api | GoogleMaps.php | GoogleMaps.coordsByAddress | public static function coordsByAddress($searchString)
{
$result = false;
try {
// we must be sure we don't send queries too frequently to avoid be banned by Google Maps API
if (self::$_googleTimeout != 0) {
$timeToWait = self::$_lastGoogleSearchTime + self::$_googleTimeout - time();
if ($timeToWait > 0) {
sleep($timeToWait);
}
}
$searchResult = self::map()->geoGetCoordsFull($searchString);
self::$_lastGoogleSearchTime = time();
if ($searchResult && $searchResult->status == 'OK') {
$result = [
'latitude' => $searchResult->results[0]->geometry->location->lat,
'longitude' => $searchResult->results[0]->geometry->location->lng,
];
}
} catch (ErrorException $e) {
\Yii::error('Can\'t load coordinates from Google Maps API: ' . $e->getMessage());
}
return $result;
} | php | public static function coordsByAddress($searchString)
{
$result = false;
try {
// we must be sure we don't send queries too frequently to avoid be banned by Google Maps API
if (self::$_googleTimeout != 0) {
$timeToWait = self::$_lastGoogleSearchTime + self::$_googleTimeout - time();
if ($timeToWait > 0) {
sleep($timeToWait);
}
}
$searchResult = self::map()->geoGetCoordsFull($searchString);
self::$_lastGoogleSearchTime = time();
if ($searchResult && $searchResult->status == 'OK') {
$result = [
'latitude' => $searchResult->results[0]->geometry->location->lat,
'longitude' => $searchResult->results[0]->geometry->location->lng,
];
}
} catch (ErrorException $e) {
\Yii::error('Can\'t load coordinates from Google Maps API: ' . $e->getMessage());
}
return $result;
} | [
"public",
"static",
"function",
"coordsByAddress",
"(",
"$",
"searchString",
")",
"{",
"$",
"result",
"=",
"false",
";",
"try",
"{",
"// we must be sure we don't send queries too frequently to avoid be banned by Google Maps API\r",
"if",
"(",
"self",
"::",
"$",
"_googleTimeout",
"!=",
"0",
")",
"{",
"$",
"timeToWait",
"=",
"self",
"::",
"$",
"_lastGoogleSearchTime",
"+",
"self",
"::",
"$",
"_googleTimeout",
"-",
"time",
"(",
")",
";",
"if",
"(",
"$",
"timeToWait",
">",
"0",
")",
"{",
"sleep",
"(",
"$",
"timeToWait",
")",
";",
"}",
"}",
"$",
"searchResult",
"=",
"self",
"::",
"map",
"(",
")",
"->",
"geoGetCoordsFull",
"(",
"$",
"searchString",
")",
";",
"self",
"::",
"$",
"_lastGoogleSearchTime",
"=",
"time",
"(",
")",
";",
"if",
"(",
"$",
"searchResult",
"&&",
"$",
"searchResult",
"->",
"status",
"==",
"'OK'",
")",
"{",
"$",
"result",
"=",
"[",
"'latitude'",
"=>",
"$",
"searchResult",
"->",
"results",
"[",
"0",
"]",
"->",
"geometry",
"->",
"location",
"->",
"lat",
",",
"'longitude'",
"=>",
"$",
"searchResult",
"->",
"results",
"[",
"0",
"]",
"->",
"geometry",
"->",
"location",
"->",
"lng",
",",
"]",
";",
"}",
"}",
"catch",
"(",
"ErrorException",
"$",
"e",
")",
"{",
"\\",
"Yii",
"::",
"error",
"(",
"'Can\\'t load coordinates from Google Maps API: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Search coordinates by address
@param string $searchString search query with address
@return array|bool | [
"Search",
"coordinates",
"by",
"address"
] | train | https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/GoogleMaps.php#L80-L106 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.getRelationDefinition | public static function getRelationDefinition($name)
{
if (!isset(static::$relations[$name])) {
throw new \Exception(sprintf('Relation "%s" of Entity "%s" is not defined', $name, get_called_class()));
}
$relation = static::$relations[$name];
if (count($relation) !== 4) {
throw new \Exception(sprintf('Relation "%s" of Entity "%s" is invalid', $name, get_called_class()));
}
return $relation;
} | php | public static function getRelationDefinition($name)
{
if (!isset(static::$relations[$name])) {
throw new \Exception(sprintf('Relation "%s" of Entity "%s" is not defined', $name, get_called_class()));
}
$relation = static::$relations[$name];
if (count($relation) !== 4) {
throw new \Exception(sprintf('Relation "%s" of Entity "%s" is invalid', $name, get_called_class()));
}
return $relation;
} | [
"public",
"static",
"function",
"getRelationDefinition",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"relations",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Relation \"%s\" of Entity \"%s\" is not defined'",
",",
"$",
"name",
",",
"get_called_class",
"(",
")",
")",
")",
";",
"}",
"$",
"relation",
"=",
"static",
"::",
"$",
"relations",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"relation",
")",
"!==",
"4",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Relation \"%s\" of Entity \"%s\" is invalid'",
",",
"$",
"name",
",",
"get_called_class",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"relation",
";",
"}"
] | Get the relation definition for a named relation. The
definition is a list with the form
[$type, $foreign_class, $foreign_column, $column].
@param string $name The name of the relation
@return array The relation definition | [
"Get",
"the",
"relation",
"definition",
"for",
"a",
"named",
"relation",
".",
"The",
"definition",
"is",
"a",
"list",
"with",
"the",
"form",
"[",
"$type",
"$foreign_class",
"$foreign_column",
"$column",
"]",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L155-L166 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.callEvent | public function callEvent($event_name)
{
$classname = get_called_class();
if (!isset(static::$callbacks[$classname][$event_name])) {
return;
}
foreach (static::$callbacks[$classname][$event_name] as $callback) {
$callback($this);
}
} | php | public function callEvent($event_name)
{
$classname = get_called_class();
if (!isset(static::$callbacks[$classname][$event_name])) {
return;
}
foreach (static::$callbacks[$classname][$event_name] as $callback) {
$callback($this);
}
} | [
"public",
"function",
"callEvent",
"(",
"$",
"event_name",
")",
"{",
"$",
"classname",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"callbacks",
"[",
"$",
"classname",
"]",
"[",
"$",
"event_name",
"]",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"static",
"::",
"$",
"callbacks",
"[",
"$",
"classname",
"]",
"[",
"$",
"event_name",
"]",
"as",
"$",
"callback",
")",
"{",
"$",
"callback",
"(",
"$",
"this",
")",
";",
"}",
"}"
] | Call an event on this entity, calling the registering
callbacks.
@param string $event_name | [
"Call",
"an",
"event",
"on",
"this",
"entity",
"calling",
"the",
"registering",
"callbacks",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L184-L194 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.get | public function get($key)
{
$method = 'getter' . ucfirst($key);
if (method_exists($this, $method)) {
return $this->$method();
}
return $this->getRaw($key);
} | php | public function get($key)
{
$method = 'getter' . ucfirst($key);
if (method_exists($this, $method)) {
return $this->$method();
}
return $this->getRaw($key);
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"method",
"=",
"'getter'",
".",
"ucfirst",
"(",
"$",
"key",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"method",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getRaw",
"(",
"$",
"key",
")",
";",
"}"
] | Get the value of $key. If the method getter<$key> exists, the return
value will be the output of calling this function.
@param string $key The name of the key to get. | [
"Get",
"the",
"value",
"of",
"$key",
".",
"If",
"the",
"method",
"getter<$key",
">",
"exists",
"the",
"return",
"value",
"will",
"be",
"the",
"output",
"of",
"calling",
"this",
"function",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L229-L237 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.getRaw | public function getRaw($key)
{
if (isset(static::$relations[$key])) {
return $this->getRelation($key);
}
return isset($this->values[$key]) ? $this->values[$key] : null;
} | php | public function getRaw($key)
{
if (isset(static::$relations[$key])) {
return $this->getRelation($key);
}
return isset($this->values[$key]) ? $this->values[$key] : null;
} | [
"public",
"function",
"getRaw",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"relations",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getRelation",
"(",
"$",
"key",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}"
] | Get the value of $key. If $key is the name of a relation, the
relation will be fetched. If $key doesn't exist, null will be
returned.
@param string $key The name of the key to get. | [
"Get",
"the",
"value",
"of",
"$key",
".",
"If",
"$key",
"is",
"the",
"name",
"of",
"a",
"relation",
"the",
"relation",
"will",
"be",
"fetched",
".",
"If",
"$key",
"doesn",
"t",
"exist",
"null",
"will",
"be",
"returned",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L246-L253 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.getRelation | public function getRelation($name)
{
if (array_key_exists($name, $this->relation_objects)) {
return $this->relation_objects[$name];
}
$relation = self::getRelationDefinition($name);
$this->relation_objects[$name] = $this->fetchRelation($relation);
return $this->relation_objects[$name];
} | php | public function getRelation($name)
{
if (array_key_exists($name, $this->relation_objects)) {
return $this->relation_objects[$name];
}
$relation = self::getRelationDefinition($name);
$this->relation_objects[$name] = $this->fetchRelation($relation);
return $this->relation_objects[$name];
} | [
"public",
"function",
"getRelation",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"relation_objects",
")",
")",
"{",
"return",
"$",
"this",
"->",
"relation_objects",
"[",
"$",
"name",
"]",
";",
"}",
"$",
"relation",
"=",
"self",
"::",
"getRelationDefinition",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"relation_objects",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"fetchRelation",
"(",
"$",
"relation",
")",
";",
"return",
"$",
"this",
"->",
"relation_objects",
"[",
"$",
"name",
"]",
";",
"}"
] | Get the named related object. If the database has not been
queried it will be fetched automatically. If the database has
been queried the original result will be returned.
@param string $name The name of the relation | [
"Get",
"the",
"named",
"related",
"object",
".",
"If",
"the",
"database",
"has",
"not",
"been",
"queried",
"it",
"will",
"be",
"fetched",
"automatically",
".",
"If",
"the",
"database",
"has",
"been",
"queried",
"the",
"original",
"result",
"will",
"be",
"returned",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L262-L273 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.has | public function has($key)
{
$result = $this->get($key);
//an empty EntityCollection means no related entities
if ($result instanceof EntityCollection && count($result) === 0) {
return false;
}
return $result ? true : false;
} | php | public function has($key)
{
$result = $this->get($key);
//an empty EntityCollection means no related entities
if ($result instanceof EntityCollection && count($result) === 0) {
return false;
}
return $result ? true : false;
} | [
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"//an empty EntityCollection means no related entities",
"if",
"(",
"$",
"result",
"instanceof",
"EntityCollection",
"&&",
"count",
"(",
"$",
"result",
")",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"result",
"?",
"true",
":",
"false",
";",
"}"
] | Check if this Entity has a value for $key. $key may be a simple
value, a related object, or a custom getter method.
@param string $key The name of the key to check | [
"Check",
"if",
"this",
"Entity",
"has",
"a",
"value",
"for",
"$key",
".",
"$key",
"may",
"be",
"a",
"simple",
"value",
"a",
"related",
"object",
"or",
"a",
"custom",
"getter",
"method",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L281-L291 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.fetchRelation | protected function fetchRelation(array $relation)
{
/* a relation is of the form
* [$type, $foreign_class, $foreign_column, $column]
*/
list($type, $foreign_class, $foreign_column, $column) = $relation;
switch ($type) {
case 'has_one':
return $this->fetchOneToOne($foreign_class, $foreign_column, $column);
case 'belongs_to':
return $this->fetchOneToOne($foreign_class, $foreign_column, $column);
case 'has_many':
return $this->fetchOneToMany($foreign_class, $foreign_column, $column);
default:
}
} | php | protected function fetchRelation(array $relation)
{
/* a relation is of the form
* [$type, $foreign_class, $foreign_column, $column]
*/
list($type, $foreign_class, $foreign_column, $column) = $relation;
switch ($type) {
case 'has_one':
return $this->fetchOneToOne($foreign_class, $foreign_column, $column);
case 'belongs_to':
return $this->fetchOneToOne($foreign_class, $foreign_column, $column);
case 'has_many':
return $this->fetchOneToMany($foreign_class, $foreign_column, $column);
default:
}
} | [
"protected",
"function",
"fetchRelation",
"(",
"array",
"$",
"relation",
")",
"{",
"/* a relation is of the form\n * [$type, $foreign_class, $foreign_column, $column]\n */",
"list",
"(",
"$",
"type",
",",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
"=",
"$",
"relation",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'has_one'",
":",
"return",
"$",
"this",
"->",
"fetchOneToOne",
"(",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
";",
"case",
"'belongs_to'",
":",
"return",
"$",
"this",
"->",
"fetchOneToOne",
"(",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
";",
"case",
"'has_many'",
":",
"return",
"$",
"this",
"->",
"fetchOneToMany",
"(",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
";",
"default",
":",
"}",
"}"
] | Fetch a related entity from the database.
@param array $relation The relation to fetch. | [
"Fetch",
"a",
"related",
"entity",
"from",
"the",
"database",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L327-L343 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.fetchOneToOne | protected function fetchOneToOne($foreign_class, $foreign_column, $column)
{
return $foreign_class::selectOne($this->connection)
->where($foreign_column, '=', $this->getRaw($column))
->execute();
} | php | protected function fetchOneToOne($foreign_class, $foreign_column, $column)
{
return $foreign_class::selectOne($this->connection)
->where($foreign_column, '=', $this->getRaw($column))
->execute();
} | [
"protected",
"function",
"fetchOneToOne",
"(",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
"{",
"return",
"$",
"foreign_class",
"::",
"selectOne",
"(",
"$",
"this",
"->",
"connection",
")",
"->",
"where",
"(",
"$",
"foreign_column",
",",
"'='",
",",
"$",
"this",
"->",
"getRaw",
"(",
"$",
"column",
")",
")",
"->",
"execute",
"(",
")",
";",
"}"
] | Query the database for a one to one relationship.
@param string $foreign_class The class name of the related entity
@param string $foreign_column The name of the column on the other table
@param string $column The name of column on this table | [
"Query",
"the",
"database",
"for",
"a",
"one",
"to",
"one",
"relationship",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L352-L357 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.fetchOneToMany | protected function fetchOneToMany($foreign_class, $foreign_column, $column)
{
return $foreign_class::select($this->connection)
->where($foreign_column, '=', $this->getRaw($column))
->execute();
} | php | protected function fetchOneToMany($foreign_class, $foreign_column, $column)
{
return $foreign_class::select($this->connection)
->where($foreign_column, '=', $this->getRaw($column))
->execute();
} | [
"protected",
"function",
"fetchOneToMany",
"(",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
"{",
"return",
"$",
"foreign_class",
"::",
"select",
"(",
"$",
"this",
"->",
"connection",
")",
"->",
"where",
"(",
"$",
"foreign_column",
",",
"'='",
",",
"$",
"this",
"->",
"getRaw",
"(",
"$",
"column",
")",
")",
"->",
"execute",
"(",
")",
";",
"}"
] | Query the database for a one to many relationship.
@param string $foreign_class The class name of the related entity
@param string $foreign_column The name of the column on the other table
@param string $column The name of column on this table | [
"Query",
"the",
"database",
"for",
"a",
"one",
"to",
"many",
"relationship",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L366-L371 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.getValues | public function getValues()
{
$return = array();
foreach ($this->values as $k => $v) {
$return[$k] = $this->get($k);
}
return $return;
} | php | public function getValues()
{
$return = array();
foreach ($this->values as $k => $v) {
$return[$k] = $this->get($k);
}
return $return;
} | [
"public",
"function",
"getValues",
"(",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"values",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"return",
"[",
"$",
"k",
"]",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"k",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | Get all values. Getter methods will be called on the values.
@return array The values | [
"Get",
"all",
"values",
".",
"Getter",
"methods",
"will",
"be",
"called",
"on",
"the",
"values",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L378-L386 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.set | public function set($key, $value)
{
$method = 'setter' . ucfirst($key);
if (method_exists($this, $method)) {
$value = $this->$method($value);
}
$this->setRaw($key, $value);
} | php | public function set($key, $value)
{
$method = 'setter' . ucfirst($key);
if (method_exists($this, $method)) {
$value = $this->$method($value);
}
$this->setRaw($key, $value);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"method",
"=",
"'setter'",
".",
"ucfirst",
"(",
"$",
"key",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"setRaw",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Set field $key to $value. If the method setter<Key> exists, $value will
be the output of calling this function with $value as an
argument.
@param string $key The name of the key to set.
@param mixed $value The value to set. | [
"Set",
"field",
"$key",
"to",
"$value",
".",
"If",
"the",
"method",
"setter<Key",
">",
"exists",
"$value",
"will",
"be",
"the",
"output",
"of",
"calling",
"this",
"function",
"with",
"$value",
"as",
"an",
"argument",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L415-L422 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.setRaw | public function setRaw($key, $value)
{
if (isset(static::$relations[$key])) {
return $this->associateRelation($key, $value);
}
//apply the modified flag if the key is one of the fields and
//the value has changed
if (in_array($key, static::$fields) && $value !== $this->getRaw($key)) {
$this->modified[$key] = true;
}
$this->values[$key] = $value;
} | php | public function setRaw($key, $value)
{
if (isset(static::$relations[$key])) {
return $this->associateRelation($key, $value);
}
//apply the modified flag if the key is one of the fields and
//the value has changed
if (in_array($key, static::$fields) && $value !== $this->getRaw($key)) {
$this->modified[$key] = true;
}
$this->values[$key] = $value;
} | [
"public",
"function",
"setRaw",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"relations",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"associateRelation",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"//apply the modified flag if the key is one of the fields and",
"//the value has changed",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"static",
"::",
"$",
"fields",
")",
"&&",
"$",
"value",
"!==",
"$",
"this",
"->",
"getRaw",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"modified",
"[",
"$",
"key",
"]",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] | Set the value of $key. If $key is the name of a relation, the
relation will associated with this entity.
@param string $key The name of the key to set.
@param mixed $value The value to set. | [
"Set",
"the",
"value",
"of",
"$key",
".",
"If",
"$key",
"is",
"the",
"name",
"of",
"a",
"relation",
"the",
"relation",
"will",
"associated",
"with",
"this",
"entity",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L431-L443 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.setRelation | public function setRelation($name, $related_object)
{
//if no related object is supplied, set it to false (an array
//value of null will not pass an isset() check on the
//relation_objects array).
if (!$related_object) {
$related_object = false;
}
$this->relation_objects[$name] = $related_object;
} | php | public function setRelation($name, $related_object)
{
//if no related object is supplied, set it to false (an array
//value of null will not pass an isset() check on the
//relation_objects array).
if (!$related_object) {
$related_object = false;
}
$this->relation_objects[$name] = $related_object;
} | [
"public",
"function",
"setRelation",
"(",
"$",
"name",
",",
"$",
"related_object",
")",
"{",
"//if no related object is supplied, set it to false (an array",
"//value of null will not pass an isset() check on the",
"//relation_objects array).",
"if",
"(",
"!",
"$",
"related_object",
")",
"{",
"$",
"related_object",
"=",
"false",
";",
"}",
"$",
"this",
"->",
"relation_objects",
"[",
"$",
"name",
"]",
"=",
"$",
"related_object",
";",
"}"
] | Set the named related object.
@param string $name The name of the relation
@param mixed $related_object The related object | [
"Set",
"the",
"named",
"related",
"object",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L451-L461 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.associateRelation | public function associateRelation($name, $related_object)
{
if (!$related_object instanceof Entity && !$related_object instanceof EntityCollection) {
return $this->unsetRelation($name, $related_object);
}
list($type, $foreign_class, $foreign_column, $column) = static::getRelationDefinition($name);
$this->setRelation($name, $related_object);
if ($type === 'has_one') {
$related_object->setRaw($foreign_column, $this->getRaw($column));
}
if ($type === 'belongs_to') {
$this->setRaw($column, $related_object->getRaw($foreign_column));
}
if ($type === 'has_many') {
$related_object->setColumn($foreign_column, $this->getRaw($column));
}
} | php | public function associateRelation($name, $related_object)
{
if (!$related_object instanceof Entity && !$related_object instanceof EntityCollection) {
return $this->unsetRelation($name, $related_object);
}
list($type, $foreign_class, $foreign_column, $column) = static::getRelationDefinition($name);
$this->setRelation($name, $related_object);
if ($type === 'has_one') {
$related_object->setRaw($foreign_column, $this->getRaw($column));
}
if ($type === 'belongs_to') {
$this->setRaw($column, $related_object->getRaw($foreign_column));
}
if ($type === 'has_many') {
$related_object->setColumn($foreign_column, $this->getRaw($column));
}
} | [
"public",
"function",
"associateRelation",
"(",
"$",
"name",
",",
"$",
"related_object",
")",
"{",
"if",
"(",
"!",
"$",
"related_object",
"instanceof",
"Entity",
"&&",
"!",
"$",
"related_object",
"instanceof",
"EntityCollection",
")",
"{",
"return",
"$",
"this",
"->",
"unsetRelation",
"(",
"$",
"name",
",",
"$",
"related_object",
")",
";",
"}",
"list",
"(",
"$",
"type",
",",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
"=",
"static",
"::",
"getRelationDefinition",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"setRelation",
"(",
"$",
"name",
",",
"$",
"related_object",
")",
";",
"if",
"(",
"$",
"type",
"===",
"'has_one'",
")",
"{",
"$",
"related_object",
"->",
"setRaw",
"(",
"$",
"foreign_column",
",",
"$",
"this",
"->",
"getRaw",
"(",
"$",
"column",
")",
")",
";",
"}",
"if",
"(",
"$",
"type",
"===",
"'belongs_to'",
")",
"{",
"$",
"this",
"->",
"setRaw",
"(",
"$",
"column",
",",
"$",
"related_object",
"->",
"getRaw",
"(",
"$",
"foreign_column",
")",
")",
";",
"}",
"if",
"(",
"$",
"type",
"===",
"'has_many'",
")",
"{",
"$",
"related_object",
"->",
"setColumn",
"(",
"$",
"foreign_column",
",",
"$",
"this",
"->",
"getRaw",
"(",
"$",
"column",
")",
")",
";",
"}",
"}"
] | Set the named related object and ensure the joining columns are
matched. If $related_object is not an Entity or
EntityCollection, the relationship will be removed.
@param string $name The name of the relation
@param mixed $related_object The related object | [
"Set",
"the",
"named",
"related",
"object",
"and",
"ensure",
"the",
"joining",
"columns",
"are",
"matched",
".",
"If",
"$related_object",
"is",
"not",
"an",
"Entity",
"or",
"EntityCollection",
"the",
"relationship",
"will",
"be",
"removed",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L471-L490 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.unsetRelation | public function unsetRelation($name, $value)
{
list($type, $foreign_class, $foreign_column, $column) = static::getRelationDefinition($name);
//no need to get the relation, the column is on this object.
if ($type === 'belongs_to') {
$this->setRaw($column, $value);
$this->relation_objects[$name] = false;
return;
}
$related_object = $this->getRelation($name);
if (!$related_object) {
return;
}
//has one, the related object column is set to the value.
if ($type === 'has_one') {
$related_object->setRaw($foreign_column, $value);
$this->relation_objects[$name] = false;
}
//has many, the columns on the entities in the related
//collection are set to the value.
if ($type === 'has_many') {
$related_object->setColumnRaw($foreign_column, $value);
$this->relation_objects[$name] = $foreign_class::newCollection();
}
return;
} | php | public function unsetRelation($name, $value)
{
list($type, $foreign_class, $foreign_column, $column) = static::getRelationDefinition($name);
//no need to get the relation, the column is on this object.
if ($type === 'belongs_to') {
$this->setRaw($column, $value);
$this->relation_objects[$name] = false;
return;
}
$related_object = $this->getRelation($name);
if (!$related_object) {
return;
}
//has one, the related object column is set to the value.
if ($type === 'has_one') {
$related_object->setRaw($foreign_column, $value);
$this->relation_objects[$name] = false;
}
//has many, the columns on the entities in the related
//collection are set to the value.
if ($type === 'has_many') {
$related_object->setColumnRaw($foreign_column, $value);
$this->relation_objects[$name] = $foreign_class::newCollection();
}
return;
} | [
"public",
"function",
"unsetRelation",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"list",
"(",
"$",
"type",
",",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
"=",
"static",
"::",
"getRelationDefinition",
"(",
"$",
"name",
")",
";",
"//no need to get the relation, the column is on this object.",
"if",
"(",
"$",
"type",
"===",
"'belongs_to'",
")",
"{",
"$",
"this",
"->",
"setRaw",
"(",
"$",
"column",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"relation_objects",
"[",
"$",
"name",
"]",
"=",
"false",
";",
"return",
";",
"}",
"$",
"related_object",
"=",
"$",
"this",
"->",
"getRelation",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"related_object",
")",
"{",
"return",
";",
"}",
"//has one, the related object column is set to the value.",
"if",
"(",
"$",
"type",
"===",
"'has_one'",
")",
"{",
"$",
"related_object",
"->",
"setRaw",
"(",
"$",
"foreign_column",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"relation_objects",
"[",
"$",
"name",
"]",
"=",
"false",
";",
"}",
"//has many, the columns on the entities in the related",
"//collection are set to the value.",
"if",
"(",
"$",
"type",
"===",
"'has_many'",
")",
"{",
"$",
"related_object",
"->",
"setColumnRaw",
"(",
"$",
"foreign_column",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"relation_objects",
"[",
"$",
"name",
"]",
"=",
"$",
"foreign_class",
"::",
"newCollection",
"(",
")",
";",
"}",
"return",
";",
"}"
] | Unset a related object and assign the joining column a
value. If the related object has not been fetched, it will be
fetched and the joining column changed.
@param string $name The name of the relation
@param mixed $value The value to assign to the joining column | [
"Unset",
"a",
"related",
"object",
"and",
"assign",
"the",
"joining",
"column",
"a",
"value",
".",
"If",
"the",
"related",
"object",
"has",
"not",
"been",
"fetched",
"it",
"will",
"be",
"fetched",
"and",
"the",
"joining",
"column",
"changed",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L500-L532 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.setValues | public function setValues(array $values = array())
{
foreach ($values as $k => $v) {
$this->set($k, $v);
}
return $this;
} | php | public function setValues(array $values = array())
{
foreach ($values as $k => $v) {
$this->set($k, $v);
}
return $this;
} | [
"public",
"function",
"setValues",
"(",
"array",
"$",
"values",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set an array of values. Setter methods will be called if they
exist.
@param array $values The array of values to set | [
"Set",
"an",
"array",
"of",
"values",
".",
"Setter",
"methods",
"will",
"be",
"called",
"if",
"they",
"exist",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L540-L547 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.setValuesRaw | public function setValuesRaw($values = array())
{
foreach ($values as $key => $value) {
$this->setRaw($key, $value);
}
return $this;
} | php | public function setValuesRaw($values = array())
{
foreach ($values as $key => $value) {
$this->setRaw($key, $value);
}
return $this;
} | [
"public",
"function",
"setValuesRaw",
"(",
"$",
"values",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setRaw",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set an array of values. Setter methods will not be called.
@param array $values The array of values to set | [
"Set",
"an",
"array",
"of",
"values",
".",
"Setter",
"methods",
"will",
"not",
"be",
"called",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L554-L561 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.setValuesSafe | public function setValuesSafe(array $values = [])
{
$blacklist = is_array(static::$blacklist) ? static::$blacklist : [static::$primary_key];
foreach ($values as $key => $value) {
if (!in_array($key, $blacklist) && isset(self::$column_cache[get_called_class()][$key])) {
$this->set($key, $values[$key]);
}
}
} | php | public function setValuesSafe(array $values = [])
{
$blacklist = is_array(static::$blacklist) ? static::$blacklist : [static::$primary_key];
foreach ($values as $key => $value) {
if (!in_array($key, $blacklist) && isset(self::$column_cache[get_called_class()][$key])) {
$this->set($key, $values[$key]);
}
}
} | [
"public",
"function",
"setValuesSafe",
"(",
"array",
"$",
"values",
"=",
"[",
"]",
")",
"{",
"$",
"blacklist",
"=",
"is_array",
"(",
"static",
"::",
"$",
"blacklist",
")",
"?",
"static",
"::",
"$",
"blacklist",
":",
"[",
"static",
"::",
"$",
"primary_key",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"blacklist",
")",
"&&",
"isset",
"(",
"self",
"::",
"$",
"column_cache",
"[",
"get_called_class",
"(",
")",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"values",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}"
] | Set an array of values, discarding any columns / relations in
the blacklist for this entity.
The primary key is discarded if no blacklist if set. | [
"Set",
"an",
"array",
"of",
"values",
"discarding",
"any",
"columns",
"/",
"relations",
"in",
"the",
"blacklist",
"for",
"this",
"entity",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L569-L578 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.insert | public function insert()
{
if ($this->stored) {
throw new \LogicException("You may not insert an already stored entity");
}
$this->callEvent('insert');
if (empty($this->modified)) {
return;
}
$values = array_intersect_key($this->values, $this->modified);
$this->connection->insert(static::$table, $values, static::$types);
//this will only work with some database vendors for now.
$this->values[static::$primary_key] = $this->connection->lastInsertId();
$this->setStored();
} | php | public function insert()
{
if ($this->stored) {
throw new \LogicException("You may not insert an already stored entity");
}
$this->callEvent('insert');
if (empty($this->modified)) {
return;
}
$values = array_intersect_key($this->values, $this->modified);
$this->connection->insert(static::$table, $values, static::$types);
//this will only work with some database vendors for now.
$this->values[static::$primary_key] = $this->connection->lastInsertId();
$this->setStored();
} | [
"public",
"function",
"insert",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"stored",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"\"You may not insert an already stored entity\"",
")",
";",
"}",
"$",
"this",
"->",
"callEvent",
"(",
"'insert'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"modified",
")",
")",
"{",
"return",
";",
"}",
"$",
"values",
"=",
"array_intersect_key",
"(",
"$",
"this",
"->",
"values",
",",
"$",
"this",
"->",
"modified",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"insert",
"(",
"static",
"::",
"$",
"table",
",",
"$",
"values",
",",
"static",
"::",
"$",
"types",
")",
";",
"//this will only work with some database vendors for now.",
"$",
"this",
"->",
"values",
"[",
"static",
"::",
"$",
"primary_key",
"]",
"=",
"$",
"this",
"->",
"connection",
"->",
"lastInsertId",
"(",
")",
";",
"$",
"this",
"->",
"setStored",
"(",
")",
";",
"}"
] | Persist this entity to the database using an insert query. | [
"Persist",
"this",
"entity",
"to",
"the",
"database",
"using",
"an",
"insert",
"query",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L603-L620 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.getPrimaryKey | protected function getPrimaryKey()
{
if (!isset($this->values[static::$primary_key])) {
throw new \LogicException('Primary key not set');
}
return $this->current_index ?: $this->values[static::$primary_key];
} | php | protected function getPrimaryKey()
{
if (!isset($this->values[static::$primary_key])) {
throw new \LogicException('Primary key not set');
}
return $this->current_index ?: $this->values[static::$primary_key];
} | [
"protected",
"function",
"getPrimaryKey",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"static",
"::",
"$",
"primary_key",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Primary key not set'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"current_index",
"?",
":",
"$",
"this",
"->",
"values",
"[",
"static",
"::",
"$",
"primary_key",
"]",
";",
"}"
] | Get the primary key for this entity as it is stored in the
database. If the key has been updated but not saved, the
original value will be returned.
@return string The primary key of the entity | [
"Get",
"the",
"primary",
"key",
"for",
"this",
"entity",
"as",
"it",
"is",
"stored",
"in",
"the",
"database",
".",
"If",
"the",
"key",
"has",
"been",
"updated",
"but",
"not",
"saved",
"the",
"original",
"value",
"will",
"be",
"returned",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L629-L636 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.update | public function update()
{
$this->callEvent('update');
if (empty($this->modified)) {
return;
}
$values = array_intersect_key($this->values, $this->modified);
$where = [static::$primary_key => $this->getPrimaryKey()];
$this->connection->update(static::$table, $values, $where, static::$types);
$this->setStored();
} | php | public function update()
{
$this->callEvent('update');
if (empty($this->modified)) {
return;
}
$values = array_intersect_key($this->values, $this->modified);
$where = [static::$primary_key => $this->getPrimaryKey()];
$this->connection->update(static::$table, $values, $where, static::$types);
$this->setStored();
} | [
"public",
"function",
"update",
"(",
")",
"{",
"$",
"this",
"->",
"callEvent",
"(",
"'update'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"modified",
")",
")",
"{",
"return",
";",
"}",
"$",
"values",
"=",
"array_intersect_key",
"(",
"$",
"this",
"->",
"values",
",",
"$",
"this",
"->",
"modified",
")",
";",
"$",
"where",
"=",
"[",
"static",
"::",
"$",
"primary_key",
"=>",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
";",
"$",
"this",
"->",
"connection",
"->",
"update",
"(",
"static",
"::",
"$",
"table",
",",
"$",
"values",
",",
"$",
"where",
",",
"static",
"::",
"$",
"types",
")",
";",
"$",
"this",
"->",
"setStored",
"(",
")",
";",
"}"
] | Update this entity in the database. | [
"Update",
"this",
"entity",
"in",
"the",
"database",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L649-L660 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.setStored | public function setStored($stored = true)
{
$this->stored = (bool) $stored;
$this->modified = $stored ? [] : $this->values;
return $this;
} | php | public function setStored($stored = true)
{
$this->stored = (bool) $stored;
$this->modified = $stored ? [] : $this->values;
return $this;
} | [
"public",
"function",
"setStored",
"(",
"$",
"stored",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"stored",
"=",
"(",
"bool",
")",
"$",
"stored",
";",
"$",
"this",
"->",
"modified",
"=",
"$",
"stored",
"?",
"[",
"]",
":",
"$",
"this",
"->",
"values",
";",
"return",
"$",
"this",
";",
"}"
] | Set whether this entity is stored in the database or not.
@param bool $stored True if stored, false if not | [
"Set",
"whether",
"this",
"entity",
"is",
"stored",
"in",
"the",
"database",
"or",
"not",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L667-L673 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.delete | public function delete()
{
$where = [static::$primary_key => $this->getPrimaryKey()];
$this->connection->delete(static::$table, $where);
$this->setStored(false);
return $this;
} | php | public function delete()
{
$where = [static::$primary_key => $this->getPrimaryKey()];
$this->connection->delete(static::$table, $where);
$this->setStored(false);
return $this;
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"$",
"where",
"=",
"[",
"static",
"::",
"$",
"primary_key",
"=>",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
";",
"$",
"this",
"->",
"connection",
"->",
"delete",
"(",
"static",
"::",
"$",
"table",
",",
"$",
"where",
")",
";",
"$",
"this",
"->",
"setStored",
"(",
"false",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Delete this entity from the database.
@return Entity This entity | [
"Delete",
"this",
"entity",
"from",
"the",
"database",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L699-L707 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.create | public static function create(Connection $connection, $amount = 0)
{
$entities = [];
for ($i = 0; $i < (int) $amount; $i++) {
$entities[] = new static($connection);
}
return static::newCollection($entities);
} | php | public static function create(Connection $connection, $amount = 0)
{
$entities = [];
for ($i = 0; $i < (int) $amount; $i++) {
$entities[] = new static($connection);
}
return static::newCollection($entities);
} | [
"public",
"static",
"function",
"create",
"(",
"Connection",
"$",
"connection",
",",
"$",
"amount",
"=",
"0",
")",
"{",
"$",
"entities",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"(",
"int",
")",
"$",
"amount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"entities",
"[",
"]",
"=",
"new",
"static",
"(",
"$",
"connection",
")",
";",
"}",
"return",
"static",
"::",
"newCollection",
"(",
"$",
"entities",
")",
";",
"}"
] | Create a new collection with an amount of empty entities.
@param Connection $connection A connection instance
@param int $amount The amount of new Entities to create | [
"Create",
"a",
"new",
"collection",
"with",
"an",
"amount",
"of",
"empty",
"entities",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L737-L745 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.selectSQL | public static function selectSQL(Connection $connection, $sql, array $parameters = [], array $field_mapping = [])
{
$stmt = $connection->prepare($sql);
$stmt->execute($parameters);
$results = array();
while ($result = $stmt->fetch()) {
foreach ($field_mapping as $result_column => $entity_field) {
if (!isset($result[$result_column])) {
continue;
}
$result[$entity_field] = $result[$result_column];
unset($result[$result_column]);
}
foreach (static::$types as $column => $type) {
if (isset($result[$column])) {
$result[$column] = $connection->convertToPHPValue($result[$column], $type);
}
}
$obj = new static($connection, $result);
$obj->setStored();
$results[] = $obj;
}
$collection = static::newCollection();
$collection->setEntities($results);
return $collection;
} | php | public static function selectSQL(Connection $connection, $sql, array $parameters = [], array $field_mapping = [])
{
$stmt = $connection->prepare($sql);
$stmt->execute($parameters);
$results = array();
while ($result = $stmt->fetch()) {
foreach ($field_mapping as $result_column => $entity_field) {
if (!isset($result[$result_column])) {
continue;
}
$result[$entity_field] = $result[$result_column];
unset($result[$result_column]);
}
foreach (static::$types as $column => $type) {
if (isset($result[$column])) {
$result[$column] = $connection->convertToPHPValue($result[$column], $type);
}
}
$obj = new static($connection, $result);
$obj->setStored();
$results[] = $obj;
}
$collection = static::newCollection();
$collection->setEntities($results);
return $collection;
} | [
"public",
"static",
"function",
"selectSQL",
"(",
"Connection",
"$",
"connection",
",",
"$",
"sql",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"field_mapping",
"=",
"[",
"]",
")",
"{",
"$",
"stmt",
"=",
"$",
"connection",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
"$",
"parameters",
")",
";",
"$",
"results",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"result",
"=",
"$",
"stmt",
"->",
"fetch",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"field_mapping",
"as",
"$",
"result_column",
"=>",
"$",
"entity_field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"$",
"result_column",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"result",
"[",
"$",
"entity_field",
"]",
"=",
"$",
"result",
"[",
"$",
"result_column",
"]",
";",
"unset",
"(",
"$",
"result",
"[",
"$",
"result_column",
"]",
")",
";",
"}",
"foreach",
"(",
"static",
"::",
"$",
"types",
"as",
"$",
"column",
"=>",
"$",
"type",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"$",
"column",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"column",
"]",
"=",
"$",
"connection",
"->",
"convertToPHPValue",
"(",
"$",
"result",
"[",
"$",
"column",
"]",
",",
"$",
"type",
")",
";",
"}",
"}",
"$",
"obj",
"=",
"new",
"static",
"(",
"$",
"connection",
",",
"$",
"result",
")",
";",
"$",
"obj",
"->",
"setStored",
"(",
")",
";",
"$",
"results",
"[",
"]",
"=",
"$",
"obj",
";",
"}",
"$",
"collection",
"=",
"static",
"::",
"newCollection",
"(",
")",
";",
"$",
"collection",
"->",
"setEntities",
"(",
"$",
"results",
")",
";",
"return",
"$",
"collection",
";",
"}"
] | Select all entities matching an SQL query, and return the
results as a collection.
@param Connection $connection A connection instance
@param string $sql The SQL query
@param array $parameters Any bound parameters required for the query
@param array $field_mapping An array of result columns => entity fields
@return EntityCollection A collection containing the selected entities | [
"Select",
"all",
"entities",
"matching",
"an",
"SQL",
"query",
"and",
"return",
"the",
"results",
"as",
"a",
"collection",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L758-L786 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.selectOneSQL | public static function selectOneSQL(Connection $connection, $sql, array $parameters = [], array $field_mapping = [])
{
$stmt = $connection->prepare($sql);
$stmt->execute($parameters);
$result = $stmt->fetch();
if ($result) {
foreach ($field_mapping as $result_column => $entity_field) {
if (!isset($result[$result_column])) {
continue;
}
$result[$entity_field] = $result[$result_column];
unset($result[$result_column]);
}
foreach (static::$types as $column => $type) {
if (isset($result[$column])) {
$result[$column] = $connection->convertToPHPValue($result[$column], $type);
}
}
$entity = new static($connection, $result);
return $entity->setStored();
}
return null;
} | php | public static function selectOneSQL(Connection $connection, $sql, array $parameters = [], array $field_mapping = [])
{
$stmt = $connection->prepare($sql);
$stmt->execute($parameters);
$result = $stmt->fetch();
if ($result) {
foreach ($field_mapping as $result_column => $entity_field) {
if (!isset($result[$result_column])) {
continue;
}
$result[$entity_field] = $result[$result_column];
unset($result[$result_column]);
}
foreach (static::$types as $column => $type) {
if (isset($result[$column])) {
$result[$column] = $connection->convertToPHPValue($result[$column], $type);
}
}
$entity = new static($connection, $result);
return $entity->setStored();
}
return null;
} | [
"public",
"static",
"function",
"selectOneSQL",
"(",
"Connection",
"$",
"connection",
",",
"$",
"sql",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"field_mapping",
"=",
"[",
"]",
")",
"{",
"$",
"stmt",
"=",
"$",
"connection",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
"$",
"parameters",
")",
";",
"$",
"result",
"=",
"$",
"stmt",
"->",
"fetch",
"(",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"foreach",
"(",
"$",
"field_mapping",
"as",
"$",
"result_column",
"=>",
"$",
"entity_field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"$",
"result_column",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"result",
"[",
"$",
"entity_field",
"]",
"=",
"$",
"result",
"[",
"$",
"result_column",
"]",
";",
"unset",
"(",
"$",
"result",
"[",
"$",
"result_column",
"]",
")",
";",
"}",
"foreach",
"(",
"static",
"::",
"$",
"types",
"as",
"$",
"column",
"=>",
"$",
"type",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"$",
"column",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"column",
"]",
"=",
"$",
"connection",
"->",
"convertToPHPValue",
"(",
"$",
"result",
"[",
"$",
"column",
"]",
",",
"$",
"type",
")",
";",
"}",
"}",
"$",
"entity",
"=",
"new",
"static",
"(",
"$",
"connection",
",",
"$",
"result",
")",
";",
"return",
"$",
"entity",
"->",
"setStored",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Select a single entity matching an SQL query. If more than one
row is matched by the query, only the first entity will be
returned.
@param Connection $connection A connection instance
@param string $sql The SQL query
@param array $parameters Any bound parameters required for the query
@param array $field_mapping An array of result columns => entity fields
@return Entity|null The selected Entity, or null if no entity was found | [
"Select",
"a",
"single",
"entity",
"matching",
"an",
"SQL",
"query",
".",
"If",
"more",
"than",
"one",
"row",
"is",
"matched",
"by",
"the",
"query",
"only",
"the",
"first",
"entity",
"will",
"be",
"returned",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L800-L825 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.select | public static function select(Connection $connection)
{
return new EntitySelector(AbstractSelector::fromConnection($connection, static::$table, static::$types), get_called_class());
} | php | public static function select(Connection $connection)
{
return new EntitySelector(AbstractSelector::fromConnection($connection, static::$table, static::$types), get_called_class());
} | [
"public",
"static",
"function",
"select",
"(",
"Connection",
"$",
"connection",
")",
"{",
"return",
"new",
"EntitySelector",
"(",
"AbstractSelector",
"::",
"fromConnection",
"(",
"$",
"connection",
",",
"static",
"::",
"$",
"table",
",",
"static",
"::",
"$",
"types",
")",
",",
"get_called_class",
"(",
")",
")",
";",
"}"
] | Select entities using an EntitySelector instance.
@param Connection $connection A connection instance
@return EntitySelector A selector instance | [
"Select",
"entities",
"using",
"an",
"EntitySelector",
"instance",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L833-L836 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.selectOne | public static function selectOne(Connection $connection)
{
$selector = new EntitySelector(AbstractSelector::fromConnection($connection, static::$table, static::$types), get_called_class());
return $selector->one();
} | php | public static function selectOne(Connection $connection)
{
$selector = new EntitySelector(AbstractSelector::fromConnection($connection, static::$table, static::$types), get_called_class());
return $selector->one();
} | [
"public",
"static",
"function",
"selectOne",
"(",
"Connection",
"$",
"connection",
")",
"{",
"$",
"selector",
"=",
"new",
"EntitySelector",
"(",
"AbstractSelector",
"::",
"fromConnection",
"(",
"$",
"connection",
",",
"static",
"::",
"$",
"table",
",",
"static",
"::",
"$",
"types",
")",
",",
"get_called_class",
"(",
")",
")",
";",
"return",
"$",
"selector",
"->",
"one",
"(",
")",
";",
"}"
] | Select a single entity using an EntitySelector instance.
@param Connection $connection A connection instance
@return EntitySelector A selector instance | [
"Select",
"a",
"single",
"entity",
"using",
"an",
"EntitySelector",
"instance",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L844-L849 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Entity/Entity.php | Entity.selectPrimaryKey | public static function selectPrimaryKey(Connection $connection, $primary_key)
{
return static::selectOne($connection)
->where(static::$primary_key, $primary_key)
->execute();
} | php | public static function selectPrimaryKey(Connection $connection, $primary_key)
{
return static::selectOne($connection)
->where(static::$primary_key, $primary_key)
->execute();
} | [
"public",
"static",
"function",
"selectPrimaryKey",
"(",
"Connection",
"$",
"connection",
",",
"$",
"primary_key",
")",
"{",
"return",
"static",
"::",
"selectOne",
"(",
"$",
"connection",
")",
"->",
"where",
"(",
"static",
"::",
"$",
"primary_key",
",",
"$",
"primary_key",
")",
"->",
"execute",
"(",
")",
";",
"}"
] | Select a single entity matching a primary key.
@param Connection $connection A connection instance
@param mixed $primary_key The primary key
@return Entity|null The entity, or null if not found | [
"Select",
"a",
"single",
"entity",
"matching",
"a",
"primary",
"key",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L858-L863 |
alevilar/ristorantino-vendor | Mesa/Controller/MozosController.php | MozosController.mesas_abiertas | public function mesas_abiertas( $microtime = 0 ) {
$lastAccess = null;
$type = 'created';
if ( $microtime != 0 ) {
$type = 'modified';
$lastAccess = $this->Session->read('lastAccess');
// setear el nuevo lastAccess
$nowTime = date('Y-m-d H:i:s', strtotime('now'));
$this->Session->write('lastAccess', $nowTime );
// ver las borradas o con checkout
$borradas = $this->Mozo->mesasBorradas( null, $lastAccess);
if ( !empty($borradas) ) {
$mesas['borradas'] = $borradas;
}
}
$mesas[$type] = $this->Mozo->mesasAbiertas( null, $lastAccess);
$this->set('mesasLastUpdatedTime', 1 );
$this->set('modified', $lastAccess );
$this->set('mesas', $mesas );
} | php | public function mesas_abiertas( $microtime = 0 ) {
$lastAccess = null;
$type = 'created';
if ( $microtime != 0 ) {
$type = 'modified';
$lastAccess = $this->Session->read('lastAccess');
// setear el nuevo lastAccess
$nowTime = date('Y-m-d H:i:s', strtotime('now'));
$this->Session->write('lastAccess', $nowTime );
// ver las borradas o con checkout
$borradas = $this->Mozo->mesasBorradas( null, $lastAccess);
if ( !empty($borradas) ) {
$mesas['borradas'] = $borradas;
}
}
$mesas[$type] = $this->Mozo->mesasAbiertas( null, $lastAccess);
$this->set('mesasLastUpdatedTime', 1 );
$this->set('modified', $lastAccess );
$this->set('mesas', $mesas );
} | [
"public",
"function",
"mesas_abiertas",
"(",
"$",
"microtime",
"=",
"0",
")",
"{",
"$",
"lastAccess",
"=",
"null",
";",
"$",
"type",
"=",
"'created'",
";",
"if",
"(",
"$",
"microtime",
"!=",
"0",
")",
"{",
"$",
"type",
"=",
"'modified'",
";",
"$",
"lastAccess",
"=",
"$",
"this",
"->",
"Session",
"->",
"read",
"(",
"'lastAccess'",
")",
";",
"// setear el nuevo lastAccess",
"$",
"nowTime",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"strtotime",
"(",
"'now'",
")",
")",
";",
"$",
"this",
"->",
"Session",
"->",
"write",
"(",
"'lastAccess'",
",",
"$",
"nowTime",
")",
";",
"// ver las borradas o con checkout",
"$",
"borradas",
"=",
"$",
"this",
"->",
"Mozo",
"->",
"mesasBorradas",
"(",
"null",
",",
"$",
"lastAccess",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"borradas",
")",
")",
"{",
"$",
"mesas",
"[",
"'borradas'",
"]",
"=",
"$",
"borradas",
";",
"}",
"}",
"$",
"mesas",
"[",
"$",
"type",
"]",
"=",
"$",
"this",
"->",
"Mozo",
"->",
"mesasAbiertas",
"(",
"null",
",",
"$",
"lastAccess",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'mesasLastUpdatedTime'",
",",
"1",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'modified'",
",",
"$",
"lastAccess",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'mesas'",
",",
"$",
"mesas",
")",
";",
"}"
] | Me devuelve las mesas abiertas de cada mozo
@param boolean $microtime microtime desde donde yo quiero tomar omo referencia a la hora de traer las mesas | [
"Me",
"devuelve",
"las",
"mesas",
"abiertas",
"de",
"cada",
"mozo"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Controller/MozosController.php#L108-L137 |
alevilar/ristorantino-vendor | Compras/Controller/UnidadDeMedidasController.php | UnidadDeMedidasController.delete | public function delete($id = null) {
$this->UnidadDeMedida->id = $id;
if (!$this->UnidadDeMedida->exists()) {
throw new NotFoundException(__('Unidad De Medida Inválido'));
}
$this->request->allowMethod('post', 'delete');
if ($this->UnidadDeMedida->delete()) {
$this->Flash->success(__('Se ha borrado la Unidad de Medida.'));
} else {
$this->Flash->error(__('No se ha podido eliminar la Unidad de Medida'), 'Risto.flash_error');
}
return $this->redirect($this->referer());
} | php | public function delete($id = null) {
$this->UnidadDeMedida->id = $id;
if (!$this->UnidadDeMedida->exists()) {
throw new NotFoundException(__('Unidad De Medida Inválido'));
}
$this->request->allowMethod('post', 'delete');
if ($this->UnidadDeMedida->delete()) {
$this->Flash->success(__('Se ha borrado la Unidad de Medida.'));
} else {
$this->Flash->error(__('No se ha podido eliminar la Unidad de Medida'), 'Risto.flash_error');
}
return $this->redirect($this->referer());
} | [
"public",
"function",
"delete",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"UnidadDeMedida",
"->",
"id",
"=",
"$",
"id",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"UnidadDeMedida",
"->",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"__",
"(",
"'Unidad De Medida Inválido')",
")",
";",
"",
"}",
"$",
"this",
"->",
"request",
"->",
"allowMethod",
"(",
"'post'",
",",
"'delete'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"UnidadDeMedida",
"->",
"delete",
"(",
")",
")",
"{",
"$",
"this",
"->",
"Flash",
"->",
"success",
"(",
"__",
"(",
"'Se ha borrado la Unidad de Medida.'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"Flash",
"->",
"error",
"(",
"__",
"(",
"'No se ha podido eliminar la Unidad de Medida'",
")",
",",
"'Risto.flash_error'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"referer",
"(",
")",
")",
";",
"}"
] | delete method
@throws NotFoundException
@param string $id
@return void | [
"delete",
"method"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Compras/Controller/UnidadDeMedidasController.php#L53-L65 |
InactiveProjects/limoncello-illuminate | app/Api/Authorizations/Authorizations.php | Authorizations.canSetBelongToManyOnCreate | public function canSetBelongToManyOnCreate(
ErrorCollection $errors,
Model $model,
Schema $schema,
$resRelationshipName,
$modRelationshipName,
$idx = null
) {
$relModelClass = $this->getBelongToManyRelationshipModelClass($schema, $resRelationshipName);
$arguments = [$model, $modRelationshipName, $idx, $relModelClass];
$allowed = $this->getGate()->allows(BasePolicy::CAN_SET_RELATIONSHIP_ON_CREATE, $arguments);
if ($allowed === false) {
$errors->addRelationshipError($resRelationshipName, T::trans(T::KEY_ERR_UNAUTHORIZED));
}
return $allowed;
} | php | public function canSetBelongToManyOnCreate(
ErrorCollection $errors,
Model $model,
Schema $schema,
$resRelationshipName,
$modRelationshipName,
$idx = null
) {
$relModelClass = $this->getBelongToManyRelationshipModelClass($schema, $resRelationshipName);
$arguments = [$model, $modRelationshipName, $idx, $relModelClass];
$allowed = $this->getGate()->allows(BasePolicy::CAN_SET_RELATIONSHIP_ON_CREATE, $arguments);
if ($allowed === false) {
$errors->addRelationshipError($resRelationshipName, T::trans(T::KEY_ERR_UNAUTHORIZED));
}
return $allowed;
} | [
"public",
"function",
"canSetBelongToManyOnCreate",
"(",
"ErrorCollection",
"$",
"errors",
",",
"Model",
"$",
"model",
",",
"Schema",
"$",
"schema",
",",
"$",
"resRelationshipName",
",",
"$",
"modRelationshipName",
",",
"$",
"idx",
"=",
"null",
")",
"{",
"$",
"relModelClass",
"=",
"$",
"this",
"->",
"getBelongToManyRelationshipModelClass",
"(",
"$",
"schema",
",",
"$",
"resRelationshipName",
")",
";",
"$",
"arguments",
"=",
"[",
"$",
"model",
",",
"$",
"modRelationshipName",
",",
"$",
"idx",
",",
"$",
"relModelClass",
"]",
";",
"$",
"allowed",
"=",
"$",
"this",
"->",
"getGate",
"(",
")",
"->",
"allows",
"(",
"BasePolicy",
"::",
"CAN_SET_RELATIONSHIP_ON_CREATE",
",",
"$",
"arguments",
")",
";",
"if",
"(",
"$",
"allowed",
"===",
"false",
")",
"{",
"$",
"errors",
"->",
"addRelationshipError",
"(",
"$",
"resRelationshipName",
",",
"T",
"::",
"trans",
"(",
"T",
"::",
"KEY_ERR_UNAUTHORIZED",
")",
")",
";",
"}",
"return",
"$",
"allowed",
";",
"}"
] | @noinspection PhpTooManyParametersInspection
@inheritdoc
@SuppressWarnings(PHPMD.StaticAccess) | [
"@noinspection",
"PhpTooManyParametersInspection",
"@inheritdoc"
] | train | https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Api/Authorizations/Authorizations.php#L156-L172 |
InactiveProjects/limoncello-illuminate | app/Api/Authorizations/Authorizations.php | Authorizations.checkAllow | protected function checkAllow($ability, $arguments, ErrorCollection $errors)
{
$isAllowed = $this->getGate()->allows($ability, $arguments);
if ($isAllowed === false) {
$title = T::trans(T::KEY_ERR_UNAUTHORIZED);
$errors->add(new Error(null, null, null, null, $title));
}
return $isAllowed;
} | php | protected function checkAllow($ability, $arguments, ErrorCollection $errors)
{
$isAllowed = $this->getGate()->allows($ability, $arguments);
if ($isAllowed === false) {
$title = T::trans(T::KEY_ERR_UNAUTHORIZED);
$errors->add(new Error(null, null, null, null, $title));
}
return $isAllowed;
} | [
"protected",
"function",
"checkAllow",
"(",
"$",
"ability",
",",
"$",
"arguments",
",",
"ErrorCollection",
"$",
"errors",
")",
"{",
"$",
"isAllowed",
"=",
"$",
"this",
"->",
"getGate",
"(",
")",
"->",
"allows",
"(",
"$",
"ability",
",",
"$",
"arguments",
")",
";",
"if",
"(",
"$",
"isAllowed",
"===",
"false",
")",
"{",
"$",
"title",
"=",
"T",
"::",
"trans",
"(",
"T",
"::",
"KEY_ERR_UNAUTHORIZED",
")",
";",
"$",
"errors",
"->",
"add",
"(",
"new",
"Error",
"(",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"$",
"title",
")",
")",
";",
"}",
"return",
"$",
"isAllowed",
";",
"}"
] | @param string $ability
@param mixed $arguments
@param ErrorCollection $errors
@return bool
@SuppressWarnings(PHPMD.StaticAccess) | [
"@param",
"string",
"$ability",
"@param",
"mixed",
"$arguments",
"@param",
"ErrorCollection",
"$errors"
] | train | https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Api/Authorizations/Authorizations.php#L362-L371 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Helper/Data.php | Aoe_Layout_Helper_Data.getObjectData | public function getObjectData(Varien_Object $object, $key = null)
{
if ($key) {
return $object->getDataUsingMethod($key);
} else {
return $object->getData();
}
} | php | public function getObjectData(Varien_Object $object, $key = null)
{
if ($key) {
return $object->getDataUsingMethod($key);
} else {
return $object->getData();
}
} | [
"public",
"function",
"getObjectData",
"(",
"Varien_Object",
"$",
"object",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
")",
"{",
"return",
"$",
"object",
"->",
"getDataUsingMethod",
"(",
"$",
"key",
")",
";",
"}",
"else",
"{",
"return",
"$",
"object",
"->",
"getData",
"(",
")",
";",
"}",
"}"
] | @param Varien_Object $object
@param string $key
@return mixed | [
"@param",
"Varien_Object",
"$object",
"@param",
"string",
"$key"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Helper/Data.php#L17-L24 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Helper/Data.php | Aoe_Layout_Helper_Data.getSourceModelArray | public function getSourceModelArray($modelRef, $useCollection = false, $trimEmptyValues = false)
{
$model = Mage::getSingleton($modelRef);
if (!$model) {
throw new RuntimeException($this->__('Could not create source model (%s)', $modelRef));
}
$useCollection = (bool)$useCollection;
if ($useCollection) {
if (!$model instanceof Mage_Core_Model_Abstract) {
throw new RuntimeException($this->__('Invalid source model type (%s)', $modelRef));
}
$collection = $model->getCollection();
if (!$collection) {
throw new RuntimeException($this->__('Could not create collection for source model (%s)', $modelRef));
}
$model = $collection;
}
$additionalArgs = func_get_args();
array_shift($additionalArgs);
array_shift($additionalArgs);
array_shift($additionalArgs);
if (method_exists($model, 'toOptionArray')) {
$optionArray = call_user_func_array([$model, 'toOptionArray'], $additionalArgs);
} elseif (method_exists($model, 'toOptionHash')) {
$optionHash = call_user_func_array([$model, 'toOptionHash'], $additionalArgs);
$optionArray = [];
foreach ($optionHash as $value => $label) {
$optionArray[] = [
'value' => $value,
'label' => $label
];
}
} else {
if ($useCollection) {
throw new RuntimeException($this->__('Source model (%s) collection does not have required method toOptionArray or toOptionHash', $modelRef));
} else {
throw new RuntimeException($this->__('Source model (%s) does not have required method toOptionArray or toOptionHash', $modelRef));
}
}
if ($trimEmptyValues) {
foreach ($optionArray as $k => $option) {
if ($option['value'] == '') {
unset($optionArray[$k]);
}
}
}
return $optionArray;
} | php | public function getSourceModelArray($modelRef, $useCollection = false, $trimEmptyValues = false)
{
$model = Mage::getSingleton($modelRef);
if (!$model) {
throw new RuntimeException($this->__('Could not create source model (%s)', $modelRef));
}
$useCollection = (bool)$useCollection;
if ($useCollection) {
if (!$model instanceof Mage_Core_Model_Abstract) {
throw new RuntimeException($this->__('Invalid source model type (%s)', $modelRef));
}
$collection = $model->getCollection();
if (!$collection) {
throw new RuntimeException($this->__('Could not create collection for source model (%s)', $modelRef));
}
$model = $collection;
}
$additionalArgs = func_get_args();
array_shift($additionalArgs);
array_shift($additionalArgs);
array_shift($additionalArgs);
if (method_exists($model, 'toOptionArray')) {
$optionArray = call_user_func_array([$model, 'toOptionArray'], $additionalArgs);
} elseif (method_exists($model, 'toOptionHash')) {
$optionHash = call_user_func_array([$model, 'toOptionHash'], $additionalArgs);
$optionArray = [];
foreach ($optionHash as $value => $label) {
$optionArray[] = [
'value' => $value,
'label' => $label
];
}
} else {
if ($useCollection) {
throw new RuntimeException($this->__('Source model (%s) collection does not have required method toOptionArray or toOptionHash', $modelRef));
} else {
throw new RuntimeException($this->__('Source model (%s) does not have required method toOptionArray or toOptionHash', $modelRef));
}
}
if ($trimEmptyValues) {
foreach ($optionArray as $k => $option) {
if ($option['value'] == '') {
unset($optionArray[$k]);
}
}
}
return $optionArray;
} | [
"public",
"function",
"getSourceModelArray",
"(",
"$",
"modelRef",
",",
"$",
"useCollection",
"=",
"false",
",",
"$",
"trimEmptyValues",
"=",
"false",
")",
"{",
"$",
"model",
"=",
"Mage",
"::",
"getSingleton",
"(",
"$",
"modelRef",
")",
";",
"if",
"(",
"!",
"$",
"model",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Could not create source model (%s)'",
",",
"$",
"modelRef",
")",
")",
";",
"}",
"$",
"useCollection",
"=",
"(",
"bool",
")",
"$",
"useCollection",
";",
"if",
"(",
"$",
"useCollection",
")",
"{",
"if",
"(",
"!",
"$",
"model",
"instanceof",
"Mage_Core_Model_Abstract",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Invalid source model type (%s)'",
",",
"$",
"modelRef",
")",
")",
";",
"}",
"$",
"collection",
"=",
"$",
"model",
"->",
"getCollection",
"(",
")",
";",
"if",
"(",
"!",
"$",
"collection",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Could not create collection for source model (%s)'",
",",
"$",
"modelRef",
")",
")",
";",
"}",
"$",
"model",
"=",
"$",
"collection",
";",
"}",
"$",
"additionalArgs",
"=",
"func_get_args",
"(",
")",
";",
"array_shift",
"(",
"$",
"additionalArgs",
")",
";",
"array_shift",
"(",
"$",
"additionalArgs",
")",
";",
"array_shift",
"(",
"$",
"additionalArgs",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"model",
",",
"'toOptionArray'",
")",
")",
"{",
"$",
"optionArray",
"=",
"call_user_func_array",
"(",
"[",
"$",
"model",
",",
"'toOptionArray'",
"]",
",",
"$",
"additionalArgs",
")",
";",
"}",
"elseif",
"(",
"method_exists",
"(",
"$",
"model",
",",
"'toOptionHash'",
")",
")",
"{",
"$",
"optionHash",
"=",
"call_user_func_array",
"(",
"[",
"$",
"model",
",",
"'toOptionHash'",
"]",
",",
"$",
"additionalArgs",
")",
";",
"$",
"optionArray",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"optionHash",
"as",
"$",
"value",
"=>",
"$",
"label",
")",
"{",
"$",
"optionArray",
"[",
"]",
"=",
"[",
"'value'",
"=>",
"$",
"value",
",",
"'label'",
"=>",
"$",
"label",
"]",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"useCollection",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Source model (%s) collection does not have required method toOptionArray or toOptionHash'",
",",
"$",
"modelRef",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Source model (%s) does not have required method toOptionArray or toOptionHash'",
",",
"$",
"modelRef",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"trimEmptyValues",
")",
"{",
"foreach",
"(",
"$",
"optionArray",
"as",
"$",
"k",
"=>",
"$",
"option",
")",
"{",
"if",
"(",
"$",
"option",
"[",
"'value'",
"]",
"==",
"''",
")",
"{",
"unset",
"(",
"$",
"optionArray",
"[",
"$",
"k",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"optionArray",
";",
"}"
] | @param string $modelRef
@param bool $useCollection
@param bool $trimEmptyValues
@return array|mixed
@throws RuntimeException | [
"@param",
"string",
"$modelRef",
"@param",
"bool",
"$useCollection",
"@param",
"bool",
"$trimEmptyValues"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Helper/Data.php#L35-L90 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Helper/Data.php | Aoe_Layout_Helper_Data.filterCollection | public function filterCollection(Mage_Core_Model_Resource_Db_Collection_Abstract $collection, array $filters, array $ifConditionals = [])
{
$filter = true;
foreach ($ifConditionals as $ifConditional) {
if ($ifConditional === 'false' || !(bool)$ifConditional) {
$filter = false;
break;
}
}
if ($filter) {
foreach ($filters as $field => $condition) {
$collection->addFieldToFilter($field, $condition);
}
}
return $collection;
} | php | public function filterCollection(Mage_Core_Model_Resource_Db_Collection_Abstract $collection, array $filters, array $ifConditionals = [])
{
$filter = true;
foreach ($ifConditionals as $ifConditional) {
if ($ifConditional === 'false' || !(bool)$ifConditional) {
$filter = false;
break;
}
}
if ($filter) {
foreach ($filters as $field => $condition) {
$collection->addFieldToFilter($field, $condition);
}
}
return $collection;
} | [
"public",
"function",
"filterCollection",
"(",
"Mage_Core_Model_Resource_Db_Collection_Abstract",
"$",
"collection",
",",
"array",
"$",
"filters",
",",
"array",
"$",
"ifConditionals",
"=",
"[",
"]",
")",
"{",
"$",
"filter",
"=",
"true",
";",
"foreach",
"(",
"$",
"ifConditionals",
"as",
"$",
"ifConditional",
")",
"{",
"if",
"(",
"$",
"ifConditional",
"===",
"'false'",
"||",
"!",
"(",
"bool",
")",
"$",
"ifConditional",
")",
"{",
"$",
"filter",
"=",
"false",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"filter",
")",
"{",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"field",
"=>",
"$",
"condition",
")",
"{",
"$",
"collection",
"->",
"addFieldToFilter",
"(",
"$",
"field",
",",
"$",
"condition",
")",
";",
"}",
"}",
"return",
"$",
"collection",
";",
"}"
] | @param Mage_Core_Model_Resource_Db_Collection_Abstract $collection
@param array $filters
@param array $ifConditionals
@return Mage_Core_Model_Resource_Db_Collection_Abstract | [
"@param",
"Mage_Core_Model_Resource_Db_Collection_Abstract",
"$collection",
"@param",
"array",
"$filters",
"@param",
"array",
"$ifConditionals"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Helper/Data.php#L170-L187 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Connection/Connection.php | Connection.query | public function query($sql, $parameters = null) {
$pdo = $this->inTransaction || $this->onlyUseMaster ?
$this->pdoProvider->getMasterPDO() :
$this->pdoProvider->getSlavePDO();
$pdoStmt = $this->executeSql($pdo, $sql, $parameters);
//SQL执行发生错误
if ($pdoStmt === false) {
return false;
}
$row = $pdoStmt->fetch(PDO::FETCH_ASSOC);
return $row ? $row : null;
} | php | public function query($sql, $parameters = null) {
$pdo = $this->inTransaction || $this->onlyUseMaster ?
$this->pdoProvider->getMasterPDO() :
$this->pdoProvider->getSlavePDO();
$pdoStmt = $this->executeSql($pdo, $sql, $parameters);
//SQL执行发生错误
if ($pdoStmt === false) {
return false;
}
$row = $pdoStmt->fetch(PDO::FETCH_ASSOC);
return $row ? $row : null;
} | [
"public",
"function",
"query",
"(",
"$",
"sql",
",",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"pdo",
"=",
"$",
"this",
"->",
"inTransaction",
"||",
"$",
"this",
"->",
"onlyUseMaster",
"?",
"$",
"this",
"->",
"pdoProvider",
"->",
"getMasterPDO",
"(",
")",
":",
"$",
"this",
"->",
"pdoProvider",
"->",
"getSlavePDO",
"(",
")",
";",
"$",
"pdoStmt",
"=",
"$",
"this",
"->",
"executeSql",
"(",
"$",
"pdo",
",",
"$",
"sql",
",",
"$",
"parameters",
")",
";",
"//SQL执行发生错误",
"if",
"(",
"$",
"pdoStmt",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"row",
"=",
"$",
"pdoStmt",
"->",
"fetch",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"return",
"$",
"row",
"?",
"$",
"row",
":",
"null",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Connection/Connection.php#L73-L88 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Connection/Connection.php | Connection.queryAll | public function queryAll($sql, $parameters = null) {
$pdo = $this->inTransaction || $this->onlyUseMaster ?
$this->pdoProvider->getMasterPDO() :
$this->pdoProvider->getSlavePDO();
$pdoStmt = $this->executeSql($pdo, $sql, $parameters);
//SQL执行发生错误
if ($pdoStmt === false) {
return false;
}
$rows = $pdoStmt->fetchAll(PDO::FETCH_ASSOC);
return $rows ? $rows : null;
} | php | public function queryAll($sql, $parameters = null) {
$pdo = $this->inTransaction || $this->onlyUseMaster ?
$this->pdoProvider->getMasterPDO() :
$this->pdoProvider->getSlavePDO();
$pdoStmt = $this->executeSql($pdo, $sql, $parameters);
//SQL执行发生错误
if ($pdoStmt === false) {
return false;
}
$rows = $pdoStmt->fetchAll(PDO::FETCH_ASSOC);
return $rows ? $rows : null;
} | [
"public",
"function",
"queryAll",
"(",
"$",
"sql",
",",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"pdo",
"=",
"$",
"this",
"->",
"inTransaction",
"||",
"$",
"this",
"->",
"onlyUseMaster",
"?",
"$",
"this",
"->",
"pdoProvider",
"->",
"getMasterPDO",
"(",
")",
":",
"$",
"this",
"->",
"pdoProvider",
"->",
"getSlavePDO",
"(",
")",
";",
"$",
"pdoStmt",
"=",
"$",
"this",
"->",
"executeSql",
"(",
"$",
"pdo",
",",
"$",
"sql",
",",
"$",
"parameters",
")",
";",
"//SQL执行发生错误",
"if",
"(",
"$",
"pdoStmt",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"rows",
"=",
"$",
"pdoStmt",
"->",
"fetchAll",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"return",
"$",
"rows",
"?",
"$",
"rows",
":",
"null",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Connection/Connection.php#L93-L108 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Connection/Connection.php | Connection.execute | public function execute($sql, array $parameters = null) {
$pdo = $this->pdoProvider->getMasterPDO();
$pdoStmt = $this->executeSql($pdo, $sql, $parameters);
//SQL执行发生错误
if ($pdoStmt === false) {
return false;
}
return $pdoStmt->rowCount();
} | php | public function execute($sql, array $parameters = null) {
$pdo = $this->pdoProvider->getMasterPDO();
$pdoStmt = $this->executeSql($pdo, $sql, $parameters);
//SQL执行发生错误
if ($pdoStmt === false) {
return false;
}
return $pdoStmt->rowCount();
} | [
"public",
"function",
"execute",
"(",
"$",
"sql",
",",
"array",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"pdo",
"=",
"$",
"this",
"->",
"pdoProvider",
"->",
"getMasterPDO",
"(",
")",
";",
"$",
"pdoStmt",
"=",
"$",
"this",
"->",
"executeSql",
"(",
"$",
"pdo",
",",
"$",
"sql",
",",
"$",
"parameters",
")",
";",
"//SQL执行发生错误",
"if",
"(",
"$",
"pdoStmt",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"pdoStmt",
"->",
"rowCount",
"(",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Connection/Connection.php#L113-L124 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Connection/Connection.php | Connection.executeSql | private function executeSql(PDO $pdo, $sql, array $parameters = null) {
$this->lastPdo = $pdo;
$this->lastSql = $sql;
$this->lastParameters = $parameters;
try {
$pdoStmt = $pdo->prepare($sql);
$pdoStmt->execute($parameters);
return $pdoStmt;
} catch (Exception $ex) {
$errMsg = '执行SQL语句出错,错误消息:' . $ex->getMessage() . ', SQL:' . $this->getLastSql();
$this->logger->error($errMsg);
return false;
}
} | php | private function executeSql(PDO $pdo, $sql, array $parameters = null) {
$this->lastPdo = $pdo;
$this->lastSql = $sql;
$this->lastParameters = $parameters;
try {
$pdoStmt = $pdo->prepare($sql);
$pdoStmt->execute($parameters);
return $pdoStmt;
} catch (Exception $ex) {
$errMsg = '执行SQL语句出错,错误消息:' . $ex->getMessage() . ', SQL:' . $this->getLastSql();
$this->logger->error($errMsg);
return false;
}
} | [
"private",
"function",
"executeSql",
"(",
"PDO",
"$",
"pdo",
",",
"$",
"sql",
",",
"array",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"lastPdo",
"=",
"$",
"pdo",
";",
"$",
"this",
"->",
"lastSql",
"=",
"$",
"sql",
";",
"$",
"this",
"->",
"lastParameters",
"=",
"$",
"parameters",
";",
"try",
"{",
"$",
"pdoStmt",
"=",
"$",
"pdo",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"pdoStmt",
"->",
"execute",
"(",
"$",
"parameters",
")",
";",
"return",
"$",
"pdoStmt",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"$",
"errMsg",
"=",
"'执行SQL语句出错,错误消息:' . $ex->getMessage() . '",
" ",
"Q",
"L:",
"' ",
". $this->g",
"e",
"t",
"a",
"tSql();",
"",
"",
"",
"",
"",
"",
"",
"",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"$",
"errMsg",
")",
";",
"return",
"false",
";",
"}",
"}"
] | 预编译并执行一个SQL语句(这是一个更为底层的方法,供其他更高层的方法调用)
@param PDO $pdo PDO实例
@param string $sql 带占位符的SQL语句
@param array $parameters 预编译参数
@return PDOStatement|false SQL执行成功则返回一个PDOStatement对象,
SQL执行错误则返回false。注意:这里所谓的"执行成功"只是SQL执行没发生错误,
并不意味着找到了数据或更新了数据。 | [
"预编译并执行一个SQL语句(这是一个更为底层的方法,供其他更高层的方法调用)"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Connection/Connection.php#L136-L151 |
ouropencode/dachi | src/Logger.php | Logger.handle_shutdown | public static function handle_shutdown() {
$isFatal = false;
$error = error_get_last();
if($error !== NULL && $error['type'] === E_ERROR) {
$isFatal = true;
self::handle_error($error['type'], $error['message'], $error['file'], $error['line']);
}
if(!count(self::$log))
return false;
$filament = self::getFilament();
curl_get_contents(Configuration::get("filament.location"), array(
"version" => 2,
"key" => Configuration::get("filament.key"),
"data" => @json_encode($filament),
"error_count" => self::$error_count
), defined('CURLOPT_CONNECTTIMEOUT_MS') ? array(
CURLOPT_NOSIGNAL => true,
CURLOPT_CONNECTTIMEOUT_MS => 250
) : array(
CURLOPT_CONNECTTIMEOUT => 1
));
if($isFatal) {
Request::setResponseCode("exception", "fatal server error");
$response = array(
"data" => $data,
"response" => Request::getResponseCode(),
"render_actions" => array()
);
if(Request::isAjax()) {
http_response_code(200);
if(Kernel::getEnvironment() != "production")
$response["filament"] = $filament;
json_echo($response);
} else {
echo "<h1>Fatal Error</h1>";
if(Kernel::getEnvironment() != "production")
echo "<pre>" . var_export(self::$log, true) . "</pre>";
}
}
} | php | public static function handle_shutdown() {
$isFatal = false;
$error = error_get_last();
if($error !== NULL && $error['type'] === E_ERROR) {
$isFatal = true;
self::handle_error($error['type'], $error['message'], $error['file'], $error['line']);
}
if(!count(self::$log))
return false;
$filament = self::getFilament();
curl_get_contents(Configuration::get("filament.location"), array(
"version" => 2,
"key" => Configuration::get("filament.key"),
"data" => @json_encode($filament),
"error_count" => self::$error_count
), defined('CURLOPT_CONNECTTIMEOUT_MS') ? array(
CURLOPT_NOSIGNAL => true,
CURLOPT_CONNECTTIMEOUT_MS => 250
) : array(
CURLOPT_CONNECTTIMEOUT => 1
));
if($isFatal) {
Request::setResponseCode("exception", "fatal server error");
$response = array(
"data" => $data,
"response" => Request::getResponseCode(),
"render_actions" => array()
);
if(Request::isAjax()) {
http_response_code(200);
if(Kernel::getEnvironment() != "production")
$response["filament"] = $filament;
json_echo($response);
} else {
echo "<h1>Fatal Error</h1>";
if(Kernel::getEnvironment() != "production")
echo "<pre>" . var_export(self::$log, true) . "</pre>";
}
}
} | [
"public",
"static",
"function",
"handle_shutdown",
"(",
")",
"{",
"$",
"isFatal",
"=",
"false",
";",
"$",
"error",
"=",
"error_get_last",
"(",
")",
";",
"if",
"(",
"$",
"error",
"!==",
"NULL",
"&&",
"$",
"error",
"[",
"'type'",
"]",
"===",
"E_ERROR",
")",
"{",
"$",
"isFatal",
"=",
"true",
";",
"self",
"::",
"handle_error",
"(",
"$",
"error",
"[",
"'type'",
"]",
",",
"$",
"error",
"[",
"'message'",
"]",
",",
"$",
"error",
"[",
"'file'",
"]",
",",
"$",
"error",
"[",
"'line'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"count",
"(",
"self",
"::",
"$",
"log",
")",
")",
"return",
"false",
";",
"$",
"filament",
"=",
"self",
"::",
"getFilament",
"(",
")",
";",
"curl_get_contents",
"(",
"Configuration",
"::",
"get",
"(",
"\"filament.location\"",
")",
",",
"array",
"(",
"\"version\"",
"=>",
"2",
",",
"\"key\"",
"=>",
"Configuration",
"::",
"get",
"(",
"\"filament.key\"",
")",
",",
"\"data\"",
"=>",
"@",
"json_encode",
"(",
"$",
"filament",
")",
",",
"\"error_count\"",
"=>",
"self",
"::",
"$",
"error_count",
")",
",",
"defined",
"(",
"'CURLOPT_CONNECTTIMEOUT_MS'",
")",
"?",
"array",
"(",
"CURLOPT_NOSIGNAL",
"=>",
"true",
",",
"CURLOPT_CONNECTTIMEOUT_MS",
"=>",
"250",
")",
":",
"array",
"(",
"CURLOPT_CONNECTTIMEOUT",
"=>",
"1",
")",
")",
";",
"if",
"(",
"$",
"isFatal",
")",
"{",
"Request",
"::",
"setResponseCode",
"(",
"\"exception\"",
",",
"\"fatal server error\"",
")",
";",
"$",
"response",
"=",
"array",
"(",
"\"data\"",
"=>",
"$",
"data",
",",
"\"response\"",
"=>",
"Request",
"::",
"getResponseCode",
"(",
")",
",",
"\"render_actions\"",
"=>",
"array",
"(",
")",
")",
";",
"if",
"(",
"Request",
"::",
"isAjax",
"(",
")",
")",
"{",
"http_response_code",
"(",
"200",
")",
";",
"if",
"(",
"Kernel",
"::",
"getEnvironment",
"(",
")",
"!=",
"\"production\"",
")",
"$",
"response",
"[",
"\"filament\"",
"]",
"=",
"$",
"filament",
";",
"json_echo",
"(",
"$",
"response",
")",
";",
"}",
"else",
"{",
"echo",
"\"<h1>Fatal Error</h1>\"",
";",
"if",
"(",
"Kernel",
"::",
"getEnvironment",
"(",
")",
"!=",
"\"production\"",
")",
"echo",
"\"<pre>\"",
".",
"var_export",
"(",
"self",
"::",
"$",
"log",
",",
"true",
")",
".",
"\"</pre>\"",
";",
"}",
"}",
"}"
] | This function is called when PHP exits, it is used to handle any errors
and report information back to Filament (the error reporting tool). It
is unadivsed to call this function manually.
@internal
@return bool | [
"This",
"function",
"is",
"called",
"when",
"PHP",
"exits",
"it",
"is",
"used",
"to",
"handle",
"any",
"errors",
"and",
"report",
"information",
"back",
"to",
"Filament",
"(",
"the",
"error",
"reporting",
"tool",
")",
".",
"It",
"is",
"unadivsed",
"to",
"call",
"this",
"function",
"manually",
"."
] | train | https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Logger.php#L36-L80 |
ouropencode/dachi | src/Logger.php | Logger.handle_error | public static function handle_error($errno, $errstr, $errfile, $errline) {
if (!(error_reporting() & $errno))
return false;
self::error(sprintf("%s [%s] %s. Line: %s. File: %s", human_error_code($errno), $errno, $errstr, $errline, $errfile));
return true;
} | php | public static function handle_error($errno, $errstr, $errfile, $errline) {
if (!(error_reporting() & $errno))
return false;
self::error(sprintf("%s [%s] %s. Line: %s. File: %s", human_error_code($errno), $errno, $errstr, $errline, $errfile));
return true;
} | [
"public",
"static",
"function",
"handle_error",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"{",
"if",
"(",
"!",
"(",
"error_reporting",
"(",
")",
"&",
"$",
"errno",
")",
")",
"return",
"false",
";",
"self",
"::",
"error",
"(",
"sprintf",
"(",
"\"%s [%s] %s. Line: %s. File: %s\"",
",",
"human_error_code",
"(",
"$",
"errno",
")",
",",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errline",
",",
"$",
"errfile",
")",
")",
";",
"return",
"true",
";",
"}"
] | This function is called when a PHP error occurs. It is unadivsed to call
this function manually.
@internal
@param int $errno The error number
@param string $errstr The error message
@param string $errfile The file that caused the error
@param int $errline The line that caused the error
@return bool | [
"This",
"function",
"is",
"called",
"when",
"a",
"PHP",
"error",
"occurs",
".",
"It",
"is",
"unadivsed",
"to",
"call",
"this",
"function",
"manually",
"."
] | train | https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Logger.php#L93-L99 |
ouropencode/dachi | src/Logger.php | Logger.filament | private static function filament($type, $arguments) {
$uniqId = md5($type . json_encode($arguments));
if(isset(self::$log[$uniqId]))
return ++self::$log[$uniqId]["count"];
self::$log[$uniqId] = array(
"count" => 1,
"type" => $type,
"arguments" => $arguments
);
return true;
} | php | private static function filament($type, $arguments) {
$uniqId = md5($type . json_encode($arguments));
if(isset(self::$log[$uniqId]))
return ++self::$log[$uniqId]["count"];
self::$log[$uniqId] = array(
"count" => 1,
"type" => $type,
"arguments" => $arguments
);
return true;
} | [
"private",
"static",
"function",
"filament",
"(",
"$",
"type",
",",
"$",
"arguments",
")",
"{",
"$",
"uniqId",
"=",
"md5",
"(",
"$",
"type",
".",
"json_encode",
"(",
"$",
"arguments",
")",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"log",
"[",
"$",
"uniqId",
"]",
")",
")",
"return",
"++",
"self",
"::",
"$",
"log",
"[",
"$",
"uniqId",
"]",
"[",
"\"count\"",
"]",
";",
"self",
"::",
"$",
"log",
"[",
"$",
"uniqId",
"]",
"=",
"array",
"(",
"\"count\"",
"=>",
"1",
",",
"\"type\"",
"=>",
"$",
"type",
",",
"\"arguments\"",
"=>",
"$",
"arguments",
")",
";",
"return",
"true",
";",
"}"
] | Add a log entry to the filament log. This log is sent to the filament
server after script execution.
@internal
@param string $type The log message.
@param array $arguments An array of the log arguments.
@return bool | [
"Add",
"a",
"log",
"entry",
"to",
"the",
"filament",
"log",
".",
"This",
"log",
"is",
"sent",
"to",
"the",
"filament",
"server",
"after",
"script",
"execution",
"."
] | train | https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Logger.php#L128-L140 |
hametuha/wpametu | src/WPametu/Utility/StringHelper.php | StringHelper.hyphen_to_camel | public function hyphen_to_camel( $string, $upper_first = false ) {
$str = preg_replace_callback( '/-(.)/u', function ( $match ) {
return strtoupper( $match[1] );
}, strtolower( $string ) );
if ( $upper_first ) {
$str = ucfirst( $str );
}
return $str;
} | php | public function hyphen_to_camel( $string, $upper_first = false ) {
$str = preg_replace_callback( '/-(.)/u', function ( $match ) {
return strtoupper( $match[1] );
}, strtolower( $string ) );
if ( $upper_first ) {
$str = ucfirst( $str );
}
return $str;
} | [
"public",
"function",
"hyphen_to_camel",
"(",
"$",
"string",
",",
"$",
"upper_first",
"=",
"false",
")",
"{",
"$",
"str",
"=",
"preg_replace_callback",
"(",
"'/-(.)/u'",
",",
"function",
"(",
"$",
"match",
")",
"{",
"return",
"strtoupper",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"}",
",",
"strtolower",
"(",
"$",
"string",
")",
")",
";",
"if",
"(",
"$",
"upper_first",
")",
"{",
"$",
"str",
"=",
"ucfirst",
"(",
"$",
"str",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] | Make hyphenated string to camel case
@param string $string
@param bool $upper_first Retuns Uppercase first letter if true. Defalt false.
@return string | [
"Make",
"hyphenated",
"string",
"to",
"camel",
"case"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/StringHelper.php#L36-L45 |
hametuha/wpametu | src/WPametu/Utility/StringHelper.php | StringHelper.auto_link | public function auto_link( $string, $nofollow = true ) {
return $this->fetch_link( $string, function ( $match ) use ( $nofollow ) {
return sprintf( '<a href="%2$s"%1$s>%2$s</a>',
( $nofollow ? ' target="_blank" rel="nofollow,external"' : '' ), $match[0] );
} );
} | php | public function auto_link( $string, $nofollow = true ) {
return $this->fetch_link( $string, function ( $match ) use ( $nofollow ) {
return sprintf( '<a href="%2$s"%1$s>%2$s</a>',
( $nofollow ? ' target="_blank" rel="nofollow,external"' : '' ), $match[0] );
} );
} | [
"public",
"function",
"auto_link",
"(",
"$",
"string",
",",
"$",
"nofollow",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"fetch_link",
"(",
"$",
"string",
",",
"function",
"(",
"$",
"match",
")",
"use",
"(",
"$",
"nofollow",
")",
"{",
"return",
"sprintf",
"(",
"'<a href=\"%2$s\"%1$s>%2$s</a>'",
",",
"(",
"$",
"nofollow",
"?",
"' target=\"_blank\" rel=\"nofollow,external\"'",
":",
"''",
")",
",",
"$",
"match",
"[",
"0",
"]",
")",
";",
"}",
")",
";",
"}"
] | Linkify strings
@param string $string
@param bool $nofollow If true, target=_blank and rel=nofollow will append. Default true.
@return mixed | [
"Linkify",
"strings"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/StringHelper.php#L91-L96 |
hametuha/wpametu | src/WPametu/Utility/StringHelper.php | StringHelper.post_type_label | public function post_type_label( $singular_name, $multiple_name = '', $as_object = false ) {
if ( ! $multiple_name ) {
$multiple_name = $singular_name;
}
$labels = [
'name' => $multiple_name,
'singular_name' => $singular_name,
'add_new' => $this->__( 'Add new' ),
'add_new_item' => sprintf( $this->__( 'Add new %s' ), $singular_name ),
'edit_item' => sprintf( $this->__( 'Edit %s' ), $singular_name ),
'new_item' => sprintf( $this->__( 'New %s' ), $singular_name ),
'view_item' => sprintf( $this->__( 'Vew %s' ), $singular_name ),
'search_items' => sprintf( $this->__( 'Search %s' ), $multiple_name ),
'not_found' => sprintf( $this->__( 'No %s found.' ), $multiple_name ),
'not_found_in_trash' => sprintf( $this->__( 'No %s in trash.' ), $singular_name ),
'parent_item_colon' => sprintf( $this->__( 'Parent %s:' ), $singular_name ),
'all_items' => sprintf( $this->__( 'All %s' ), $multiple_name ),
'menu_name' => $singular_name,
'name_admin_bar' => $singular_name,
];
return $as_object ? (object) $labels : $labels;
} | php | public function post_type_label( $singular_name, $multiple_name = '', $as_object = false ) {
if ( ! $multiple_name ) {
$multiple_name = $singular_name;
}
$labels = [
'name' => $multiple_name,
'singular_name' => $singular_name,
'add_new' => $this->__( 'Add new' ),
'add_new_item' => sprintf( $this->__( 'Add new %s' ), $singular_name ),
'edit_item' => sprintf( $this->__( 'Edit %s' ), $singular_name ),
'new_item' => sprintf( $this->__( 'New %s' ), $singular_name ),
'view_item' => sprintf( $this->__( 'Vew %s' ), $singular_name ),
'search_items' => sprintf( $this->__( 'Search %s' ), $multiple_name ),
'not_found' => sprintf( $this->__( 'No %s found.' ), $multiple_name ),
'not_found_in_trash' => sprintf( $this->__( 'No %s in trash.' ), $singular_name ),
'parent_item_colon' => sprintf( $this->__( 'Parent %s:' ), $singular_name ),
'all_items' => sprintf( $this->__( 'All %s' ), $multiple_name ),
'menu_name' => $singular_name,
'name_admin_bar' => $singular_name,
];
return $as_object ? (object) $labels : $labels;
} | [
"public",
"function",
"post_type_label",
"(",
"$",
"singular_name",
",",
"$",
"multiple_name",
"=",
"''",
",",
"$",
"as_object",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"multiple_name",
")",
"{",
"$",
"multiple_name",
"=",
"$",
"singular_name",
";",
"}",
"$",
"labels",
"=",
"[",
"'name'",
"=>",
"$",
"multiple_name",
",",
"'singular_name'",
"=>",
"$",
"singular_name",
",",
"'add_new'",
"=>",
"$",
"this",
"->",
"__",
"(",
"'Add new'",
")",
",",
"'add_new_item'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Add new %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'edit_item'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Edit %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'new_item'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'New %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'view_item'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Vew %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'search_items'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Search %s'",
")",
",",
"$",
"multiple_name",
")",
",",
"'not_found'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'No %s found.'",
")",
",",
"$",
"multiple_name",
")",
",",
"'not_found_in_trash'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'No %s in trash.'",
")",
",",
"$",
"singular_name",
")",
",",
"'parent_item_colon'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Parent %s:'",
")",
",",
"$",
"singular_name",
")",
",",
"'all_items'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'All %s'",
")",
",",
"$",
"multiple_name",
")",
",",
"'menu_name'",
"=>",
"$",
"singular_name",
",",
"'name_admin_bar'",
"=>",
"$",
"singular_name",
",",
"]",
";",
"return",
"$",
"as_object",
"?",
"(",
"object",
")",
"$",
"labels",
":",
"$",
"labels",
";",
"}"
] | Returns post type label shorthand.
@param string $singular_name
@param string $multiple_name Optional.
@param bool $as_object
@return array|\stdClass | [
"Returns",
"post",
"type",
"label",
"shorthand",
"."
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/StringHelper.php#L107-L129 |
hametuha/wpametu | src/WPametu/Utility/StringHelper.php | StringHelper.get_taxonomy_label | public function get_taxonomy_label( $singular_name, $multiple_name = '', $hierarchical = false, $as_object = false ) {
if ( ! $multiple_name ) {
$multiple_name = $singular_name;
}
$labels = [
'name' => $multiple_name,
'singular_name' => $singular_name,
'search_items' => sprintf( $this->__( 'Search %s' ), $singular_name ),
'popular_items' => sprintf( $this->__( 'Popular %s' ), $multiple_name ),
'all_items' => sprintf( $this->__( 'All %s' ), $multiple_name ),
'parent_item' => $hierarchical ? sprintf( $this->__( 'Parent %s' ), $singular_name ) : null,
'parent_item_colon' => $hierarchical ? sprintf( $this->__( 'Parent %s:' ), $singular_name ) : null,
'edit_item' => sprintf( $this->__( 'Edit %s' ), $singular_name ),
'update_item' => sprintf( $this->__( 'Update %s' ), $singular_name ),
'add_new_item' => sprintf( $this->__( 'Add New %s' ), $singular_name ),
'new_item_name' => sprintf( $this->__( 'New %s Name' ), $singular_name ),
'separate_items_with_commas' => sprintf( $this->__( 'Separate %s with commas' ), $multiple_name ),
'add_or_remove_items' => sprintf( $this->__( 'Add or remove %s' ), $multiple_name ),
'choose_from_most_used' => sprintf( $this->__( 'Choose from the most used %s' ), $multiple_name ),
'not_found' => sprintf( $this->__( 'No %s found.' ), $multiple_name ),
'menu_name' => $multiple_name,
];
return $as_object ? (object) $labels : $labels;
} | php | public function get_taxonomy_label( $singular_name, $multiple_name = '', $hierarchical = false, $as_object = false ) {
if ( ! $multiple_name ) {
$multiple_name = $singular_name;
}
$labels = [
'name' => $multiple_name,
'singular_name' => $singular_name,
'search_items' => sprintf( $this->__( 'Search %s' ), $singular_name ),
'popular_items' => sprintf( $this->__( 'Popular %s' ), $multiple_name ),
'all_items' => sprintf( $this->__( 'All %s' ), $multiple_name ),
'parent_item' => $hierarchical ? sprintf( $this->__( 'Parent %s' ), $singular_name ) : null,
'parent_item_colon' => $hierarchical ? sprintf( $this->__( 'Parent %s:' ), $singular_name ) : null,
'edit_item' => sprintf( $this->__( 'Edit %s' ), $singular_name ),
'update_item' => sprintf( $this->__( 'Update %s' ), $singular_name ),
'add_new_item' => sprintf( $this->__( 'Add New %s' ), $singular_name ),
'new_item_name' => sprintf( $this->__( 'New %s Name' ), $singular_name ),
'separate_items_with_commas' => sprintf( $this->__( 'Separate %s with commas' ), $multiple_name ),
'add_or_remove_items' => sprintf( $this->__( 'Add or remove %s' ), $multiple_name ),
'choose_from_most_used' => sprintf( $this->__( 'Choose from the most used %s' ), $multiple_name ),
'not_found' => sprintf( $this->__( 'No %s found.' ), $multiple_name ),
'menu_name' => $multiple_name,
];
return $as_object ? (object) $labels : $labels;
} | [
"public",
"function",
"get_taxonomy_label",
"(",
"$",
"singular_name",
",",
"$",
"multiple_name",
"=",
"''",
",",
"$",
"hierarchical",
"=",
"false",
",",
"$",
"as_object",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"multiple_name",
")",
"{",
"$",
"multiple_name",
"=",
"$",
"singular_name",
";",
"}",
"$",
"labels",
"=",
"[",
"'name'",
"=>",
"$",
"multiple_name",
",",
"'singular_name'",
"=>",
"$",
"singular_name",
",",
"'search_items'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Search %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'popular_items'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Popular %s'",
")",
",",
"$",
"multiple_name",
")",
",",
"'all_items'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'All %s'",
")",
",",
"$",
"multiple_name",
")",
",",
"'parent_item'",
"=>",
"$",
"hierarchical",
"?",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Parent %s'",
")",
",",
"$",
"singular_name",
")",
":",
"null",
",",
"'parent_item_colon'",
"=>",
"$",
"hierarchical",
"?",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Parent %s:'",
")",
",",
"$",
"singular_name",
")",
":",
"null",
",",
"'edit_item'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Edit %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'update_item'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Update %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'add_new_item'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Add New %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'new_item_name'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'New %s Name'",
")",
",",
"$",
"singular_name",
")",
",",
"'separate_items_with_commas'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Separate %s with commas'",
")",
",",
"$",
"multiple_name",
")",
",",
"'add_or_remove_items'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Add or remove %s'",
")",
",",
"$",
"multiple_name",
")",
",",
"'choose_from_most_used'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Choose from the most used %s'",
")",
",",
"$",
"multiple_name",
")",
",",
"'not_found'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'No %s found.'",
")",
",",
"$",
"multiple_name",
")",
",",
"'menu_name'",
"=>",
"$",
"multiple_name",
",",
"]",
";",
"return",
"$",
"as_object",
"?",
"(",
"object",
")",
"$",
"labels",
":",
"$",
"labels",
";",
"}"
] | Returns taxonomy label shorthand.
@param string $singular_name
@param string $multiple_name If empty, singular_name will be used.
@param bool $hierarchical Default false.
@param bool $as_object Default false. If true, returns as Object
@return array|\stdClass | [
"Returns",
"taxonomy",
"label",
"shorthand",
"."
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/StringHelper.php#L142-L166 |
hametuha/wpametu | src/WPametu/Utility/StringHelper.php | StringHelper.extract_host | public function extract_host( $url ) {
$string = (string) $url;
if ( preg_match( '@https?://([^/\?#]+)@u', $url, $match ) ) {
return $match[1];
} else {
return $url;
}
} | php | public function extract_host( $url ) {
$string = (string) $url;
if ( preg_match( '@https?://([^/\?#]+)@u', $url, $match ) ) {
return $match[1];
} else {
return $url;
}
} | [
"public",
"function",
"extract_host",
"(",
"$",
"url",
")",
"{",
"$",
"string",
"=",
"(",
"string",
")",
"$",
"url",
";",
"if",
"(",
"preg_match",
"(",
"'@https?://([^/\\?#]+)@u'",
",",
"$",
"url",
",",
"$",
"match",
")",
")",
"{",
"return",
"$",
"match",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"return",
"$",
"url",
";",
"}",
"}"
] | Extract host value from url
@param string $url
@return string | [
"Extract",
"host",
"value",
"from",
"url"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/StringHelper.php#L175-L182 |
hametuha/wpametu | src/WPametu/Utility/StringHelper.php | StringHelper.trim | public function trim( $string, $limit = 80, $suffix = '…' ) {
if ( $limit < mb_strlen( $string, 'utf-8' ) ) {
$string = mb_substr( $string, 0, $limit - 1 ) . $suffix;
}
return $string;
} | php | public function trim( $string, $limit = 80, $suffix = '…' ) {
if ( $limit < mb_strlen( $string, 'utf-8' ) ) {
$string = mb_substr( $string, 0, $limit - 1 ) . $suffix;
}
return $string;
} | [
"public",
"function",
"trim",
"(",
"$",
"string",
",",
"$",
"limit",
"=",
"80",
",",
"$",
"suffix",
"=",
"'…'",
")",
"{",
"if",
"(",
"$",
"limit",
"<",
"mb_strlen",
"(",
"$",
"string",
",",
"'utf-8'",
")",
")",
"{",
"$",
"string",
"=",
"mb_substr",
"(",
"$",
"string",
",",
"0",
",",
"$",
"limit",
"-",
"1",
")",
".",
"$",
"suffix",
";",
"}",
"return",
"$",
"string",
";",
"}"
] | Trim string
@param string $string
@param int $limit Default 80
@param string $suffix Default …
@return string | [
"Trim",
"string"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/StringHelper.php#L193-L199 |
ekuiter/feature-php | FeaturePhp/Model/Model.php | Model.getFeature | public function getFeature($featureName, $permissive = false) {
$feature = Feature::findByName($this->features, $featureName, $permissive);
if (!$feature)
throw new ModelException("the model has no feature named \"$featureName\"");
return $feature;
} | php | public function getFeature($featureName, $permissive = false) {
$feature = Feature::findByName($this->features, $featureName, $permissive);
if (!$feature)
throw new ModelException("the model has no feature named \"$featureName\"");
return $feature;
} | [
"public",
"function",
"getFeature",
"(",
"$",
"featureName",
",",
"$",
"permissive",
"=",
"false",
")",
"{",
"$",
"feature",
"=",
"Feature",
"::",
"findByName",
"(",
"$",
"this",
"->",
"features",
",",
"$",
"featureName",
",",
"$",
"permissive",
")",
";",
"if",
"(",
"!",
"$",
"feature",
")",
"throw",
"new",
"ModelException",
"(",
"\"the model has no feature named \\\"$featureName\\\"\"",
")",
";",
"return",
"$",
"feature",
";",
"}"
] | Returns a feature in the feature model with a given name.
@param string $featureName
@param bool $permissive
@return Feature | [
"Returns",
"a",
"feature",
"in",
"the",
"feature",
"model",
"with",
"a",
"given",
"name",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/Model.php#L72-L77 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/query_select_oracle.php | ezcQuerySelectOracle.reset | public function reset()
{
$this->hasLimit = false;
$this->limit = 0;
$this->offset = 0;
parent::reset();
} | php | public function reset()
{
$this->hasLimit = false;
$this->limit = 0;
$this->offset = 0;
parent::reset();
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"hasLimit",
"=",
"false",
";",
"$",
"this",
"->",
"limit",
"=",
"0",
";",
"$",
"this",
"->",
"offset",
"=",
"0",
";",
"parent",
"::",
"reset",
"(",
")",
";",
"}"
] | Resets the query object for reuse.
@return void | [
"Resets",
"the",
"query",
"object",
"for",
"reuse",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/query_select_oracle.php#L58-L64 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/query_select_oracle.php | ezcQuerySelectOracle.limit | public function limit( $limit, $offset = 0 )
{
$this->hasLimit = true;
$this->limit = $limit;
$this->offset = $offset;
return $this;
} | php | public function limit( $limit, $offset = 0 )
{
$this->hasLimit = true;
$this->limit = $limit;
$this->offset = $offset;
return $this;
} | [
"public",
"function",
"limit",
"(",
"$",
"limit",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"hasLimit",
"=",
"true",
";",
"$",
"this",
"->",
"limit",
"=",
"$",
"limit",
";",
"$",
"this",
"->",
"offset",
"=",
"$",
"offset",
";",
"return",
"$",
"this",
";",
"}"
] | Returns SQL that limits the result set.
$limit controls the maximum number of rows that will be returned.
$offset controls which row that will be the first in the result
set from the total amount of matching rows.
Example:
<code>
$q->select( '*' )->from( 'table' )
->limit( 10, 0 );
</code>
Oracle does not support the LIMIT keyword. A complete rewrite of the
query is neccessary. Queries will be rewritten like this:
<code>
Original query in MySQL syntax:
SELECT * FROM table LIMIT 10, 5
The corresponding Oracle query:
SELECT * FROM (SELECT a.*, ROWNUM rn FROM (SELECT * FROM table) a WHERE rownum <= 15) WHERE rn >= 6;
</code>
Even though the Oracle query is three times as long it performs about the same
as mysql on small result sets and a bit better on large result sets.
Note that you will not get a result if you call buildLimit() when using the oracle database.
@param string $limit integer expression
@param string $offset integer expression
@return ezcQuerySelect | [
"Returns",
"SQL",
"that",
"limits",
"the",
"result",
"set",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/query_select_oracle.php#L119-L125 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/query_select_oracle.php | ezcQuerySelectOracle.getQuery | public function getQuery()
{
$query = parent::getQuery();
if ( $this->hasLimit )
{
$max = $this->offset + $this->limit;
if ( $this->offset > 0 )
{
$min = $this->offset + 1;
$query = "SELECT * FROM (SELECT a.*, ROWNUM rn FROM ( {$query} ) a WHERE rownum <= {$max} ) WHERE rn >= {$min}";
}
else
{
$query = "SELECT a.* FROM ( {$query} ) a WHERE ROWNUM <= {$max}";
}
}
return $query;
} | php | public function getQuery()
{
$query = parent::getQuery();
if ( $this->hasLimit )
{
$max = $this->offset + $this->limit;
if ( $this->offset > 0 )
{
$min = $this->offset + 1;
$query = "SELECT * FROM (SELECT a.*, ROWNUM rn FROM ( {$query} ) a WHERE rownum <= {$max} ) WHERE rn >= {$min}";
}
else
{
$query = "SELECT a.* FROM ( {$query} ) a WHERE ROWNUM <= {$max}";
}
}
return $query;
} | [
"public",
"function",
"getQuery",
"(",
")",
"{",
"$",
"query",
"=",
"parent",
"::",
"getQuery",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasLimit",
")",
"{",
"$",
"max",
"=",
"$",
"this",
"->",
"offset",
"+",
"$",
"this",
"->",
"limit",
";",
"if",
"(",
"$",
"this",
"->",
"offset",
">",
"0",
")",
"{",
"$",
"min",
"=",
"$",
"this",
"->",
"offset",
"+",
"1",
";",
"$",
"query",
"=",
"\"SELECT * FROM (SELECT a.*, ROWNUM rn FROM ( {$query} ) a WHERE rownum <= {$max} ) WHERE rn >= {$min}\"",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"\"SELECT a.* FROM ( {$query} ) a WHERE ROWNUM <= {$max}\"",
";",
"}",
"}",
"return",
"$",
"query",
";",
"}"
] | Transforms the query from the parent to provide LIMIT functionality. | [
"Transforms",
"the",
"query",
"from",
"the",
"parent",
"to",
"provide",
"LIMIT",
"functionality",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/query_select_oracle.php#L141-L158 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/query_select_oracle.php | ezcQuerySelectOracle.prepare | public function prepare()
{
if ( $this->fromString == null || $this->fromString == '' )
{
$this->from( $this->getDummyTableName() );
}
return parent::prepare();
} | php | public function prepare()
{
if ( $this->fromString == null || $this->fromString == '' )
{
$this->from( $this->getDummyTableName() );
}
return parent::prepare();
} | [
"public",
"function",
"prepare",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"fromString",
"==",
"null",
"||",
"$",
"this",
"->",
"fromString",
"==",
"''",
")",
"{",
"$",
"this",
"->",
"from",
"(",
"$",
"this",
"->",
"getDummyTableName",
"(",
")",
")",
";",
"}",
"return",
"parent",
"::",
"prepare",
"(",
")",
";",
"}"
] | Handles preparing query.
Overrides ezcQuery->prepare()
Adds "FROM dual" to the select if no FROM clause specified
i.e. fixes queries like "SELECT 1+1" to work in Oracle.
@return PDOStatement | [
"Handles",
"preparing",
"query",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/query_select_oracle.php#L170-L177 |
flowcode/AmulenUserBundle | src/Flowcode/UserBundle/Controller/AdminRoleController.php | AdminRoleController.createCreateForm | private function createCreateForm(Role $entity) {
$form = $this->createForm(new RoleType, $entity, array(
'action' => $this->generateUrl('admin_role_create'),
'method' => 'POST',
));
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
} | php | private function createCreateForm(Role $entity) {
$form = $this->createForm(new RoleType, $entity, array(
'action' => $this->generateUrl('admin_role_create'),
'method' => 'POST',
));
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
} | [
"private",
"function",
"createCreateForm",
"(",
"Role",
"$",
"entity",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"RoleType",
",",
"$",
"entity",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_role_create'",
")",
",",
"'method'",
"=>",
"'POST'",
",",
")",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'submit'",
",",
"'submit'",
",",
"array",
"(",
"'label'",
"=>",
"'Create'",
")",
")",
";",
"return",
"$",
"form",
";",
"}"
] | Creates a form to create a Role entity.
@param Role $entity The entity
@return \Symfony\Component\Form\Form The form | [
"Creates",
"a",
"form",
"to",
"create",
"a",
"Role",
"entity",
"."
] | train | https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Controller/AdminRoleController.php#L72-L81 |
flowcode/AmulenUserBundle | src/Flowcode/UserBundle/Controller/AdminRoleController.php | AdminRoleController.newAction | public function newAction() {
$entity = new Role();
$form = $this->createCreateForm($entity);
return array(
'entity' => $entity,
'form' => $form->createView(),
);
} | php | public function newAction() {
$entity = new Role();
$form = $this->createCreateForm($entity);
return array(
'entity' => $entity,
'form' => $form->createView(),
);
} | [
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"entity",
"=",
"new",
"Role",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createCreateForm",
"(",
"$",
"entity",
")",
";",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Displays a form to create a new Role entity.
@Route("/new", name="admin_role_new")
@Method("GET")
@Template() | [
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"Role",
"entity",
"."
] | train | https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Controller/AdminRoleController.php#L90-L100 |
Eresus/EresusCMS | src/core/Admin/ContentProvider/Abstract.php | Eresus_Admin_ContentProvider_Abstract.adminRender | public function adminRender(Eresus_CMS_Request $request)
{
if (!method_exists($this->getModule(), 'adminRender'))
{
throw new LogicException(sprintf(_('Метод "%s" не найден в классе "%s".'),
'adminRender', get_class($this->getModule())));
}
try
{
$html = $this->getModule()->adminRender($request);
}
catch (Eresus_CMS_Exception_NotFound $e)
{
throw $e;
}
catch (Exception $e)
{
throw new RuntimeException(
sprintf(_('В модуле %s произошла ошибка: %s'), $this->getModuleName(),
$e->getMessage()), 0, $e);
}
return $html;
} | php | public function adminRender(Eresus_CMS_Request $request)
{
if (!method_exists($this->getModule(), 'adminRender'))
{
throw new LogicException(sprintf(_('Метод "%s" не найден в классе "%s".'),
'adminRender', get_class($this->getModule())));
}
try
{
$html = $this->getModule()->adminRender($request);
}
catch (Eresus_CMS_Exception_NotFound $e)
{
throw $e;
}
catch (Exception $e)
{
throw new RuntimeException(
sprintf(_('В модуле %s произошла ошибка: %s'), $this->getModuleName(),
$e->getMessage()), 0, $e);
}
return $html;
} | [
"public",
"function",
"adminRender",
"(",
"Eresus_CMS_Request",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
"->",
"getModule",
"(",
")",
",",
"'adminRender'",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"sprintf",
"(",
"_",
"(",
"'Метод \"%s\" не найден в классе \"%s\".'),",
"",
"",
"'adminRender'",
",",
"get_class",
"(",
"$",
"this",
"->",
"getModule",
"(",
")",
")",
")",
")",
";",
"}",
"try",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"getModule",
"(",
")",
"->",
"adminRender",
"(",
"$",
"request",
")",
";",
"}",
"catch",
"(",
"Eresus_CMS_Exception_NotFound",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"_",
"(",
"'В модуле %s произошла ошибка: %s'), $this->getModuleNam",
"e",
"(",
",",
"",
"",
"",
"",
"",
"",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"html",
";",
"}"
] | Отрисовывает интерфейс модуля
@param Eresus_CMS_Request $request
@throws LogicException
@throws RuntimeException
@return string HTML
@since 3.01 | [
"Отрисовывает",
"интерфейс",
"модуля"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Admin/ContentProvider/Abstract.php#L58-L80 |
hametuha/wpametu | src/WPametu/Utility/Formatter.php | Formatter.to_string | public static function to_string( \DOMDocument $dom ) {
$html5 = new HTML5();
preg_match( '/<body>(.*)<\/body>/s', $html5->saveHTML( $dom ), $match );
return $match[1];
} | php | public static function to_string( \DOMDocument $dom ) {
$html5 = new HTML5();
preg_match( '/<body>(.*)<\/body>/s', $html5->saveHTML( $dom ), $match );
return $match[1];
} | [
"public",
"static",
"function",
"to_string",
"(",
"\\",
"DOMDocument",
"$",
"dom",
")",
"{",
"$",
"html5",
"=",
"new",
"HTML5",
"(",
")",
";",
"preg_match",
"(",
"'/<body>(.*)<\\/body>/s'",
",",
"$",
"html5",
"->",
"saveHTML",
"(",
"$",
"dom",
")",
",",
"$",
"match",
")",
";",
"return",
"$",
"match",
"[",
"1",
"]",
";",
"}"
] | Return body as string
@param \DOMDocument $dom
@return mixed | [
"Return",
"body",
"as",
"string"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/Formatter.php#L45-L50 |
mothership-ec/composer | src/Composer/Downloader/VcsDownloader.php | VcsDownloader.download | public function download(PackageInterface $package, $path)
{
if (!$package->getSourceReference()) {
throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
}
$this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
$this->filesystem->emptyDirectory($path);
$urls = $package->getSourceUrls();
while ($url = array_shift($urls)) {
try {
if (Filesystem::isLocalPath($url)) {
$url = realpath($url);
}
$this->doDownload($package, $path, $url);
break;
} catch (\Exception $e) {
if ($this->io->isDebug()) {
$this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
} elseif (count($urls)) {
$this->io->writeError(' Failed, trying the next URL');
}
if (!count($urls)) {
throw $e;
}
}
}
$this->io->writeError('');
} | php | public function download(PackageInterface $package, $path)
{
if (!$package->getSourceReference()) {
throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
}
$this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
$this->filesystem->emptyDirectory($path);
$urls = $package->getSourceUrls();
while ($url = array_shift($urls)) {
try {
if (Filesystem::isLocalPath($url)) {
$url = realpath($url);
}
$this->doDownload($package, $path, $url);
break;
} catch (\Exception $e) {
if ($this->io->isDebug()) {
$this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
} elseif (count($urls)) {
$this->io->writeError(' Failed, trying the next URL');
}
if (!count($urls)) {
throw $e;
}
}
}
$this->io->writeError('');
} | [
"public",
"function",
"download",
"(",
"PackageInterface",
"$",
"package",
",",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"$",
"package",
"->",
"getSourceReference",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Package '",
".",
"$",
"package",
"->",
"getPrettyName",
"(",
")",
".",
"' is missing reference information'",
")",
";",
"}",
"$",
"this",
"->",
"io",
"->",
"writeError",
"(",
"\" - Installing <info>\"",
".",
"$",
"package",
"->",
"getName",
"(",
")",
".",
"\"</info> (<comment>\"",
".",
"VersionParser",
"::",
"formatVersion",
"(",
"$",
"package",
")",
".",
"\"</comment>)\"",
")",
";",
"$",
"this",
"->",
"filesystem",
"->",
"emptyDirectory",
"(",
"$",
"path",
")",
";",
"$",
"urls",
"=",
"$",
"package",
"->",
"getSourceUrls",
"(",
")",
";",
"while",
"(",
"$",
"url",
"=",
"array_shift",
"(",
"$",
"urls",
")",
")",
"{",
"try",
"{",
"if",
"(",
"Filesystem",
"::",
"isLocalPath",
"(",
"$",
"url",
")",
")",
"{",
"$",
"url",
"=",
"realpath",
"(",
"$",
"url",
")",
";",
"}",
"$",
"this",
"->",
"doDownload",
"(",
"$",
"package",
",",
"$",
"path",
",",
"$",
"url",
")",
";",
"break",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"io",
"->",
"isDebug",
"(",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"writeError",
"(",
"'Failed: ['",
".",
"get_class",
"(",
"$",
"e",
")",
".",
"'] '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"urls",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"writeError",
"(",
"' Failed, trying the next URL'",
")",
";",
"}",
"if",
"(",
"!",
"count",
"(",
"$",
"urls",
")",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"io",
"->",
"writeError",
"(",
"''",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/VcsDownloader.php#L51-L81 |
Humanized/yii2-location | models/location/LocationSearch.php | LocationSearch.search | public function search($params)
{
$this->load($params);
$query = Location::find();
$query->select(['*', 'uid' => 'location.uid', 'name' => 'city_translation.name', 'language' => 'city.language_id']);
$query->innerJoin('city', 'location.city_id=city.id');
$query->leftJoin('city_translation', 'city_translation.city_id=city.id');
//$query->andWhere(['city.language_id' => 'city_translation.language_id']);
// $query->joinWith('city');
// $query->joinWith('city.localisedIdentification');
if (isset($this->uid)) {
$this->pageSize = 1;
}
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => ($this->pagination ? [
'pageSize' => $this->pageSize,
] : FALSE),
'sort' => [
'attributes' => [
'name', 'postcode', 'language'
],
]
]);
if (isset($this->uid)) {
// uncomment the following line if you do not want to return any records when validation fails
$query->where(['location.uid' => $this->uid]);
return $dataProvider;
}
if (!$this->validate() || !isset($this->country_id)) {
// uncomment the following line if you do not want to return any records when validation fails
$query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['country_id' => $this->country_id]);
$query->andFilterWhere(
['NOT IN', 'postcode', ['-1', '0']]
);
$query->andFilterWhere([
'or',
['like', 'postcode', $this->q],
['like', 'city_translation.name', $this->q],
]);
return $dataProvider;
} | php | public function search($params)
{
$this->load($params);
$query = Location::find();
$query->select(['*', 'uid' => 'location.uid', 'name' => 'city_translation.name', 'language' => 'city.language_id']);
$query->innerJoin('city', 'location.city_id=city.id');
$query->leftJoin('city_translation', 'city_translation.city_id=city.id');
//$query->andWhere(['city.language_id' => 'city_translation.language_id']);
// $query->joinWith('city');
// $query->joinWith('city.localisedIdentification');
if (isset($this->uid)) {
$this->pageSize = 1;
}
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => ($this->pagination ? [
'pageSize' => $this->pageSize,
] : FALSE),
'sort' => [
'attributes' => [
'name', 'postcode', 'language'
],
]
]);
if (isset($this->uid)) {
// uncomment the following line if you do not want to return any records when validation fails
$query->where(['location.uid' => $this->uid]);
return $dataProvider;
}
if (!$this->validate() || !isset($this->country_id)) {
// uncomment the following line if you do not want to return any records when validation fails
$query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['country_id' => $this->country_id]);
$query->andFilterWhere(
['NOT IN', 'postcode', ['-1', '0']]
);
$query->andFilterWhere([
'or',
['like', 'postcode', $this->q],
['like', 'city_translation.name', $this->q],
]);
return $dataProvider;
} | [
"public",
"function",
"search",
"(",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"load",
"(",
"$",
"params",
")",
";",
"$",
"query",
"=",
"Location",
"::",
"find",
"(",
")",
";",
"$",
"query",
"->",
"select",
"(",
"[",
"'*'",
",",
"'uid'",
"=>",
"'location.uid'",
",",
"'name'",
"=>",
"'city_translation.name'",
",",
"'language'",
"=>",
"'city.language_id'",
"]",
")",
";",
"$",
"query",
"->",
"innerJoin",
"(",
"'city'",
",",
"'location.city_id=city.id'",
")",
";",
"$",
"query",
"->",
"leftJoin",
"(",
"'city_translation'",
",",
"'city_translation.city_id=city.id'",
")",
";",
"//$query->andWhere(['city.language_id' => 'city_translation.language_id']);",
"// $query->joinWith('city');",
"// $query->joinWith('city.localisedIdentification');",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"uid",
")",
")",
"{",
"$",
"this",
"->",
"pageSize",
"=",
"1",
";",
"}",
"$",
"dataProvider",
"=",
"new",
"ActiveDataProvider",
"(",
"[",
"'query'",
"=>",
"$",
"query",
",",
"'pagination'",
"=>",
"(",
"$",
"this",
"->",
"pagination",
"?",
"[",
"'pageSize'",
"=>",
"$",
"this",
"->",
"pageSize",
",",
"]",
":",
"FALSE",
")",
",",
"'sort'",
"=>",
"[",
"'attributes'",
"=>",
"[",
"'name'",
",",
"'postcode'",
",",
"'language'",
"]",
",",
"]",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"uid",
")",
")",
"{",
"// uncomment the following line if you do not want to return any records when validation fails",
"$",
"query",
"->",
"where",
"(",
"[",
"'location.uid'",
"=>",
"$",
"this",
"->",
"uid",
"]",
")",
";",
"return",
"$",
"dataProvider",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"validate",
"(",
")",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"country_id",
")",
")",
"{",
"// uncomment the following line if you do not want to return any records when validation fails",
"$",
"query",
"->",
"where",
"(",
"'0=1'",
")",
";",
"return",
"$",
"dataProvider",
";",
"}",
"$",
"query",
"->",
"andFilterWhere",
"(",
"[",
"'country_id'",
"=>",
"$",
"this",
"->",
"country_id",
"]",
")",
";",
"$",
"query",
"->",
"andFilterWhere",
"(",
"[",
"'NOT IN'",
",",
"'postcode'",
",",
"[",
"'-1'",
",",
"'0'",
"]",
"]",
")",
";",
"$",
"query",
"->",
"andFilterWhere",
"(",
"[",
"'or'",
",",
"[",
"'like'",
",",
"'postcode'",
",",
"$",
"this",
"->",
"q",
"]",
",",
"[",
"'like'",
",",
"'city_translation.name'",
",",
"$",
"this",
"->",
"q",
"]",
",",
"]",
")",
";",
"return",
"$",
"dataProvider",
";",
"}"
] | Creates data provider instance with search query applied
@param array $params
@return ActiveDataProvider | [
"Creates",
"data",
"provider",
"instance",
"with",
"search",
"query",
"applied"
] | train | https://github.com/Humanized/yii2-location/blob/48ac12ceab741fc4c82ac8e979415a11bf9175f2/models/location/LocationSearch.php#L47-L96 |
GreenCape/joomla-cli | src/GreenCape/JoomlaCLI/Driver/Joomla2.php | Joomla2Driver.setupEnvironment | public function setupEnvironment($basePath, $application = 'site')
{
define('DS', DIRECTORY_SEPARATOR);
parent::setupEnvironment($basePath, $application);
jimport('joomla.application.component.helper');
} | php | public function setupEnvironment($basePath, $application = 'site')
{
define('DS', DIRECTORY_SEPARATOR);
parent::setupEnvironment($basePath, $application);
jimport('joomla.application.component.helper');
} | [
"public",
"function",
"setupEnvironment",
"(",
"$",
"basePath",
",",
"$",
"application",
"=",
"'site'",
")",
"{",
"define",
"(",
"'DS'",
",",
"DIRECTORY_SEPARATOR",
")",
";",
"parent",
"::",
"setupEnvironment",
"(",
"$",
"basePath",
",",
"$",
"application",
")",
";",
"jimport",
"(",
"'joomla.application.component.helper'",
")",
";",
"}"
] | Setup the environment
@param string $basePath The root of the Joomla! application
@param string $application The application, eg., 'site' or 'administration'
@return void | [
"Setup",
"the",
"environment"
] | train | https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Driver/Joomla2.php#L51-L58 |
oroinc/OroLayoutComponent | BlockViewCollection.php | BlockViewCollection.offsetGet | public function offsetGet($offset)
{
if (isset($this->elements[$offset])) {
return $this->elements[$offset];
};
throw new \OutOfBoundsException(sprintf('Undefined index: %s.', $offset));
} | php | public function offsetGet($offset)
{
if (isset($this->elements[$offset])) {
return $this->elements[$offset];
};
throw new \OutOfBoundsException(sprintf('Undefined index: %s.', $offset));
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"offset",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"elements",
"[",
"$",
"offset",
"]",
";",
"}",
";",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'Undefined index: %s.'",
",",
"$",
"offset",
")",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockViewCollection.php#L31-L38 |
ekuiter/feature-php | FeaturePhp/Collaboration/ClassComposer.php | ClassComposer.refine | public function refine($role) {
$fileSource = $role->getFileSpecification()->getSource();
$parser = (new fphp\Helper\PhpParser())->parseFile($fileSource);
$ast = $parser->getAst();
$class = $parser->getExactlyOneClass($fileSource);
if (!$this->targetClass) { // not refining, but defining the target class
$this->targetClass = $class->name;
$this->mangleClassName($class, $role);
} else { // refining
if ($class->name !== $this->targetClass)
throw new ClassComposerException("\"$fileSource\" refines \"$class->name\" (expected \"$this->targetClass\")");
if ($class->extends)
throw new ClassComposerException("refining role at \"$fileSource\" may not extend a class");
$this->mangleClassName($class, $role);
$this->extendClass($class);
}
return new ClassComposer($this->targetClass, $class->name, array_merge($this->ast, $ast));
} | php | public function refine($role) {
$fileSource = $role->getFileSpecification()->getSource();
$parser = (new fphp\Helper\PhpParser())->parseFile($fileSource);
$ast = $parser->getAst();
$class = $parser->getExactlyOneClass($fileSource);
if (!$this->targetClass) { // not refining, but defining the target class
$this->targetClass = $class->name;
$this->mangleClassName($class, $role);
} else { // refining
if ($class->name !== $this->targetClass)
throw new ClassComposerException("\"$fileSource\" refines \"$class->name\" (expected \"$this->targetClass\")");
if ($class->extends)
throw new ClassComposerException("refining role at \"$fileSource\" may not extend a class");
$this->mangleClassName($class, $role);
$this->extendClass($class);
}
return new ClassComposer($this->targetClass, $class->name, array_merge($this->ast, $ast));
} | [
"public",
"function",
"refine",
"(",
"$",
"role",
")",
"{",
"$",
"fileSource",
"=",
"$",
"role",
"->",
"getFileSpecification",
"(",
")",
"->",
"getSource",
"(",
")",
";",
"$",
"parser",
"=",
"(",
"new",
"fphp",
"\\",
"Helper",
"\\",
"PhpParser",
"(",
")",
")",
"->",
"parseFile",
"(",
"$",
"fileSource",
")",
";",
"$",
"ast",
"=",
"$",
"parser",
"->",
"getAst",
"(",
")",
";",
"$",
"class",
"=",
"$",
"parser",
"->",
"getExactlyOneClass",
"(",
"$",
"fileSource",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"targetClass",
")",
"{",
"// not refining, but defining the target class",
"$",
"this",
"->",
"targetClass",
"=",
"$",
"class",
"->",
"name",
";",
"$",
"this",
"->",
"mangleClassName",
"(",
"$",
"class",
",",
"$",
"role",
")",
";",
"}",
"else",
"{",
"// refining",
"if",
"(",
"$",
"class",
"->",
"name",
"!==",
"$",
"this",
"->",
"targetClass",
")",
"throw",
"new",
"ClassComposerException",
"(",
"\"\\\"$fileSource\\\" refines \\\"$class->name\\\" (expected \\\"$this->targetClass\\\")\"",
")",
";",
"if",
"(",
"$",
"class",
"->",
"extends",
")",
"throw",
"new",
"ClassComposerException",
"(",
"\"refining role at \\\"$fileSource\\\" may not extend a class\"",
")",
";",
"$",
"this",
"->",
"mangleClassName",
"(",
"$",
"class",
",",
"$",
"role",
")",
";",
"$",
"this",
"->",
"extendClass",
"(",
"$",
"class",
")",
";",
"}",
"return",
"new",
"ClassComposer",
"(",
"$",
"this",
"->",
"targetClass",
",",
"$",
"class",
"->",
"name",
",",
"array_merge",
"(",
"$",
"this",
"->",
"ast",
",",
"$",
"ast",
")",
")",
";",
"}"
] | Returns a new class composer containing a role's refinements.
@param Role $role
@return ClassComposer | [
"Returns",
"a",
"new",
"class",
"composer",
"containing",
"a",
"role",
"s",
"refinements",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Collaboration/ClassComposer.php#L90-L110 |
ekuiter/feature-php | FeaturePhp/Collaboration/ClassComposer.php | ClassComposer.getContent | public function getContent() {
$class = new \PhpParser\Node\Stmt\Class_($this->targetClass);
$this->extendClass($class);
$ast = array_merge($this->ast, array($class));
$code = fphp\Helper\PhpParser::astToString($ast);
return new fphp\File\TextFileContent($code);
} | php | public function getContent() {
$class = new \PhpParser\Node\Stmt\Class_($this->targetClass);
$this->extendClass($class);
$ast = array_merge($this->ast, array($class));
$code = fphp\Helper\PhpParser::astToString($ast);
return new fphp\File\TextFileContent($code);
} | [
"public",
"function",
"getContent",
"(",
")",
"{",
"$",
"class",
"=",
"new",
"\\",
"PhpParser",
"\\",
"Node",
"\\",
"Stmt",
"\\",
"Class_",
"(",
"$",
"this",
"->",
"targetClass",
")",
";",
"$",
"this",
"->",
"extendClass",
"(",
"$",
"class",
")",
";",
"$",
"ast",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"ast",
",",
"array",
"(",
"$",
"class",
")",
")",
";",
"$",
"code",
"=",
"fphp",
"\\",
"Helper",
"\\",
"PhpParser",
"::",
"astToString",
"(",
"$",
"ast",
")",
";",
"return",
"new",
"fphp",
"\\",
"File",
"\\",
"TextFileContent",
"(",
"$",
"code",
")",
";",
"}"
] | Returns the refined file's content.
@return \FeaturePhp\File\TextFileContent | [
"Returns",
"the",
"refined",
"file",
"s",
"content",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Collaboration/ClassComposer.php#L116-L122 |
surebert/surebert-framework | src/sb/Controller/Toolkit.php | Toolkit.concatFiles | protected function concatFiles($files = Array(), $version = '')
{
if ($files[0] == 'sb' && strstr(\sb\Gateway::$agent, 'MSIE')) {
array_unshift($files, 'js1_5');
}
$root = $this->toolkit_root;
$binary = preg_match("~\.(swf|gif|png)$~", $files[0], $match);
if ($binary) {
if ($match[1] == 'swf') {
header("Content-type: application/x-shockwave-flash");
} elseif ($match[1] == 'gif' || $match[1] == 'png') {
header("Content-type: image/" . $match[1]);
}
} else {
$this->addJavascriptHeaders();
echo '//v ' . date('m/d/Y H:i:s') . "\n";
}
if ($this->cache_enable) {
$cache = isset(\App::$cache) ? \App::$cache : new Cache_FileSystem();
$key = '/toolkit/' . md5(implode(",", $files));
$data = $cache->fetch($key);
if ($data) {
echo $data;
return true;
}
}
$surebert = $this->default_files;
$this->loaded_files = Array();
foreach ($files as $file) {
if ($binary) {
$surebert[] = $file;
} else {
$surebert[] = str_replace('.', '/', $file) . '.js';
}
}
ob_start();
foreach ($surebert as $file) {
echo $this->grabFile($file, $root);
}
$js = ob_get_clean();
if (isset($this->request->get['manifest'])) {
$m = $this->request->get['manifest'];
if ($m == 'js') {
return json_encode($this->loaded_files);
} else {
return print_r($this->loaded_files, 1);
}
}
if ($this->cache_enable) {
$cache->store($key, $js);
}
return $js;
} | php | protected function concatFiles($files = Array(), $version = '')
{
if ($files[0] == 'sb' && strstr(\sb\Gateway::$agent, 'MSIE')) {
array_unshift($files, 'js1_5');
}
$root = $this->toolkit_root;
$binary = preg_match("~\.(swf|gif|png)$~", $files[0], $match);
if ($binary) {
if ($match[1] == 'swf') {
header("Content-type: application/x-shockwave-flash");
} elseif ($match[1] == 'gif' || $match[1] == 'png') {
header("Content-type: image/" . $match[1]);
}
} else {
$this->addJavascriptHeaders();
echo '//v ' . date('m/d/Y H:i:s') . "\n";
}
if ($this->cache_enable) {
$cache = isset(\App::$cache) ? \App::$cache : new Cache_FileSystem();
$key = '/toolkit/' . md5(implode(",", $files));
$data = $cache->fetch($key);
if ($data) {
echo $data;
return true;
}
}
$surebert = $this->default_files;
$this->loaded_files = Array();
foreach ($files as $file) {
if ($binary) {
$surebert[] = $file;
} else {
$surebert[] = str_replace('.', '/', $file) . '.js';
}
}
ob_start();
foreach ($surebert as $file) {
echo $this->grabFile($file, $root);
}
$js = ob_get_clean();
if (isset($this->request->get['manifest'])) {
$m = $this->request->get['manifest'];
if ($m == 'js') {
return json_encode($this->loaded_files);
} else {
return print_r($this->loaded_files, 1);
}
}
if ($this->cache_enable) {
$cache->store($key, $js);
}
return $js;
} | [
"protected",
"function",
"concatFiles",
"(",
"$",
"files",
"=",
"Array",
"(",
")",
",",
"$",
"version",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"files",
"[",
"0",
"]",
"==",
"'sb'",
"&&",
"strstr",
"(",
"\\",
"sb",
"\\",
"Gateway",
"::",
"$",
"agent",
",",
"'MSIE'",
")",
")",
"{",
"array_unshift",
"(",
"$",
"files",
",",
"'js1_5'",
")",
";",
"}",
"$",
"root",
"=",
"$",
"this",
"->",
"toolkit_root",
";",
"$",
"binary",
"=",
"preg_match",
"(",
"\"~\\.(swf|gif|png)$~\"",
",",
"$",
"files",
"[",
"0",
"]",
",",
"$",
"match",
")",
";",
"if",
"(",
"$",
"binary",
")",
"{",
"if",
"(",
"$",
"match",
"[",
"1",
"]",
"==",
"'swf'",
")",
"{",
"header",
"(",
"\"Content-type: application/x-shockwave-flash\"",
")",
";",
"}",
"elseif",
"(",
"$",
"match",
"[",
"1",
"]",
"==",
"'gif'",
"||",
"$",
"match",
"[",
"1",
"]",
"==",
"'png'",
")",
"{",
"header",
"(",
"\"Content-type: image/\"",
".",
"$",
"match",
"[",
"1",
"]",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"addJavascriptHeaders",
"(",
")",
";",
"echo",
"'//v '",
".",
"date",
"(",
"'m/d/Y H:i:s'",
")",
".",
"\"\\n\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"cache_enable",
")",
"{",
"$",
"cache",
"=",
"isset",
"(",
"\\",
"App",
"::",
"$",
"cache",
")",
"?",
"\\",
"App",
"::",
"$",
"cache",
":",
"new",
"Cache_FileSystem",
"(",
")",
";",
"$",
"key",
"=",
"'/toolkit/'",
".",
"md5",
"(",
"implode",
"(",
"\",\"",
",",
"$",
"files",
")",
")",
";",
"$",
"data",
"=",
"$",
"cache",
"->",
"fetch",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"data",
")",
"{",
"echo",
"$",
"data",
";",
"return",
"true",
";",
"}",
"}",
"$",
"surebert",
"=",
"$",
"this",
"->",
"default_files",
";",
"$",
"this",
"->",
"loaded_files",
"=",
"Array",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"binary",
")",
"{",
"$",
"surebert",
"[",
"]",
"=",
"$",
"file",
";",
"}",
"else",
"{",
"$",
"surebert",
"[",
"]",
"=",
"str_replace",
"(",
"'.'",
",",
"'/'",
",",
"$",
"file",
")",
".",
"'.js'",
";",
"}",
"}",
"ob_start",
"(",
")",
";",
"foreach",
"(",
"$",
"surebert",
"as",
"$",
"file",
")",
"{",
"echo",
"$",
"this",
"->",
"grabFile",
"(",
"$",
"file",
",",
"$",
"root",
")",
";",
"}",
"$",
"js",
"=",
"ob_get_clean",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"request",
"->",
"get",
"[",
"'manifest'",
"]",
")",
")",
"{",
"$",
"m",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"[",
"'manifest'",
"]",
";",
"if",
"(",
"$",
"m",
"==",
"'js'",
")",
"{",
"return",
"json_encode",
"(",
"$",
"this",
"->",
"loaded_files",
")",
";",
"}",
"else",
"{",
"return",
"print_r",
"(",
"$",
"this",
"->",
"loaded_files",
",",
"1",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"cache_enable",
")",
"{",
"$",
"cache",
"->",
"store",
"(",
"$",
"key",
",",
"$",
"js",
")",
";",
"}",
"return",
"$",
"js",
";",
"}"
] | Concatenates the javascript/surebert files and turns them into cache if caching is enable
@param $files | [
"Concatenates",
"the",
"javascript",
"/",
"surebert",
"files",
"and",
"turns",
"them",
"into",
"cache",
"if",
"caching",
"is",
"enable"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/Toolkit.php#L61-L126 |
surebert/surebert-framework | src/sb/Controller/Toolkit.php | Toolkit.grabFile | protected function grabFile($file, $root)
{
$data = '';
if (is_file($root . '/' . $file)) {
$this->loaded_files[] = $file;
$file = $root . '/' . $file;
$data = file_get_contents($file);
if (!strstr($file, 'sb.js')) {
preg_match_all("~sb\.include\([\"'](.*?)[\"']~", $data, $includes);
if ($includes[1]) {
$precludes = '';
foreach ($includes[1] as $include) {
$include = \str_replace('.', '/', $include) . '.js';
if (!\in_array($include, $this->loaded_files)) {
$precludes .= $this->grabFile($include, $root);
}
}
$data = $precludes . "\n" . $data;
}
}
} else {
echo"\nthrow('ERROR: " . $file . " Surebert module \""
. \basename($file) . "\" could not be located by /surebert/load ');";
}
return $data;
} | php | protected function grabFile($file, $root)
{
$data = '';
if (is_file($root . '/' . $file)) {
$this->loaded_files[] = $file;
$file = $root . '/' . $file;
$data = file_get_contents($file);
if (!strstr($file, 'sb.js')) {
preg_match_all("~sb\.include\([\"'](.*?)[\"']~", $data, $includes);
if ($includes[1]) {
$precludes = '';
foreach ($includes[1] as $include) {
$include = \str_replace('.', '/', $include) . '.js';
if (!\in_array($include, $this->loaded_files)) {
$precludes .= $this->grabFile($include, $root);
}
}
$data = $precludes . "\n" . $data;
}
}
} else {
echo"\nthrow('ERROR: " . $file . " Surebert module \""
. \basename($file) . "\" could not be located by /surebert/load ');";
}
return $data;
} | [
"protected",
"function",
"grabFile",
"(",
"$",
"file",
",",
"$",
"root",
")",
"{",
"$",
"data",
"=",
"''",
";",
"if",
"(",
"is_file",
"(",
"$",
"root",
".",
"'/'",
".",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"loaded_files",
"[",
"]",
"=",
"$",
"file",
";",
"$",
"file",
"=",
"$",
"root",
".",
"'/'",
".",
"$",
"file",
";",
"$",
"data",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"if",
"(",
"!",
"strstr",
"(",
"$",
"file",
",",
"'sb.js'",
")",
")",
"{",
"preg_match_all",
"(",
"\"~sb\\.include\\([\\\"'](.*?)[\\\"']~\"",
",",
"$",
"data",
",",
"$",
"includes",
")",
";",
"if",
"(",
"$",
"includes",
"[",
"1",
"]",
")",
"{",
"$",
"precludes",
"=",
"''",
";",
"foreach",
"(",
"$",
"includes",
"[",
"1",
"]",
"as",
"$",
"include",
")",
"{",
"$",
"include",
"=",
"\\",
"str_replace",
"(",
"'.'",
",",
"'/'",
",",
"$",
"include",
")",
".",
"'.js'",
";",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"include",
",",
"$",
"this",
"->",
"loaded_files",
")",
")",
"{",
"$",
"precludes",
".=",
"$",
"this",
"->",
"grabFile",
"(",
"$",
"include",
",",
"$",
"root",
")",
";",
"}",
"}",
"$",
"data",
"=",
"$",
"precludes",
".",
"\"\\n\"",
".",
"$",
"data",
";",
"}",
"}",
"}",
"else",
"{",
"echo",
"\"\\nthrow('ERROR: \"",
".",
"$",
"file",
".",
"\" Surebert module \\\"\"",
".",
"\\",
"basename",
"(",
"$",
"file",
")",
".",
"\"\\\" could not be located by /surebert/load ');\"",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Grabs a file
@param string $file The file to load
@param string $root The root to load
@return string The file data | [
"Grabs",
"a",
"file"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/Toolkit.php#L134-L166 |
surebert/surebert-framework | src/sb/Controller/Toolkit.php | Toolkit.load | public function load()
{
$surebert = $this->request->args;
if (empty($surebert)) {
$surebert = Array('sb');
}
if ($surebert[0] == 'sb') {
echo "var sbBase = '/surebert/load/';\n";
}
echo $this->concatFiles($surebert);
} | php | public function load()
{
$surebert = $this->request->args;
if (empty($surebert)) {
$surebert = Array('sb');
}
if ($surebert[0] == 'sb') {
echo "var sbBase = '/surebert/load/';\n";
}
echo $this->concatFiles($surebert);
} | [
"public",
"function",
"load",
"(",
")",
"{",
"$",
"surebert",
"=",
"$",
"this",
"->",
"request",
"->",
"args",
";",
"if",
"(",
"empty",
"(",
"$",
"surebert",
")",
")",
"{",
"$",
"surebert",
"=",
"Array",
"(",
"'sb'",
")",
";",
"}",
"if",
"(",
"$",
"surebert",
"[",
"0",
"]",
"==",
"'sb'",
")",
"{",
"echo",
"\"var sbBase = '/surebert/load/';\\n\"",
";",
"}",
"echo",
"$",
"this",
"->",
"concatFiles",
"(",
"$",
"surebert",
")",
";",
"}"
] | Serves out individual files or sb by default. e.g. /surebert/load or /surebert/load/colors.rand
@servable true | [
"Serves",
"out",
"individual",
"files",
"or",
"sb",
"by",
"default",
".",
"e",
".",
"g",
".",
"/",
"surebert",
"/",
"load",
"or",
"/",
"surebert",
"/",
"load",
"/",
"colors",
".",
"rand"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/Toolkit.php#L185-L198 |
surebert/surebert-framework | src/sb/Controller/Toolkit.php | Toolkit.basic | public function basic()
{
if (!isset($this->request->get['noexpire'])) {
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 259200));
}
header("Content-type: application/x-javascript");
$version = '';
if (isset($this->request->get['v'])) {
if (is_numeric($this->request->get['v'])) {
$version = $this->request->get['v'];
}
}
/**
* This file loads multiple surebert toolkit modules and javascript files
* and puts them all into one large file for faster load times
*/
$surebert = Array(
"sb",
"browser.\$_GET",
"math.rand",
"cookies",
"browser.removeSelection",
"browser.getScrollPosition",
"browser.scrollTo",
"Element.prototype.show",
"Element.prototype.hide",
"Element.prototype.toggle",
"Element.prototype.getDimensions",
"Element.prototype.mv",
"Element.prototype.getPosition",
"Element.prototype.getNextSibling",
"Element.prototype.getPreviousSibling",
"Element.prototype.isOrHasParentOfClassName",
"Element.prototype.containsElement",
"Element.prototype.isWithin",
"Element.prototype.getContaining",
"Element.prototype.cssTransition",
"css.rules",
"swf",
"css.styleSheet",
"events.observer",
"events.classListener",
"events.idListener",
"widget.notifier",
"json.rpc2"
);
$protocol = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http';
$str = "if(!sbBase){var sbBase = '" . $protocol . "://" . \sb\Gateway::$http_host . "/surebert/load/';}\n";
$surebert = \array_merge($surebert, $this->request->args);
$str .= $this->concatFiles($surebert, $version);
return $str;
} | php | public function basic()
{
if (!isset($this->request->get['noexpire'])) {
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 259200));
}
header("Content-type: application/x-javascript");
$version = '';
if (isset($this->request->get['v'])) {
if (is_numeric($this->request->get['v'])) {
$version = $this->request->get['v'];
}
}
/**
* This file loads multiple surebert toolkit modules and javascript files
* and puts them all into one large file for faster load times
*/
$surebert = Array(
"sb",
"browser.\$_GET",
"math.rand",
"cookies",
"browser.removeSelection",
"browser.getScrollPosition",
"browser.scrollTo",
"Element.prototype.show",
"Element.prototype.hide",
"Element.prototype.toggle",
"Element.prototype.getDimensions",
"Element.prototype.mv",
"Element.prototype.getPosition",
"Element.prototype.getNextSibling",
"Element.prototype.getPreviousSibling",
"Element.prototype.isOrHasParentOfClassName",
"Element.prototype.containsElement",
"Element.prototype.isWithin",
"Element.prototype.getContaining",
"Element.prototype.cssTransition",
"css.rules",
"swf",
"css.styleSheet",
"events.observer",
"events.classListener",
"events.idListener",
"widget.notifier",
"json.rpc2"
);
$protocol = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http';
$str = "if(!sbBase){var sbBase = '" . $protocol . "://" . \sb\Gateway::$http_host . "/surebert/load/';}\n";
$surebert = \array_merge($surebert, $this->request->args);
$str .= $this->concatFiles($surebert, $version);
return $str;
} | [
"public",
"function",
"basic",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"request",
"->",
"get",
"[",
"'noexpire'",
"]",
")",
")",
"{",
"header",
"(",
"'Expires: '",
".",
"gmdate",
"(",
"'D, d M Y H:i:s \\G\\M\\T'",
",",
"time",
"(",
")",
"+",
"259200",
")",
")",
";",
"}",
"header",
"(",
"\"Content-type: application/x-javascript\"",
")",
";",
"$",
"version",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"request",
"->",
"get",
"[",
"'v'",
"]",
")",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"this",
"->",
"request",
"->",
"get",
"[",
"'v'",
"]",
")",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"[",
"'v'",
"]",
";",
"}",
"}",
"/**\n * This file loads multiple surebert toolkit modules and javascript files\n * and puts them all into one large file for faster load times\n */",
"$",
"surebert",
"=",
"Array",
"(",
"\"sb\"",
",",
"\"browser.\\$_GET\"",
",",
"\"math.rand\"",
",",
"\"cookies\"",
",",
"\"browser.removeSelection\"",
",",
"\"browser.getScrollPosition\"",
",",
"\"browser.scrollTo\"",
",",
"\"Element.prototype.show\"",
",",
"\"Element.prototype.hide\"",
",",
"\"Element.prototype.toggle\"",
",",
"\"Element.prototype.getDimensions\"",
",",
"\"Element.prototype.mv\"",
",",
"\"Element.prototype.getPosition\"",
",",
"\"Element.prototype.getNextSibling\"",
",",
"\"Element.prototype.getPreviousSibling\"",
",",
"\"Element.prototype.isOrHasParentOfClassName\"",
",",
"\"Element.prototype.containsElement\"",
",",
"\"Element.prototype.isWithin\"",
",",
"\"Element.prototype.getContaining\"",
",",
"\"Element.prototype.cssTransition\"",
",",
"\"css.rules\"",
",",
"\"swf\"",
",",
"\"css.styleSheet\"",
",",
"\"events.observer\"",
",",
"\"events.classListener\"",
",",
"\"events.idListener\"",
",",
"\"widget.notifier\"",
",",
"\"json.rpc2\"",
")",
";",
"$",
"protocol",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'SERVER_PORT'",
"]",
")",
"&&",
"$",
"_SERVER",
"[",
"'SERVER_PORT'",
"]",
"==",
"443",
"?",
"'https'",
":",
"'http'",
";",
"$",
"str",
"=",
"\"if(!sbBase){var sbBase = '\"",
".",
"$",
"protocol",
".",
"\"://\"",
".",
"\\",
"sb",
"\\",
"Gateway",
"::",
"$",
"http_host",
".",
"\"/surebert/load/';}\\n\"",
";",
"$",
"surebert",
"=",
"\\",
"array_merge",
"(",
"$",
"surebert",
",",
"$",
"this",
"->",
"request",
"->",
"args",
")",
";",
"$",
"str",
".=",
"$",
"this",
"->",
"concatFiles",
"(",
"$",
"surebert",
",",
"$",
"version",
")",
";",
"return",
"$",
"str",
";",
"}"
] | Serves out the most common surebert toolkit files
@servable true | [
"Serves",
"out",
"the",
"most",
"common",
"surebert",
"toolkit",
"files"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/Toolkit.php#L204-L261 |
tigron/skeleton-file | lib/Skeleton/File/Util.php | Util.limit_digits | public static function limit_digits($value, $round = true, $digits = 3) {
$integers = floor($value);
$decimals_needed = $digits - self::number_of_digits($integers);
if ($decimals_needed < 1) {
return $integers;
} else {
if ($round) {
$parts = explode('.', round($value, $decimals_needed));
$integers = $parts[0];
} else {
$parts = explode('.', $value);
}
if (isset($parts[1])) {
$decimals = $parts[1];
} else {
$decimals = 0;
}
$joined = $integers . '.' . $decimals . str_repeat('0', $digits);
return substr($joined, 0, $digits + 1);
}
} | php | public static function limit_digits($value, $round = true, $digits = 3) {
$integers = floor($value);
$decimals_needed = $digits - self::number_of_digits($integers);
if ($decimals_needed < 1) {
return $integers;
} else {
if ($round) {
$parts = explode('.', round($value, $decimals_needed));
$integers = $parts[0];
} else {
$parts = explode('.', $value);
}
if (isset($parts[1])) {
$decimals = $parts[1];
} else {
$decimals = 0;
}
$joined = $integers . '.' . $decimals . str_repeat('0', $digits);
return substr($joined, 0, $digits + 1);
}
} | [
"public",
"static",
"function",
"limit_digits",
"(",
"$",
"value",
",",
"$",
"round",
"=",
"true",
",",
"$",
"digits",
"=",
"3",
")",
"{",
"$",
"integers",
"=",
"floor",
"(",
"$",
"value",
")",
";",
"$",
"decimals_needed",
"=",
"$",
"digits",
"-",
"self",
"::",
"number_of_digits",
"(",
"$",
"integers",
")",
";",
"if",
"(",
"$",
"decimals_needed",
"<",
"1",
")",
"{",
"return",
"$",
"integers",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"round",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"round",
"(",
"$",
"value",
",",
"$",
"decimals_needed",
")",
")",
";",
"$",
"integers",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"value",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
")",
"{",
"$",
"decimals",
"=",
"$",
"parts",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"decimals",
"=",
"0",
";",
"}",
"$",
"joined",
"=",
"$",
"integers",
".",
"'.'",
".",
"$",
"decimals",
".",
"str_repeat",
"(",
"'0'",
",",
"$",
"digits",
")",
";",
"return",
"substr",
"(",
"$",
"joined",
",",
"0",
",",
"$",
"digits",
"+",
"1",
")",
";",
"}",
"}"
] | Formats a number to a minimum amount of digits.
In other words, makes sure that a number has at least $digits on it, even if
that means introducing redundant decimal zeroes at the end, or rounding the
ones present exceeding the $digits count when combined with the integers.
This is primarily useful for generating human-friendly numbers.
@access public
@param double $value
@param bool $round
@param int $digits | [
"Formats",
"a",
"number",
"to",
"a",
"minimum",
"amount",
"of",
"digits",
".",
"In",
"other",
"words",
"makes",
"sure",
"that",
"a",
"number",
"has",
"at",
"least",
"$digits",
"on",
"it",
"even",
"if",
"that",
"means",
"introducing",
"redundant",
"decimal",
"zeroes",
"at",
"the",
"end",
"or",
"rounding",
"the",
"ones",
"present",
"exceeding",
"the",
"$digits",
"count",
"when",
"combined",
"with",
"the",
"integers",
".",
"This",
"is",
"primarily",
"useful",
"for",
"generating",
"human",
"-",
"friendly",
"numbers",
"."
] | train | https://github.com/tigron/skeleton-file/blob/97978d49f179f07c76380ddc8919b8a7d56dee61/lib/Skeleton/File/Util.php#L44-L69 |
tigron/skeleton-file | lib/Skeleton/File/Util.php | Util.sanitize_filename | public static function sanitize_filename($filename, $max_length = 50) {
$parts = pathinfo($filename);
$slugify = new \Cocur\Slugify\Slugify();
$basename = $slugify->slugify($parts['filename']);
if (isset($parts['extension'])) {
$extension = $slugify->slugify($parts['extension']);
$filename = substr($basename, 0, $max_length-strlen($extension)) . '.' . $extension;
} else {
$filename = $basename;
}
return $filename;
} | php | public static function sanitize_filename($filename, $max_length = 50) {
$parts = pathinfo($filename);
$slugify = new \Cocur\Slugify\Slugify();
$basename = $slugify->slugify($parts['filename']);
if (isset($parts['extension'])) {
$extension = $slugify->slugify($parts['extension']);
$filename = substr($basename, 0, $max_length-strlen($extension)) . '.' . $extension;
} else {
$filename = $basename;
}
return $filename;
} | [
"public",
"static",
"function",
"sanitize_filename",
"(",
"$",
"filename",
",",
"$",
"max_length",
"=",
"50",
")",
"{",
"$",
"parts",
"=",
"pathinfo",
"(",
"$",
"filename",
")",
";",
"$",
"slugify",
"=",
"new",
"\\",
"Cocur",
"\\",
"Slugify",
"\\",
"Slugify",
"(",
")",
";",
"$",
"basename",
"=",
"$",
"slugify",
"->",
"slugify",
"(",
"$",
"parts",
"[",
"'filename'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"parts",
"[",
"'extension'",
"]",
")",
")",
"{",
"$",
"extension",
"=",
"$",
"slugify",
"->",
"slugify",
"(",
"$",
"parts",
"[",
"'extension'",
"]",
")",
";",
"$",
"filename",
"=",
"substr",
"(",
"$",
"basename",
",",
"0",
",",
"$",
"max_length",
"-",
"strlen",
"(",
"$",
"extension",
")",
")",
".",
"'.'",
".",
"$",
"extension",
";",
"}",
"else",
"{",
"$",
"filename",
"=",
"$",
"basename",
";",
"}",
"return",
"$",
"filename",
";",
"}"
] | Sanitize filenames
@access public
@param string $name
@param string $max_length
@return string $name | [
"Sanitize",
"filenames"
] | train | https://github.com/tigron/skeleton-file/blob/97978d49f179f07c76380ddc8919b8a7d56dee61/lib/Skeleton/File/Util.php#L79-L90 |
tigron/skeleton-file | lib/Skeleton/File/Util.php | Util.detect_mime_type | public static function detect_mime_type($path) {
$handle = finfo_open(FILEINFO_MIME);
$mime_type = finfo_file($handle, $path);
if (strpos($mime_type, ';')) {
$mime_type = preg_replace('/;.*/', ' ', $mime_type);
}
return trim($mime_type);
} | php | public static function detect_mime_type($path) {
$handle = finfo_open(FILEINFO_MIME);
$mime_type = finfo_file($handle, $path);
if (strpos($mime_type, ';')) {
$mime_type = preg_replace('/;.*/', ' ', $mime_type);
}
return trim($mime_type);
} | [
"public",
"static",
"function",
"detect_mime_type",
"(",
"$",
"path",
")",
"{",
"$",
"handle",
"=",
"finfo_open",
"(",
"FILEINFO_MIME",
")",
";",
"$",
"mime_type",
"=",
"finfo_file",
"(",
"$",
"handle",
",",
"$",
"path",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"mime_type",
",",
"';'",
")",
")",
"{",
"$",
"mime_type",
"=",
"preg_replace",
"(",
"'/;.*/'",
",",
"' '",
",",
"$",
"mime_type",
")",
";",
"}",
"return",
"trim",
"(",
"$",
"mime_type",
")",
";",
"}"
] | Get the mime_type of a file
@access public
@param string $file The path to the file
@return string $mime_type | [
"Get",
"the",
"mime_type",
"of",
"a",
"file"
] | train | https://github.com/tigron/skeleton-file/blob/97978d49f179f07c76380ddc8919b8a7d56dee61/lib/Skeleton/File/Util.php#L99-L108 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.