repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/PlayersBundle/Plugins/Player.php
Player.updatePlayer
protected function updatePlayer($player) { $time = time(); $upTime = $time - $this->playerLastUpTime[$player->getLogin()]; $this->playerLastUpTime[$player->getLogin()] = $time; $player->setOnlineTime($player->getOnlineTime() + $upTime); }
php
protected function updatePlayer($player) { $time = time(); $upTime = $time - $this->playerLastUpTime[$player->getLogin()]; $this->playerLastUpTime[$player->getLogin()] = $time; $player->setOnlineTime($player->getOnlineTime() + $upTime); }
[ "protected", "function", "updatePlayer", "(", "$", "player", ")", "{", "$", "time", "=", "time", "(", ")", ";", "$", "upTime", "=", "$", "time", "-", "$", "this", "->", "playerLastUpTime", "[", "$", "player", "->", "getLogin", "(", ")", "]", ";", "...
Update player information. @param PlayerModel $player Login of the player.
[ "Update", "player", "information", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Plugins/Player.php#L145-L152
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/PlayersBundle/Plugins/Player.php
Player.getPlayer
public function getPlayer($login) { if (isset($this->loggedInPlayers[$login])) { return $this->loggedInPlayers[$login]; } return $this->playerQueryBuilder->findByLogin($login); }
php
public function getPlayer($login) { if (isset($this->loggedInPlayers[$login])) { return $this->loggedInPlayers[$login]; } return $this->playerQueryBuilder->findByLogin($login); }
[ "public", "function", "getPlayer", "(", "$", "login", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "loggedInPlayers", "[", "$", "login", "]", ")", ")", "{", "return", "$", "this", "->", "loggedInPlayers", "[", "$", "login", "]", ";", "}", ...
Get data on a player. @param string $login Login of the player. @return PlayerModel
[ "Get", "data", "on", "a", "player", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Plugins/Player.php#L161-L168
train
Malwarebytes/Altamira
src/Altamira/ChartRenderer.php
ChartRenderer.render
public static function render( Chart $chart, array $styleOptions = array() ) { if ( empty( self::$rendererChain ) ) { self::pushRenderer( '\Altamira\ChartRenderer\DefaultRenderer' ); } $outputString = ''; for ( $i = count( self::$rendererChain ) - 1; $i >= 0; $i-- ) { $renderer = self::$rendererChain[$i]; $outputString .= call_user_func_array( array( $renderer, 'preRender' ), array( $chart, $styleOptions ) ); } for ( $i = 0; $i < count( self::$rendererChain ); $i++ ) { $renderer = self::$rendererChain[$i]; $outputString .= call_user_func_array( array( $renderer, 'postRender' ), array( $chart, $styleOptions ) ); } return $outputString; }
php
public static function render( Chart $chart, array $styleOptions = array() ) { if ( empty( self::$rendererChain ) ) { self::pushRenderer( '\Altamira\ChartRenderer\DefaultRenderer' ); } $outputString = ''; for ( $i = count( self::$rendererChain ) - 1; $i >= 0; $i-- ) { $renderer = self::$rendererChain[$i]; $outputString .= call_user_func_array( array( $renderer, 'preRender' ), array( $chart, $styleOptions ) ); } for ( $i = 0; $i < count( self::$rendererChain ); $i++ ) { $renderer = self::$rendererChain[$i]; $outputString .= call_user_func_array( array( $renderer, 'postRender' ), array( $chart, $styleOptions ) ); } return $outputString; }
[ "public", "static", "function", "render", "(", "Chart", "$", "chart", ",", "array", "$", "styleOptions", "=", "array", "(", ")", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "rendererChain", ")", ")", "{", "self", "::", "pushRenderer", "(", ...
Renders a single chart by passing it through the renderer chain @param Chart $chart @param array $styleOptions @return string the output generated from renders
[ "Renders", "a", "single", "chart", "by", "passing", "it", "through", "the", "renderer", "chain" ]
38e320f68070d7a0b6902c6c3f904995d4a8cdfc
https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/ChartRenderer.php#L53-L74
train
Malwarebytes/Altamira
src/Altamira/ChartRenderer.php
ChartRenderer.pushRenderer
public static function pushRenderer( $renderer ) { if (! in_array( 'Altamira\ChartRenderer\RendererInterface', class_implements( $renderer ) ) ) { throw new \UnexpectedValueException( "Renderer must be instance of or string name of a class implementing RendererInterface" ); } array_push( self::$rendererChain, $renderer ); return self::getInstance(); }
php
public static function pushRenderer( $renderer ) { if (! in_array( 'Altamira\ChartRenderer\RendererInterface', class_implements( $renderer ) ) ) { throw new \UnexpectedValueException( "Renderer must be instance of or string name of a class implementing RendererInterface" ); } array_push( self::$rendererChain, $renderer ); return self::getInstance(); }
[ "public", "static", "function", "pushRenderer", "(", "$", "renderer", ")", "{", "if", "(", "!", "in_array", "(", "'Altamira\\ChartRenderer\\RendererInterface'", ",", "class_implements", "(", "$", "renderer", ")", ")", ")", "{", "throw", "new", "\\", "UnexpectedV...
Adds a renderer to the end of the renderer chain @param string $renderer @throws \UnexpectedValueException @return \Altamira\ChartRenderer
[ "Adds", "a", "renderer", "to", "the", "end", "of", "the", "renderer", "chain" ]
38e320f68070d7a0b6902c6c3f904995d4a8cdfc
https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/ChartRenderer.php#L82-L91
train
Malwarebytes/Altamira
src/Altamira/ChartRenderer.php
ChartRenderer.unshiftRenderer
public static function unshiftRenderer( $renderer ) { if (! in_array( 'Altamira\ChartRenderer\RendererInterface', class_implements( $renderer ) ) ) { throw new \UnexpectedValueException( "Renderer must be instance of or string name of a class implementing RendererInterface" ); } array_unshift( self::$rendererChain, $renderer ); return self::getInstance(); }
php
public static function unshiftRenderer( $renderer ) { if (! in_array( 'Altamira\ChartRenderer\RendererInterface', class_implements( $renderer ) ) ) { throw new \UnexpectedValueException( "Renderer must be instance of or string name of a class implementing RendererInterface" ); } array_unshift( self::$rendererChain, $renderer ); return self::getInstance(); }
[ "public", "static", "function", "unshiftRenderer", "(", "$", "renderer", ")", "{", "if", "(", "!", "in_array", "(", "'Altamira\\ChartRenderer\\RendererInterface'", ",", "class_implements", "(", "$", "renderer", ")", ")", ")", "{", "throw", "new", "\\", "Unexpect...
Prepends a renderer to the beginning of renderer chain @param string $renderer @throws \UnexpectedValueException @return \Altamira\ChartRenderer
[ "Prepends", "a", "renderer", "to", "the", "beginning", "of", "renderer", "chain" ]
38e320f68070d7a0b6902c6c3f904995d4a8cdfc
https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/ChartRenderer.php#L99-L108
train
TheBnl/event-tickets
code/model/user-fields/UserField.php
UserField.createField
public function createField($fieldName, $defaultValue = null) { $fieldType = $this->fieldType; $field = $fieldType::create($fieldName, $this->Title, $defaultValue); $field->addExtraClass($this->ExtraClass); $this->extend('updateCreateField', $field); return $field; }
php
public function createField($fieldName, $defaultValue = null) { $fieldType = $this->fieldType; $field = $fieldType::create($fieldName, $this->Title, $defaultValue); $field->addExtraClass($this->ExtraClass); $this->extend('updateCreateField', $field); return $field; }
[ "public", "function", "createField", "(", "$", "fieldName", ",", "$", "defaultValue", "=", "null", ")", "{", "$", "fieldType", "=", "$", "this", "->", "fieldType", ";", "$", "field", "=", "$", "fieldType", "::", "create", "(", "$", "fieldName", ",", "$...
Create the actual field Overwrite this on the field subclass @param $fieldName string Created by the AttendeeField @param $defaultValue string Set a default value @return FormField
[ "Create", "the", "actual", "field", "Overwrite", "this", "on", "the", "field", "subclass" ]
d18db4146a141795fd50689057130a6fd41ac397
https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/user-fields/UserField.php#L187-L194
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/Core/Plugins/Gui/ManialinkFactory.php
ManialinkFactory.create
public function create($group) { if (is_string($group)) { $group = $this->groupFactory->createForPlayer($group); } else { if (is_array($group)) { $group = $this->groupFactory->createForPlayers($group); } } if (!is_null($this->guiHandler->getManialink($group, $this))) { $this->update($group); return $group; } $ml = $this->createManialink($group); $this->guiHandler->addToDisplay($ml, $this); $this->createContent($ml); $this->updateContent($ml); return $group; }
php
public function create($group) { if (is_string($group)) { $group = $this->groupFactory->createForPlayer($group); } else { if (is_array($group)) { $group = $this->groupFactory->createForPlayers($group); } } if (!is_null($this->guiHandler->getManialink($group, $this))) { $this->update($group); return $group; } $ml = $this->createManialink($group); $this->guiHandler->addToDisplay($ml, $this); $this->createContent($ml); $this->updateContent($ml); return $group; }
[ "public", "function", "create", "(", "$", "group", ")", "{", "if", "(", "is_string", "(", "$", "group", ")", ")", "{", "$", "group", "=", "$", "this", "->", "groupFactory", "->", "createForPlayer", "(", "$", "group", ")", ";", "}", "else", "{", "if...
Creates a new manialink. @param string|array|Group $group @return Group
[ "Creates", "a", "new", "manialink", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/Gui/ManialinkFactory.php#L104-L128
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/Core/Plugins/Gui/ManialinkFactory.php
ManialinkFactory.update
public function update($group) { if (is_string($group)) { $group = $this->groupFactory->createForPlayer($group); } else { if (is_array($group)) { $group = $this->groupFactory->createForPlayers($group); } } $ml = $this->guiHandler->getManialink($group, $this); if ($ml) { $this->actionFactory->destroyNotPermanentActions($ml); if ($ml instanceof Window) { $ml->busyCounter += 1; if ($ml->isBusy && $ml->busyCounter > 1) { $ml->setBusy(false); } } $this->updateContent($ml); $this->guiHandler->addToDisplay($ml, $this); } }
php
public function update($group) { if (is_string($group)) { $group = $this->groupFactory->createForPlayer($group); } else { if (is_array($group)) { $group = $this->groupFactory->createForPlayers($group); } } $ml = $this->guiHandler->getManialink($group, $this); if ($ml) { $this->actionFactory->destroyNotPermanentActions($ml); if ($ml instanceof Window) { $ml->busyCounter += 1; if ($ml->isBusy && $ml->busyCounter > 1) { $ml->setBusy(false); } } $this->updateContent($ml); $this->guiHandler->addToDisplay($ml, $this); } }
[ "public", "function", "update", "(", "$", "group", ")", "{", "if", "(", "is_string", "(", "$", "group", ")", ")", "{", "$", "group", "=", "$", "this", "->", "groupFactory", "->", "createForPlayer", "(", "$", "group", ")", ";", "}", "else", "{", "if...
Request an update for manialink. @param string|array|Group $group
[ "Request", "an", "update", "for", "manialink", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/Gui/ManialinkFactory.php#L135-L158
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/Core/Plugins/Gui/ManialinkFactory.php
ManialinkFactory.destroy
public function destroy(Group $group) { $ml = $this->guiHandler->getManialink($group, $this); if ($ml) { $this->guiHandler->addToHide($ml, $this); } }
php
public function destroy(Group $group) { $ml = $this->guiHandler->getManialink($group, $this); if ($ml) { $this->guiHandler->addToHide($ml, $this); } }
[ "public", "function", "destroy", "(", "Group", "$", "group", ")", "{", "$", "ml", "=", "$", "this", "->", "guiHandler", "->", "getManialink", "(", "$", "group", ",", "$", "this", ")", ";", "if", "(", "$", "ml", ")", "{", "$", "this", "->", "guiHa...
Hides and frees manialink resources @param Group $group
[ "Hides", "and", "frees", "manialink", "resources" ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/Gui/ManialinkFactory.php#L188-L194
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/Core/Plugins/Gui/ManialinkFactory.php
ManialinkFactory.createManialink
protected function createManialink(Group $group) { $className = $this->className; return new $className($this, $group, $this->name, $this->sizeX, $this->sizeY, $this->posX, $this->posY); }
php
protected function createManialink(Group $group) { $className = $this->className; return new $className($this, $group, $this->name, $this->sizeX, $this->sizeY, $this->posX, $this->posY); }
[ "protected", "function", "createManialink", "(", "Group", "$", "group", ")", "{", "$", "className", "=", "$", "this", "->", "className", ";", "return", "new", "$", "className", "(", "$", "this", ",", "$", "group", ",", "$", "this", "->", "name", ",", ...
Create manialink object for user group. @param Group $group @return Manialink
[ "Create", "manialink", "object", "for", "user", "group", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/Gui/ManialinkFactory.php#L203-L208
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Bundle/MxKarma/Services/MxKarmaService.php
MxKarmaService.connect
public function connect($serverLogin, $apikey) { $this->apiKey = $apikey; $this->serverLogin = $serverLogin; if (empty($this->apiKey)) { $this->console->writeln('MxKarma error: You need to define a api key'); return; } if (empty($this->serverLogin)) { $this->console->writeln('MxKarma error: You need to define server login'); return; } $params = [ "serverLogin" => $serverLogin, "applicationIdentifier" => "eXpansion v ".AbstractApplication::EXPANSION_VERSION, "testMode" => "false", ]; $this->console->writeln('> MxKarma attempting to connect...'); $this->http->get( $this->buildUrl( "startSession", $params), [$this, "xConnect"] ); }
php
public function connect($serverLogin, $apikey) { $this->apiKey = $apikey; $this->serverLogin = $serverLogin; if (empty($this->apiKey)) { $this->console->writeln('MxKarma error: You need to define a api key'); return; } if (empty($this->serverLogin)) { $this->console->writeln('MxKarma error: You need to define server login'); return; } $params = [ "serverLogin" => $serverLogin, "applicationIdentifier" => "eXpansion v ".AbstractApplication::EXPANSION_VERSION, "testMode" => "false", ]; $this->console->writeln('> MxKarma attempting to connect...'); $this->http->get( $this->buildUrl( "startSession", $params), [$this, "xConnect"] ); }
[ "public", "function", "connect", "(", "$", "serverLogin", ",", "$", "apikey", ")", "{", "$", "this", "->", "apiKey", "=", "$", "apikey", ";", "$", "this", "->", "serverLogin", "=", "$", "serverLogin", ";", "if", "(", "empty", "(", "$", "this", "->", ...
connect to MX karma @param string $serverLogin @param string $apikey @return void
[ "connect", "to", "MX", "karma" ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/MxKarma/Services/MxKarmaService.php#L117-L146
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Bundle/MxKarma/Services/MxKarmaService.php
MxKarmaService.loadVotes
public function loadVotes($players = array(), $getVotesOnly = false) { if (!$this->connected) { $this->console->writeln('> MxKarma trying to load votes when not connected: $ff0aborting!'); return; } $this->console->writeln('> MxKarma attempting to load votes...'); $params = array("sessionKey" => $this->sessionKey); $postData = [ "gamemode" => $this->getGameMode(), "titleid" => $this->gameDataStorage->getVersion()->titleId, "mapuid" => $this->mapStorage->getCurrentMap()->uId, "getvotesonly" => $getVotesOnly, "playerlogins" => $players, ]; $this->http->post( $this->buildUrl("getMapRating", $params), json_encode($postData), array($this, "xGetRatings"), [], $this->options ); }
php
public function loadVotes($players = array(), $getVotesOnly = false) { if (!$this->connected) { $this->console->writeln('> MxKarma trying to load votes when not connected: $ff0aborting!'); return; } $this->console->writeln('> MxKarma attempting to load votes...'); $params = array("sessionKey" => $this->sessionKey); $postData = [ "gamemode" => $this->getGameMode(), "titleid" => $this->gameDataStorage->getVersion()->titleId, "mapuid" => $this->mapStorage->getCurrentMap()->uId, "getvotesonly" => $getVotesOnly, "playerlogins" => $players, ]; $this->http->post( $this->buildUrl("getMapRating", $params), json_encode($postData), array($this, "xGetRatings"), [], $this->options ); }
[ "public", "function", "loadVotes", "(", "$", "players", "=", "array", "(", ")", ",", "$", "getVotesOnly", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "connected", ")", "{", "$", "this", "->", "console", "->", "writeln", "(", "'> MxKarm...
loads votes from server @param array $players @param bool $getVotesOnly
[ "loads", "votes", "from", "server" ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/MxKarma/Services/MxKarmaService.php#L209-L234
train
vube/php-filesystem
src/Vube/FileSystem/Gzip.php
Gzip.zip
public function zip($sSourceFile, $sDestinationFile=null) { if($sDestinationFile === null) $sDestinationFile = $this->getDefaultDestinationFilename($sSourceFile); if(! ($fh = fopen($sSourceFile, 'rb'))) throw new FileOpenException($sSourceFile); if(! ($zp = gzopen($sDestinationFile, 'wb9'))) throw new FileOpenException($sDestinationFile); while(! feof($fh)) { $data = fread($fh, static::READ_SIZE); if(false === $data) throw new FileReadException($sSourceFile); $sz = strlen($data); if($sz !== gzwrite($zp, $data, $sz)) throw new FileWriteException($sDestinationFile); } gzclose($zp); fclose($fh); return $sDestinationFile; }
php
public function zip($sSourceFile, $sDestinationFile=null) { if($sDestinationFile === null) $sDestinationFile = $this->getDefaultDestinationFilename($sSourceFile); if(! ($fh = fopen($sSourceFile, 'rb'))) throw new FileOpenException($sSourceFile); if(! ($zp = gzopen($sDestinationFile, 'wb9'))) throw new FileOpenException($sDestinationFile); while(! feof($fh)) { $data = fread($fh, static::READ_SIZE); if(false === $data) throw new FileReadException($sSourceFile); $sz = strlen($data); if($sz !== gzwrite($zp, $data, $sz)) throw new FileWriteException($sDestinationFile); } gzclose($zp); fclose($fh); return $sDestinationFile; }
[ "public", "function", "zip", "(", "$", "sSourceFile", ",", "$", "sDestinationFile", "=", "null", ")", "{", "if", "(", "$", "sDestinationFile", "===", "null", ")", "$", "sDestinationFile", "=", "$", "this", "->", "getDefaultDestinationFilename", "(", "$", "sS...
Gzip a file @param string $sSourceFile Path to the source file @param string $sDestinationFile [optional] Path to save the zip contents. <p> If NULL, the default value is $this->getDefaultDestinationFilename($sSourceFile) </p> @return string Path to the saved zip file @throws FileOpenException if there is any error opening the source or output files @throws FileReadException if there is an error reading the source file @throws FileWriteException if there is an error writing the output file
[ "Gzip", "a", "file" ]
147513e8c3809a1d9d947d2753780c0671cc3194
https://github.com/vube/php-filesystem/blob/147513e8c3809a1d9d947d2753780c0671cc3194/src/Vube/FileSystem/Gzip.php#L41-L67
train
mridang/pearify
src/Pearify/Command.php
Params.error
private function error(OutputInterface $output, $message, $args = array()) { /** @noinspection HtmlUnknownTag */ $output->writeln('<error>' . sprintf($message, $args) . '</error>'); exit(0); }
php
private function error(OutputInterface $output, $message, $args = array()) { /** @noinspection HtmlUnknownTag */ $output->writeln('<error>' . sprintf($message, $args) . '</error>'); exit(0); }
[ "private", "function", "error", "(", "OutputInterface", "$", "output", ",", "$", "message", ",", "$", "args", "=", "array", "(", ")", ")", "{", "/** @noinspection HtmlUnknownTag */", "$", "output", "->", "writeln", "(", "'<error>'", ".", "sprintf", "(", "$",...
Prints an info log message to the console with the warning message colour @param $output @param $message string the log message @param array $args the array of format parameters
[ "Prints", "an", "info", "log", "message", "to", "the", "console", "with", "the", "warning", "message", "colour" ]
7bc0710beb4165164e07f88b456de47cad8b3002
https://github.com/mridang/pearify/blob/7bc0710beb4165164e07f88b456de47cad8b3002/src/Pearify/Command.php#L75-L80
train
BenGorUser/UserBundle
src/BenGorUser/UserBundle/Controller/Api/RequestRememberPasswordController.php
RequestRememberPasswordController.requestRememberPasswordAction
public function requestRememberPasswordAction(Request $request, $userClass) { $form = $this->get('form.factory')->createNamedBuilder('', RequestRememberPasswordType::class, null, [ 'csrf_protection' => false, ])->getForm(); $form->handleRequest($request); if ($form->isValid()) { try { $this->get('bengor_user.' . $userClass . '.api_command_bus')->handle( $form->getData() ); return new JsonResponse(); } catch (UserDoesNotExistException $exception) { return new JsonResponse( sprintf( 'The "%s" user email does not exist ', $form->getData()->email() ), 400 ); } } return new JsonResponse(FormErrorSerializer::errors($form), 400); }
php
public function requestRememberPasswordAction(Request $request, $userClass) { $form = $this->get('form.factory')->createNamedBuilder('', RequestRememberPasswordType::class, null, [ 'csrf_protection' => false, ])->getForm(); $form->handleRequest($request); if ($form->isValid()) { try { $this->get('bengor_user.' . $userClass . '.api_command_bus')->handle( $form->getData() ); return new JsonResponse(); } catch (UserDoesNotExistException $exception) { return new JsonResponse( sprintf( 'The "%s" user email does not exist ', $form->getData()->email() ), 400 ); } } return new JsonResponse(FormErrorSerializer::errors($form), 400); }
[ "public", "function", "requestRememberPasswordAction", "(", "Request", "$", "request", ",", "$", "userClass", ")", "{", "$", "form", "=", "$", "this", "->", "get", "(", "'form.factory'", ")", "->", "createNamedBuilder", "(", "''", ",", "RequestRememberPasswordTy...
Request remember user password action. @param Request $request The request @param string $userClass Extra parameter that contains the user type @return \Symfony\Component\HttpFoundation\JsonResponse
[ "Request", "remember", "user", "password", "action", "." ]
a6d0173496c269a6c80e1319d42eaed4b3bbbd4a
https://github.com/BenGorUser/UserBundle/blob/a6d0173496c269a6c80e1319d42eaed4b3bbbd4a/src/BenGorUser/UserBundle/Controller/Api/RequestRememberPasswordController.php#L37-L63
train
mrclay/UserlandSession
src/UserlandSession/Session.php
Session.get
public function get($key, $default = null) { if (!$this->id) { throw new Exception('Cannot use get without active session.'); } return array_key_exists($key, $this->data) ? $this->data[$key] : $default; }
php
public function get($key, $default = null) { if (!$this->id) { throw new Exception('Cannot use get without active session.'); } return array_key_exists($key, $this->data) ? $this->data[$key] : $default; }
[ "public", "function", "get", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "id", ")", "{", "throw", "new", "Exception", "(", "'Cannot use get without active session.'", ")", ";", "}", "return", "array_key...
Get a value from the session @param string $key @param mixed $default @return mixed @throws Exception
[ "Get", "a", "value", "from", "the", "session" ]
deabb1b487294efbd0bcb79ca83e6dab56036e45
https://github.com/mrclay/UserlandSession/blob/deabb1b487294efbd0bcb79ca83e6dab56036e45/src/UserlandSession/Session.php#L130-L136
train
mrclay/UserlandSession
src/UserlandSession/Session.php
Session.id
public function id($id = null) { if ($id) { if (!$this->isValidId($id)) { throw new \InvalidArgumentException('$id may contain only [a-zA-Z0-9-_]'); } if ($this->id) { throw new Exception('Cannot set id while session is active'); } $this->requestedId = $id; } return $this->id; }
php
public function id($id = null) { if ($id) { if (!$this->isValidId($id)) { throw new \InvalidArgumentException('$id may contain only [a-zA-Z0-9-_]'); } if ($this->id) { throw new Exception('Cannot set id while session is active'); } $this->requestedId = $id; } return $this->id; }
[ "public", "function", "id", "(", "$", "id", "=", "null", ")", "{", "if", "(", "$", "id", ")", "{", "if", "(", "!", "$", "this", "->", "isValidId", "(", "$", "id", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$id may conta...
Get the session ID, or request an ID to be used when the session begins. @param string $id Requested session id. May contain only [a-zA-Z0-9-_] @return string ('' means there is no active session) @throws \InvalidArgumentException|Exception
[ "Get", "the", "session", "ID", "or", "request", "an", "ID", "to", "be", "used", "when", "the", "session", "begins", "." ]
deabb1b487294efbd0bcb79ca83e6dab56036e45
https://github.com/mrclay/UserlandSession/blob/deabb1b487294efbd0bcb79ca83e6dab56036e45/src/UserlandSession/Session.php#L207-L219
train
mrclay/UserlandSession
src/UserlandSession/Session.php
Session.persistedDataExists
public function persistedDataExists($id) { if (!$this->id) { $this->handler->open($this->savePath, $this->name); } $ret = (bool)$this->handler->read($id); if (!$this->id) { $this->handler->close(); } return $ret; }
php
public function persistedDataExists($id) { if (!$this->id) { $this->handler->open($this->savePath, $this->name); } $ret = (bool)$this->handler->read($id); if (!$this->id) { $this->handler->close(); } return $ret; }
[ "public", "function", "persistedDataExists", "(", "$", "id", ")", "{", "if", "(", "!", "$", "this", "->", "id", ")", "{", "$", "this", "->", "handler", "->", "open", "(", "$", "this", "->", "savePath", ",", "$", "this", "->", "name", ")", ";", "}...
Does the storage handler have data under this ID? @param string $id @return bool
[ "Does", "the", "storage", "handler", "have", "data", "under", "this", "ID?" ]
deabb1b487294efbd0bcb79ca83e6dab56036e45
https://github.com/mrclay/UserlandSession/blob/deabb1b487294efbd0bcb79ca83e6dab56036e45/src/UserlandSession/Session.php#L271-L281
train
mrclay/UserlandSession
src/UserlandSession/Session.php
Session.destroy
public function destroy($removeCookie = false) { if ($this->id) { if ($removeCookie) { $this->removeCookie(); } $this->handler->destroy($this->id); $this->handler->close(); $this->id = ''; $this->data = null; return true; } return false; }
php
public function destroy($removeCookie = false) { if ($this->id) { if ($removeCookie) { $this->removeCookie(); } $this->handler->destroy($this->id); $this->handler->close(); $this->id = ''; $this->data = null; return true; } return false; }
[ "public", "function", "destroy", "(", "$", "removeCookie", "=", "false", ")", "{", "if", "(", "$", "this", "->", "id", ")", "{", "if", "(", "$", "removeCookie", ")", "{", "$", "this", "->", "removeCookie", "(", ")", ";", "}", "$", "this", "->", "...
Stop the session and destroy its persisted data. @param bool $removeCookie Remove the session cookie, too? @return bool success
[ "Stop", "the", "session", "and", "destroy", "its", "persisted", "data", "." ]
deabb1b487294efbd0bcb79ca83e6dab56036e45
https://github.com/mrclay/UserlandSession/blob/deabb1b487294efbd0bcb79ca83e6dab56036e45/src/UserlandSession/Session.php#L379-L392
train
mrclay/UserlandSession
src/UserlandSession/Session.php
Session.regenerateId
public function regenerateId($deleteOldSession = false) { if (headers_sent() || !$this->id) { return false; } $oldId = $this->id; $this->id = IdGenerator::generateSessionId($this->idLength); $this->setCookie($this->name, $this->id); if ($oldId && $deleteOldSession) { $this->handler->destroy($oldId); } return true; }
php
public function regenerateId($deleteOldSession = false) { if (headers_sent() || !$this->id) { return false; } $oldId = $this->id; $this->id = IdGenerator::generateSessionId($this->idLength); $this->setCookie($this->name, $this->id); if ($oldId && $deleteOldSession) { $this->handler->destroy($oldId); } return true; }
[ "public", "function", "regenerateId", "(", "$", "deleteOldSession", "=", "false", ")", "{", "if", "(", "headers_sent", "(", ")", "||", "!", "$", "this", "->", "id", ")", "{", "return", "false", ";", "}", "$", "oldId", "=", "$", "this", "->", "id", ...
Regenerate the session ID, update the browser's cookie, and optionally remove the previous ID's session storage. @param bool $deleteOldSession @return bool success
[ "Regenerate", "the", "session", "ID", "update", "the", "browser", "s", "cookie", "and", "optionally", "remove", "the", "previous", "ID", "s", "session", "storage", "." ]
deabb1b487294efbd0bcb79ca83e6dab56036e45
https://github.com/mrclay/UserlandSession/blob/deabb1b487294efbd0bcb79ca83e6dab56036e45/src/UserlandSession/Session.php#L402-L414
train
mrclay/UserlandSession
src/UserlandSession/Session.php
Session.removeCookie
public function removeCookie() { return setcookie( $this->name, '', time() - 86400, $this->cookie_path, $this->cookie_domain, (bool)$this->cookie_secure, (bool)$this->cookie_httponly ); }
php
public function removeCookie() { return setcookie( $this->name, '', time() - 86400, $this->cookie_path, $this->cookie_domain, (bool)$this->cookie_secure, (bool)$this->cookie_httponly ); }
[ "public", "function", "removeCookie", "(", ")", "{", "return", "setcookie", "(", "$", "this", "->", "name", ",", "''", ",", "time", "(", ")", "-", "86400", ",", "$", "this", "->", "cookie_path", ",", "$", "this", "->", "cookie_domain", ",", "(", "boo...
Remove the session cookie @return bool success
[ "Remove", "the", "session", "cookie" ]
deabb1b487294efbd0bcb79ca83e6dab56036e45
https://github.com/mrclay/UserlandSession/blob/deabb1b487294efbd0bcb79ca83e6dab56036e45/src/UserlandSession/Session.php#L421-L432
train
mrclay/UserlandSession
src/UserlandSession/Session.php
Session.sendStartHeaders
protected function sendStartHeaders() { // send optional cache limiter // this is actual session behavior rather than what's documented. $lastModified = self::formatAsGmt(filemtime($_SERVER['SCRIPT_FILENAME'])); $ce = $this->cache_expire; switch ($this->cache_limiter) { case self::CACHE_LIMITER_PUBLIC: header('Expires: ' . self::formatAsGmt(time() + $ce)); header("Cache-Control: public, max-age=$ce"); header('Last-Modified: ' . $lastModified); break; case self::CACHE_LIMITER_PRIVATE_NO_EXPIRE: header("Cache-Control: private, max-age=$ce, pre-check=$ce"); header('Last-Modified: ' . $lastModified); break; case self::CACHE_LIMITER_PRIVATE: header('Expires: Thu, 19 Nov 1981 08:52:00 GMT'); header("Cache-Control: private, max-age=$ce, pre-check=$ce"); header('Last-Modified: ' . $lastModified); break; case self::CACHE_LIMITER_NOCACHE: header('Expires: Thu, 19 Nov 1981 08:52:00 GMT'); header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); header('Pragma: no-cache'); break; case self::CACHE_LIMITER_NONE: // send no cache headers, please break; } }
php
protected function sendStartHeaders() { // send optional cache limiter // this is actual session behavior rather than what's documented. $lastModified = self::formatAsGmt(filemtime($_SERVER['SCRIPT_FILENAME'])); $ce = $this->cache_expire; switch ($this->cache_limiter) { case self::CACHE_LIMITER_PUBLIC: header('Expires: ' . self::formatAsGmt(time() + $ce)); header("Cache-Control: public, max-age=$ce"); header('Last-Modified: ' . $lastModified); break; case self::CACHE_LIMITER_PRIVATE_NO_EXPIRE: header("Cache-Control: private, max-age=$ce, pre-check=$ce"); header('Last-Modified: ' . $lastModified); break; case self::CACHE_LIMITER_PRIVATE: header('Expires: Thu, 19 Nov 1981 08:52:00 GMT'); header("Cache-Control: private, max-age=$ce, pre-check=$ce"); header('Last-Modified: ' . $lastModified); break; case self::CACHE_LIMITER_NOCACHE: header('Expires: Thu, 19 Nov 1981 08:52:00 GMT'); header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); header('Pragma: no-cache'); break; case self::CACHE_LIMITER_NONE: // send no cache headers, please break; } }
[ "protected", "function", "sendStartHeaders", "(", ")", "{", "// send optional cache limiter", "// this is actual session behavior rather than what's documented.", "$", "lastModified", "=", "self", "::", "formatAsGmt", "(", "filemtime", "(", "$", "_SERVER", "[", "'SCRIPT_FILEN...
Send headers based on cache_limiter and cache_expire properties
[ "Send", "headers", "based", "on", "cache_limiter", "and", "cache_expire", "properties" ]
deabb1b487294efbd0bcb79ca83e6dab56036e45
https://github.com/mrclay/UserlandSession/blob/deabb1b487294efbd0bcb79ca83e6dab56036e45/src/UserlandSession/Session.php#L494-L525
train
smartboxgroup/core-bundle
Validation/ValidatorDecorator.php
ValidatorDecorator.validate
public function validate($value, $constraints = null, $groups = null) { return $this->decoratedValidator->validate($value, $constraints, $groups); }
php
public function validate($value, $constraints = null, $groups = null) { return $this->decoratedValidator->validate($value, $constraints, $groups); }
[ "public", "function", "validate", "(", "$", "value", ",", "$", "constraints", "=", "null", ",", "$", "groups", "=", "null", ")", "{", "return", "$", "this", "->", "decoratedValidator", "->", "validate", "(", "$", "value", ",", "$", "constraints", ",", ...
Validates a value against a constraint or a list of constraints. If no constraint is passed, the constraint {@link \Symfony\Component\Validator\Constraints\Valid} is assumed. @param mixed $value The value to validate @param Constraint|Constraint[] $constraints The constraint(s) to validate against @param array|null $groups The validation groups to validate. If none is given, "Default" is assumed @return ConstraintViolationListInterface A list of constraint violations. If the list is empty, validation succeeded
[ "Validates", "a", "value", "against", "a", "constraint", "or", "a", "list", "of", "constraints", "." ]
88ffc0af6631efbea90425454ce0bce0c753504e
https://github.com/smartboxgroup/core-bundle/blob/88ffc0af6631efbea90425454ce0bce0c753504e/Validation/ValidatorDecorator.php#L72-L75
train
smartboxgroup/core-bundle
Validation/ValidatorDecorator.php
ValidatorDecorator.validateProperty
public function validateProperty($object, $propertyName, $groups = null) { return $this->decoratedValidator->validateProperty($object, $propertyName, $groups); }
php
public function validateProperty($object, $propertyName, $groups = null) { return $this->decoratedValidator->validateProperty($object, $propertyName, $groups); }
[ "public", "function", "validateProperty", "(", "$", "object", ",", "$", "propertyName", ",", "$", "groups", "=", "null", ")", "{", "return", "$", "this", "->", "decoratedValidator", "->", "validateProperty", "(", "$", "object", ",", "$", "propertyName", ",",...
Validates a property of an object against the constraints specified for this property. @param object $object The object @param string $propertyName The name of the validated property @param array|null $groups The validation groups to validate. If none is given, "Default" is assumed @return ConstraintViolationListInterface A list of constraint violations. If the list is empty, validation succeeded
[ "Validates", "a", "property", "of", "an", "object", "against", "the", "constraints", "specified", "for", "this", "property", "." ]
88ffc0af6631efbea90425454ce0bce0c753504e
https://github.com/smartboxgroup/core-bundle/blob/88ffc0af6631efbea90425454ce0bce0c753504e/Validation/ValidatorDecorator.php#L87-L90
train
smartboxgroup/core-bundle
Validation/ValidatorDecorator.php
ValidatorDecorator.validatePropertyValue
public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null) { return $this->decoratedValidator->validatePropertyValue($objectOrClass, $propertyName, $value, $groups); }
php
public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null) { return $this->decoratedValidator->validatePropertyValue($objectOrClass, $propertyName, $value, $groups); }
[ "public", "function", "validatePropertyValue", "(", "$", "objectOrClass", ",", "$", "propertyName", ",", "$", "value", ",", "$", "groups", "=", "null", ")", "{", "return", "$", "this", "->", "decoratedValidator", "->", "validatePropertyValue", "(", "$", "objec...
Validates a value against the constraints specified for an object's property. @param object|string $objectOrClass The object or its class name @param string $propertyName The name of the property @param mixed $value The value to validate against the property's constraints @param array|null $groups The validation groups to validate. If none is given, "Default" is assumed @return ConstraintViolationListInterface A list of constraint violations. If the list is empty, validation succeeded
[ "Validates", "a", "value", "against", "the", "constraints", "specified", "for", "an", "object", "s", "property", "." ]
88ffc0af6631efbea90425454ce0bce0c753504e
https://github.com/smartboxgroup/core-bundle/blob/88ffc0af6631efbea90425454ce0bce0c753504e/Validation/ValidatorDecorator.php#L103-L106
train
anklimsk/cakephp-theme
Controller/Component/ViewExtensionComponent.php
ViewExtensionComponent.isHtml
public function isHtml() { $ext = $this->_controller->request->param('ext'); if (empty($ext)) { return true; } $prefers = $this->_controller->RequestHandler->prefers(); if (empty($prefers)) { $prefers = 'html'; } $responseMimeType = $this->_controller->response->getMimeType($prefers); if (!$responseMimeType) { return false; } return in_array('text/html', (array)$responseMimeType); }
php
public function isHtml() { $ext = $this->_controller->request->param('ext'); if (empty($ext)) { return true; } $prefers = $this->_controller->RequestHandler->prefers(); if (empty($prefers)) { $prefers = 'html'; } $responseMimeType = $this->_controller->response->getMimeType($prefers); if (!$responseMimeType) { return false; } return in_array('text/html', (array)$responseMimeType); }
[ "public", "function", "isHtml", "(", ")", "{", "$", "ext", "=", "$", "this", "->", "_controller", "->", "request", "->", "param", "(", "'ext'", ")", ";", "if", "(", "empty", "(", "$", "ext", ")", ")", "{", "return", "true", ";", "}", "$", "prefer...
Checking the response is HTML. @return bool True if response is HTML. False otherwise.
[ "Checking", "the", "response", "is", "HTML", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ViewExtensionComponent.php#L136-L153
train
anklimsk/cakephp-theme
Controller/Component/ViewExtensionComponent.php
ViewExtensionComponent._addSpecificResponse
protected function _addSpecificResponse(Controller &$controller) { $controller->response->type(['sse' => 'text/event-stream']); $controller->response->type(['mod' => 'text/html']); $controller->response->type(['pop' => 'text/html']); $controller->response->type(['prt' => 'text/html']); }
php
protected function _addSpecificResponse(Controller &$controller) { $controller->response->type(['sse' => 'text/event-stream']); $controller->response->type(['mod' => 'text/html']); $controller->response->type(['pop' => 'text/html']); $controller->response->type(['prt' => 'text/html']); }
[ "protected", "function", "_addSpecificResponse", "(", "Controller", "&", "$", "controller", ")", "{", "$", "controller", "->", "response", "->", "type", "(", "[", "'sse'", "=>", "'text/event-stream'", "]", ")", ";", "$", "controller", "->", "response", "->", ...
Adding response for SSE, print preview, modal and popup request @param Controller &$controller Instantiating controller @return void
[ "Adding", "response", "for", "SSE", "print", "preview", "modal", "and", "popup", "request" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ViewExtensionComponent.php#L195-L200
train
anklimsk/cakephp-theme
Controller/Component/ViewExtensionComponent.php
ViewExtensionComponent._setUiLangVar
protected function _setUiLangVar(Controller &$controller) { $uiLcid2 = $this->_language->getCurrentUiLang(true); $uiLcid3 = $this->_language->getCurrentUiLang(false); $controller->set(compact('uiLcid2', 'uiLcid3')); }
php
protected function _setUiLangVar(Controller &$controller) { $uiLcid2 = $this->_language->getCurrentUiLang(true); $uiLcid3 = $this->_language->getCurrentUiLang(false); $controller->set(compact('uiLcid2', 'uiLcid3')); }
[ "protected", "function", "_setUiLangVar", "(", "Controller", "&", "$", "controller", ")", "{", "$", "uiLcid2", "=", "$", "this", "->", "_language", "->", "getCurrentUiLang", "(", "true", ")", ";", "$", "uiLcid3", "=", "$", "this", "->", "_language", "->", ...
Set global variable of current UI language Set global variable: - `uiLcid2`: language code in format ISO 639-1 (two-letter codes); - `uiLcid3` - :language code in format ISO 639-2 (three-letter codes). @param Controller &$controller Instantiating controller @return void
[ "Set", "global", "variable", "of", "current", "UI", "language" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ViewExtensionComponent.php#L224-L228
train
anklimsk/cakephp-theme
Controller/Component/ViewExtensionComponent.php
ViewExtensionComponent._setLayout
protected function _setLayout(Controller &$controller) { $isModal = $controller->request->is('modal'); $isPopup = $controller->request->is('popup'); $isSSE = $controller->request->is('sse'); $isPrint = $controller->request->is('print'); if ($isModal || $isPopup || $isSSE) { $controller->layout = 'CakeTheme.default'; } elseif ($isPrint) { $controller->viewPath = mb_ereg_replace(DS . 'prt', '', $controller->viewPath); $controller->response->type('html'); } }
php
protected function _setLayout(Controller &$controller) { $isModal = $controller->request->is('modal'); $isPopup = $controller->request->is('popup'); $isSSE = $controller->request->is('sse'); $isPrint = $controller->request->is('print'); if ($isModal || $isPopup || $isSSE) { $controller->layout = 'CakeTheme.default'; } elseif ($isPrint) { $controller->viewPath = mb_ereg_replace(DS . 'prt', '', $controller->viewPath); $controller->response->type('html'); } }
[ "protected", "function", "_setLayout", "(", "Controller", "&", "$", "controller", ")", "{", "$", "isModal", "=", "$", "controller", "->", "request", "->", "is", "(", "'modal'", ")", ";", "$", "isPopup", "=", "$", "controller", "->", "request", "->", "is"...
Set layout for SSE, modal and popup response @param Controller &$controller Instantiating controller @return void
[ "Set", "layout", "for", "SSE", "modal", "and", "popup", "response" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ViewExtensionComponent.php#L236-L247
train
anklimsk/cakephp-theme
Controller/Component/ViewExtensionComponent.php
ViewExtensionComponent._getSessionKeyRedirect
protected function _getSessionKeyRedirect($key = null) { if (empty($key)) { $key = $this->_controller->request->here(); } $cacheKey = md5((string)$key); return $cacheKey; }
php
protected function _getSessionKeyRedirect($key = null) { if (empty($key)) { $key = $this->_controller->request->here(); } $cacheKey = md5((string)$key); return $cacheKey; }
[ "protected", "function", "_getSessionKeyRedirect", "(", "$", "key", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "key", ")", ")", "{", "$", "key", "=", "$", "this", "->", "_controller", "->", "request", "->", "here", "(", ")", ";", "}", "$"...
Return MD5 cache key from key string @param string $key Key for cache @return string MD5 cache key
[ "Return", "MD5", "cache", "key", "from", "key", "string" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ViewExtensionComponent.php#L255-L262
train
anklimsk/cakephp-theme
Controller/Component/ViewExtensionComponent.php
ViewExtensionComponent.setRedirectUrl
public function setRedirectUrl($redirect = null, $key = null) { if (empty($redirect)) { $redirect = $this->_controller->request->referer(true); } elseif ($redirect === true) { $redirect = $this->_controller->request->here(true); } if (empty($redirect) || $this->_controller->request->is('popup') || $this->_controller->request->is('print')) { return false; } $cacheKey = $this->_getSessionKeyRedirect($key); $data = CakeSession::read($cacheKey); if (!empty($data) && (md5((string)$data) === md5((string)$redirect))) { return false; } return CakeSession::write($cacheKey, $redirect); }
php
public function setRedirectUrl($redirect = null, $key = null) { if (empty($redirect)) { $redirect = $this->_controller->request->referer(true); } elseif ($redirect === true) { $redirect = $this->_controller->request->here(true); } if (empty($redirect) || $this->_controller->request->is('popup') || $this->_controller->request->is('print')) { return false; } $cacheKey = $this->_getSessionKeyRedirect($key); $data = CakeSession::read($cacheKey); if (!empty($data) && (md5((string)$data) === md5((string)$redirect))) { return false; } return CakeSession::write($cacheKey, $redirect); }
[ "public", "function", "setRedirectUrl", "(", "$", "redirect", "=", "null", ",", "$", "key", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "redirect", ")", ")", "{", "$", "redirect", "=", "$", "this", "->", "_controller", "->", "request", "->",...
Set redirect URL to cache @param string|array|bool $redirect Redirect URL. If empty, use redirect URL. If True, use current URL. @param string $key Key for cache @return bool Success
[ "Set", "redirect", "URL", "to", "cache" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ViewExtensionComponent.php#L272-L289
train
anklimsk/cakephp-theme
Controller/Component/ViewExtensionComponent.php
ViewExtensionComponent._getRedirectCache
protected function _getRedirectCache($key = null) { $cacheKey = $this->_getSessionKeyRedirect($key); $redirect = CakeSession::consume($cacheKey); return $redirect; }
php
protected function _getRedirectCache($key = null) { $cacheKey = $this->_getSessionKeyRedirect($key); $redirect = CakeSession::consume($cacheKey); return $redirect; }
[ "protected", "function", "_getRedirectCache", "(", "$", "key", "=", "null", ")", "{", "$", "cacheKey", "=", "$", "this", "->", "_getSessionKeyRedirect", "(", "$", "key", ")", ";", "$", "redirect", "=", "CakeSession", "::", "consume", "(", "$", "cacheKey", ...
Get redirect URL from cache @param string $key Key for cache @return mixed Return redirect URL, or Null on failure
[ "Get", "redirect", "URL", "from", "cache" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ViewExtensionComponent.php#L297-L302
train
anklimsk/cakephp-theme
Controller/Component/ViewExtensionComponent.php
ViewExtensionComponent.getRedirectUrl
public function getRedirectUrl($defaultRedirect = null, $key = null) { $redirect = $this->_getRedirectCache($key); if (empty($redirect)) { if (!empty($defaultRedirect)) { if ($defaultRedirect === true) { $redirect = $this->_controller->request->here(); } else { $redirect = $defaultRedirect; } } else { $redirect = ['action' => 'index']; } } return $redirect; }
php
public function getRedirectUrl($defaultRedirect = null, $key = null) { $redirect = $this->_getRedirectCache($key); if (empty($redirect)) { if (!empty($defaultRedirect)) { if ($defaultRedirect === true) { $redirect = $this->_controller->request->here(); } else { $redirect = $defaultRedirect; } } else { $redirect = ['action' => 'index']; } } return $redirect; }
[ "public", "function", "getRedirectUrl", "(", "$", "defaultRedirect", "=", "null", ",", "$", "key", "=", "null", ")", "{", "$", "redirect", "=", "$", "this", "->", "_getRedirectCache", "(", "$", "key", ")", ";", "if", "(", "empty", "(", "$", "redirect",...
Get redirect URL @param string|array|bool $defaultRedirect Default redirect URL. If True, use current URL. Use if redirect URL is not found in cache. @param string $key Key for cache @return mixed Return redirect URL
[ "Get", "redirect", "URL" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ViewExtensionComponent.php#L312-L327
train
anklimsk/cakephp-theme
Controller/Component/ViewExtensionComponent.php
ViewExtensionComponent.redirectByUrl
public function redirectByUrl($defaultRedirect = null, $key = null) { $redirectUrl = $this->getRedirectUrl($defaultRedirect, $key); return $this->_controller->redirect($redirectUrl); }
php
public function redirectByUrl($defaultRedirect = null, $key = null) { $redirectUrl = $this->getRedirectUrl($defaultRedirect, $key); return $this->_controller->redirect($redirectUrl); }
[ "public", "function", "redirectByUrl", "(", "$", "defaultRedirect", "=", "null", ",", "$", "key", "=", "null", ")", "{", "$", "redirectUrl", "=", "$", "this", "->", "getRedirectUrl", "(", "$", "defaultRedirect", ",", "$", "key", ")", ";", "return", "$", ...
Redirect by URL @param string|array $defaultRedirect Default redirect URL. Use if redirect URL is not found in cache. @param string $key Key for cache @return CakeResponse|null @see ViewExtensionComponent::getRedirectUrl()
[ "Redirect", "by", "URL" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ViewExtensionComponent.php#L338-L342
train
anklimsk/cakephp-theme
Controller/Component/ViewExtensionComponent.php
ViewExtensionComponent._setLocale
protected function _setLocale() { $language = $this->_language->getCurrentUiLang(false); return (bool)setlocale(LC_ALL, $language); }
php
protected function _setLocale() { $language = $this->_language->getCurrentUiLang(false); return (bool)setlocale(LC_ALL, $language); }
[ "protected", "function", "_setLocale", "(", ")", "{", "$", "language", "=", "$", "this", "->", "_language", "->", "getCurrentUiLang", "(", "false", ")", ";", "return", "(", "bool", ")", "setlocale", "(", "LC_ALL", ",", "$", "language", ")", ";", "}" ]
Set locale for current UI language. @return bool Success
[ "Set", "locale", "for", "current", "UI", "language", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ViewExtensionComponent.php#L349-L353
train
anklimsk/cakephp-theme
Controller/Component/ViewExtensionComponent.php
ViewExtensionComponent.setProgressSseTask
public function setProgressSseTask($taskName = null) { if (empty($taskName)) { return false; } $tasks = (array)CakeSession::read('SSE.progress'); if (in_array($taskName, $tasks)) { return true; } $tasks[] = $taskName; return CakeSession::write('SSE.progress', $tasks); }
php
public function setProgressSseTask($taskName = null) { if (empty($taskName)) { return false; } $tasks = (array)CakeSession::read('SSE.progress'); if (in_array($taskName, $tasks)) { return true; } $tasks[] = $taskName; return CakeSession::write('SSE.progress', $tasks); }
[ "public", "function", "setProgressSseTask", "(", "$", "taskName", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "taskName", ")", ")", "{", "return", "false", ";", "}", "$", "tasks", "=", "(", "array", ")", "CakeSession", "::", "read", "(", "'S...
Set task to display the progress of execution from task queue @param string $taskName Name of task @return bool Success
[ "Set", "task", "to", "display", "the", "progress", "of", "execution", "from", "task", "queue" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ViewExtensionComponent.php#L361-L374
train
anklimsk/cakephp-theme
Controller/Component/ViewExtensionComponent.php
ViewExtensionComponent.setExceptionMessage
public function setExceptionMessage($message = '', $defaultRedirect = null, $key = null) { $statusCode = null; $redirectUrl = null; if ($message instanceof Exception) { if ($this->_controller->request->is('ajax')) { $statusCode = $message->getCode(); } } if (empty($statusCode)) { $this->_controller->Flash->error($message); $redirectUrl = $this->getRedirectUrl($defaultRedirect, $key); } return $this->_controller->redirect($redirectUrl, $statusCode); }
php
public function setExceptionMessage($message = '', $defaultRedirect = null, $key = null) { $statusCode = null; $redirectUrl = null; if ($message instanceof Exception) { if ($this->_controller->request->is('ajax')) { $statusCode = $message->getCode(); } } if (empty($statusCode)) { $this->_controller->Flash->error($message); $redirectUrl = $this->getRedirectUrl($defaultRedirect, $key); } return $this->_controller->redirect($redirectUrl, $statusCode); }
[ "public", "function", "setExceptionMessage", "(", "$", "message", "=", "''", ",", "$", "defaultRedirect", "=", "null", ",", "$", "key", "=", "null", ")", "{", "$", "statusCode", "=", "null", ";", "$", "redirectUrl", "=", "null", ";", "if", "(", "$", ...
Set Flash message of exception @param string $message Message to be flashed. If an instance of Exception the exception message will be used and code will be set in params. @param string|array $defaultRedirect Default redirect URL. Use if redirect URL is not found in cache. @param string $key Key for cache @return CakeResponse|null @see FlashComponent::set() @see ViewExtensionComponent::getRedirectUrl()
[ "Set", "Flash", "message", "of", "exception" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ViewExtensionComponent.php#L389-L403
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Bundle/Admin/Plugins/Gui/ScriptSettingsWindowFactory.php
ScriptSettingsWindowFactory.callbackApply
public function callbackApply(ManialinkInterface $manialink, $login, $entries, $args) { /** @var GridBuilder $grid */ $grid = $manialink->getData('grid'); $grid->updateDataCollection($entries); // update datacollection // build settings array from datacollection $settings = []; foreach ($grid->getDataCollection()->getAll() as $key => $value) { $settings[$value['name']] = $value['value']; } try { $this->factory->getConnection()->setModeScriptSettings($settings); $this->closeManialink($manialink); } catch (\Exception $ex) { // TODO this should use chat notification. $this->factory->getConnection()->chatSendServerMessage("error: ".$ex->getMessage()); $this->console->writeln('$f00Error: $fff'.$ex->getMessage()); } }
php
public function callbackApply(ManialinkInterface $manialink, $login, $entries, $args) { /** @var GridBuilder $grid */ $grid = $manialink->getData('grid'); $grid->updateDataCollection($entries); // update datacollection // build settings array from datacollection $settings = []; foreach ($grid->getDataCollection()->getAll() as $key => $value) { $settings[$value['name']] = $value['value']; } try { $this->factory->getConnection()->setModeScriptSettings($settings); $this->closeManialink($manialink); } catch (\Exception $ex) { // TODO this should use chat notification. $this->factory->getConnection()->chatSendServerMessage("error: ".$ex->getMessage()); $this->console->writeln('$f00Error: $fff'.$ex->getMessage()); } }
[ "public", "function", "callbackApply", "(", "ManialinkInterface", "$", "manialink", ",", "$", "login", ",", "$", "entries", ",", "$", "args", ")", "{", "/** @var GridBuilder $grid */", "$", "grid", "=", "$", "manialink", "->", "getData", "(", "'grid'", ")", ...
Callback for apply button @param $login @param $entries @param $args
[ "Callback", "for", "apply", "button" ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/Admin/Plugins/Gui/ScriptSettingsWindowFactory.php#L133-L154
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Bundle/Admin/Plugins/Gui/ScriptSettingsWindowFactory.php
ScriptSettingsWindowFactory.fetchScriptSettings
public function fetchScriptSettings() { $data = []; $scriptSettings = $this->factory->getConnection()->getModeScriptSettings(); /** * @var string $i */ $i = 1; foreach ($scriptSettings as $name => $value) { $data[] = [ 'index' => $i++, 'name' => $name, 'value' => $value, ]; } return $data; }
php
public function fetchScriptSettings() { $data = []; $scriptSettings = $this->factory->getConnection()->getModeScriptSettings(); /** * @var string $i */ $i = 1; foreach ($scriptSettings as $name => $value) { $data[] = [ 'index' => $i++, 'name' => $name, 'value' => $value, ]; } return $data; }
[ "public", "function", "fetchScriptSettings", "(", ")", "{", "$", "data", "=", "[", "]", ";", "$", "scriptSettings", "=", "$", "this", "->", "factory", "->", "getConnection", "(", ")", "->", "getModeScriptSettings", "(", ")", ";", "/**\n * @var string $...
helper function to fetch script settings
[ "helper", "function", "to", "fetch", "script", "settings" ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/Admin/Plugins/Gui/ScriptSettingsWindowFactory.php#L159-L178
train
eXpansionPluginPack/eXpansion2
src_experimantal/eXpansionExperimantal/Bundle/Dedimania/Services/DedimaniaService.php
DedimaniaService.processRecord
public function processRecord($login, $score, $checkpoints) { if ($this->enabled->get() == false) { return false; } if ($this->isDisabled()) { return false; } $tempRecords = $this->recordsByLogin; $tempPositions = $this->ranksByLogin; if (isset($this->recordsByLogin[$login])) { $record = $this->recordsByLogin[$login]; } else { $record = new DedimaniaRecord($login); $pla = $this->playerStorage->getPlayerInfo($login); $record->nickName = $pla->getNickName(); } $tempRecords[$login] = clone $record; $oldRecord = clone $record; // if better time if ($score < $oldRecord->best || $oldRecord->best == -1) { $record->best = $score; $record->checks = implode(",", $checkpoints); $tempRecords[$login] = $record; // sort and update new rank uasort($tempRecords, [$this, "compare"]); if (!isset($this->players[$login])) { echo "player $login not connected\n"; return false; } $player = $this->players[$login]; // recalculate ranks for records $rank = 1; $newRecord = false; foreach ($tempRecords as $key => $tempRecord) { $tempRecords[$key]->rank = $rank; $tempPositions[$key] = $rank; if ($tempRecord->login == $login && ($rank <= $this->serverMaxRank || $rank <= $player->maxRank) && $rank < 100) { $newRecord = $tempRecords[$login]; } $rank++; } $tempRecords = array_slice($tempRecords, 0, 100, true); $tempPositions = array_slice($tempPositions, 0, 100, true); if ($newRecord) { $this->recordsByLogin = $tempRecords; $outRecords = usort($tempRecords, [$this, 'compare']); $this->ranksByLogin = $tempPositions; $params = [ $newRecord, $oldRecord, $outRecords, $newRecord->rank, $oldRecord->rank, ]; $this->dispatcher->dispatch("expansion.dedimania.records.update", [$params]); return $newRecord; } } return false; }
php
public function processRecord($login, $score, $checkpoints) { if ($this->enabled->get() == false) { return false; } if ($this->isDisabled()) { return false; } $tempRecords = $this->recordsByLogin; $tempPositions = $this->ranksByLogin; if (isset($this->recordsByLogin[$login])) { $record = $this->recordsByLogin[$login]; } else { $record = new DedimaniaRecord($login); $pla = $this->playerStorage->getPlayerInfo($login); $record->nickName = $pla->getNickName(); } $tempRecords[$login] = clone $record; $oldRecord = clone $record; // if better time if ($score < $oldRecord->best || $oldRecord->best == -1) { $record->best = $score; $record->checks = implode(",", $checkpoints); $tempRecords[$login] = $record; // sort and update new rank uasort($tempRecords, [$this, "compare"]); if (!isset($this->players[$login])) { echo "player $login not connected\n"; return false; } $player = $this->players[$login]; // recalculate ranks for records $rank = 1; $newRecord = false; foreach ($tempRecords as $key => $tempRecord) { $tempRecords[$key]->rank = $rank; $tempPositions[$key] = $rank; if ($tempRecord->login == $login && ($rank <= $this->serverMaxRank || $rank <= $player->maxRank) && $rank < 100) { $newRecord = $tempRecords[$login]; } $rank++; } $tempRecords = array_slice($tempRecords, 0, 100, true); $tempPositions = array_slice($tempPositions, 0, 100, true); if ($newRecord) { $this->recordsByLogin = $tempRecords; $outRecords = usort($tempRecords, [$this, 'compare']); $this->ranksByLogin = $tempPositions; $params = [ $newRecord, $oldRecord, $outRecords, $newRecord->rank, $oldRecord->rank, ]; $this->dispatcher->dispatch("expansion.dedimania.records.update", [$params]); return $newRecord; } } return false; }
[ "public", "function", "processRecord", "(", "$", "login", ",", "$", "score", ",", "$", "checkpoints", ")", "{", "if", "(", "$", "this", "->", "enabled", "->", "get", "(", ")", "==", "false", ")", "{", "return", "false", ";", "}", "if", "(", "$", ...
Check and Add a new record, if needed @param string $login @param int $score @param int[] $checkpoints @return DedimaniaRecord|false
[ "Check", "and", "Add", "a", "new", "record", "if", "needed" ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src_experimantal/eXpansionExperimantal/Bundle/Dedimania/Services/DedimaniaService.php#L120-L199
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Bundle/VoteManager/Plugins/VoteManager.php
VoteManager.onVoteNew
public function onVoteNew(Player $player, $cmdName, $cmdValue) { if ($cmdValue instanceof Vote) { $this->updateVoteWidgetFactory->create($this->players); $this->voteWidgetFactory->create($this->players); } else { $this->voteService->startVote($player, $cmdName, ['value' => $cmdValue]); } }
php
public function onVoteNew(Player $player, $cmdName, $cmdValue) { if ($cmdValue instanceof Vote) { $this->updateVoteWidgetFactory->create($this->players); $this->voteWidgetFactory->create($this->players); } else { $this->voteService->startVote($player, $cmdName, ['value' => $cmdValue]); } }
[ "public", "function", "onVoteNew", "(", "Player", "$", "player", ",", "$", "cmdName", ",", "$", "cmdValue", ")", "{", "if", "(", "$", "cmdValue", "instanceof", "Vote", ")", "{", "$", "this", "->", "updateVoteWidgetFactory", "->", "create", "(", "$", "thi...
When a new vote is addressed @param Player $player @param string $cmdName @param string $cmdValue @return void
[ "When", "a", "new", "vote", "is", "addressed" ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/VoteManager/Plugins/VoteManager.php#L75-L83
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Bundle/VoteManager/Plugins/VoteManager.php
VoteManager.onVoteCancelled
public function onVoteCancelled(Player $player, $cmdName, $cmdValue) { if ($cmdValue instanceof Vote) { $this->voteWidgetFactory->destroy($this->players); $this->updateVoteWidgetFactory->destroy($this->players); } else { $this->voteService->cancel(); } }
php
public function onVoteCancelled(Player $player, $cmdName, $cmdValue) { if ($cmdValue instanceof Vote) { $this->voteWidgetFactory->destroy($this->players); $this->updateVoteWidgetFactory->destroy($this->players); } else { $this->voteService->cancel(); } }
[ "public", "function", "onVoteCancelled", "(", "Player", "$", "player", ",", "$", "cmdName", ",", "$", "cmdValue", ")", "{", "if", "(", "$", "cmdValue", "instanceof", "Vote", ")", "{", "$", "this", "->", "voteWidgetFactory", "->", "destroy", "(", "$", "th...
When vote gets cancelled @param Player $player @param string $cmdName @param string $cmdValue @return void
[ "When", "vote", "gets", "cancelled" ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/VoteManager/Plugins/VoteManager.php#L94-L103
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Bundle/VoteManager/Plugins/VoteManager.php
VoteManager.onVoteNo
public function onVoteNo(Player $player, $vote) { if ($this->voteService->getCurrentVote() instanceof AbstractVotePlugin) { $this->updateVoteWidgetFactory->updateVote($vote); } }
php
public function onVoteNo(Player $player, $vote) { if ($this->voteService->getCurrentVote() instanceof AbstractVotePlugin) { $this->updateVoteWidgetFactory->updateVote($vote); } }
[ "public", "function", "onVoteNo", "(", "Player", "$", "player", ",", "$", "vote", ")", "{", "if", "(", "$", "this", "->", "voteService", "->", "getCurrentVote", "(", ")", "instanceof", "AbstractVotePlugin", ")", "{", "$", "this", "->", "updateVoteWidgetFacto...
When vote Fails @param Player $player @param Vote $vote @return void
[ "When", "vote", "Fails" ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/VoteManager/Plugins/VoteManager.php#L163-L168
train
anklimsk/cakephp-theme
Model/Behavior/MoveBehavior.php
MoveBehavior._getBehaviorConfig
protected function _getBehaviorConfig(Model $model, $configParam = null) { if (empty($configParam) || !isset($model->Behaviors->Tree->settings[$model->alias][$configParam])) { return null; } $result = $model->Behaviors->Tree->settings[$model->alias][$configParam]; return $result; }
php
protected function _getBehaviorConfig(Model $model, $configParam = null) { if (empty($configParam) || !isset($model->Behaviors->Tree->settings[$model->alias][$configParam])) { return null; } $result = $model->Behaviors->Tree->settings[$model->alias][$configParam]; return $result; }
[ "protected", "function", "_getBehaviorConfig", "(", "Model", "$", "model", ",", "$", "configParam", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "configParam", ")", "||", "!", "isset", "(", "$", "model", "->", "Behaviors", "->", "Tree", "->", "...
Return value of configuration behavior by parameter. @param Model $model Model using this behavior. @param string $configParam Parameter of configuration behavior. @return mixed|null Return value of configuration behavior for parameter, or null on failure.
[ "Return", "value", "of", "configuration", "behavior", "by", "parameter", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/Behavior/MoveBehavior.php#L48-L57
train
anklimsk/cakephp-theme
Model/Behavior/MoveBehavior.php
MoveBehavior._changeParent
protected function _changeParent(Model $model, $id = null, $parentId = null) { $parentField = $this->_getBehaviorConfig($model, 'parent'); if (empty($id) || ($parentField === null)) { return false; } $model->recursive = -1; $treeItem = $model->read(null, $id); if (empty($treeItem)) { return false; } $treeItem[$model->alias][$parentField] = $parentId; $result = (bool)$model->save($treeItem); return $result; }
php
protected function _changeParent(Model $model, $id = null, $parentId = null) { $parentField = $this->_getBehaviorConfig($model, 'parent'); if (empty($id) || ($parentField === null)) { return false; } $model->recursive = -1; $treeItem = $model->read(null, $id); if (empty($treeItem)) { return false; } $treeItem[$model->alias][$parentField] = $parentId; $result = (bool)$model->save($treeItem); return $result; }
[ "protected", "function", "_changeParent", "(", "Model", "$", "model", ",", "$", "id", "=", "null", ",", "$", "parentId", "=", "null", ")", "{", "$", "parentField", "=", "$", "this", "->", "_getBehaviorConfig", "(", "$", "model", ",", "'parent'", ")", "...
Change parent ID of item. @param Model $model Model using this behavior. @param int|string $id The ID of item for change parent. @param int|string|null $parentId New parent ID of item. @return bool
[ "Change", "parent", "ID", "of", "item", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/Behavior/MoveBehavior.php#L67-L83
train
anklimsk/cakephp-theme
Model/Behavior/MoveBehavior.php
MoveBehavior._getSubTree
protected function _getSubTree(Model $model, $id = null) { $result = []; $parentField = $this->_getBehaviorConfig($model, 'parent'); $leftField = $this->_getBehaviorConfig($model, 'left'); if (($parentField === null) || ($leftField === null)) { return $result; } $conditions = [ $model->alias . '.' . $parentField => null ]; if (!empty($id)) { $conditions[$model->alias . '.' . $parentField] = (int)$id; } if ($model->Behaviors->Tree->settings[$model->alias]['scope'] !== '1 = 1') { $conditions[] = $model->Behaviors->Tree->settings[$model->alias]['scope']; } $fields = [ $model->alias . '.' . $model->primaryKey, ]; $order = [ $model->alias . '.' . $leftField => 'asc' ]; $model->recursive = -1; $data = $model->find('list', compact('conditions', 'fields', 'order')); if (!empty($data)) { $result = array_keys($data); } return $result; }
php
protected function _getSubTree(Model $model, $id = null) { $result = []; $parentField = $this->_getBehaviorConfig($model, 'parent'); $leftField = $this->_getBehaviorConfig($model, 'left'); if (($parentField === null) || ($leftField === null)) { return $result; } $conditions = [ $model->alias . '.' . $parentField => null ]; if (!empty($id)) { $conditions[$model->alias . '.' . $parentField] = (int)$id; } if ($model->Behaviors->Tree->settings[$model->alias]['scope'] !== '1 = 1') { $conditions[] = $model->Behaviors->Tree->settings[$model->alias]['scope']; } $fields = [ $model->alias . '.' . $model->primaryKey, ]; $order = [ $model->alias . '.' . $leftField => 'asc' ]; $model->recursive = -1; $data = $model->find('list', compact('conditions', 'fields', 'order')); if (!empty($data)) { $result = array_keys($data); } return $result; }
[ "protected", "function", "_getSubTree", "(", "Model", "$", "model", ",", "$", "id", "=", "null", ")", "{", "$", "result", "=", "[", "]", ";", "$", "parentField", "=", "$", "this", "->", "_getBehaviorConfig", "(", "$", "model", ",", "'parent'", ")", "...
Return list ID of subtree for item. @param Model $model Model using this behavior. @param int|string $id The ID of the item to get a list ID of subtree. @return array Return list of ID.
[ "Return", "list", "ID", "of", "subtree", "for", "item", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/Behavior/MoveBehavior.php#L92-L123
train
anklimsk/cakephp-theme
Model/Behavior/MoveBehavior.php
MoveBehavior.moveItem
public function moveItem(Model $model, $direct = null, $id = null, $delta = 1) { $direct = mb_strtolower($direct); $delta = (int)$delta; if (in_array($direct, ['up', 'down']) && ($delta < 0)) { throw new InternalErrorException(__d('view_extension', 'Invalid delta for moving record')); } if (!in_array($direct, ['top', 'up', 'down', 'bottom'])) { throw new InternalErrorException(__d('view_extension', 'Invalid direction for moving record')); } switch ($direct) { case 'top': $delta = true; // no break case 'up': $method = 'moveUp'; break; case 'bottom': $delta = true; // no break case 'down': $method = 'moveDown'; break; } $newParentId = null; $optionsEvent = compact('id', 'newParentId', 'method', 'delta'); $event = new CakeEvent('Model.beforeUpdateTree', $model, [$optionsEvent]); $model->getEventManager()->dispatch($event); if ($event->isStopped()) { return false; } $result = $model->$method($id, $delta); if ($result) { $event = new CakeEvent('Model.afterUpdateTree', $model); $model->getEventManager()->dispatch($event); } return $result; }
php
public function moveItem(Model $model, $direct = null, $id = null, $delta = 1) { $direct = mb_strtolower($direct); $delta = (int)$delta; if (in_array($direct, ['up', 'down']) && ($delta < 0)) { throw new InternalErrorException(__d('view_extension', 'Invalid delta for moving record')); } if (!in_array($direct, ['top', 'up', 'down', 'bottom'])) { throw new InternalErrorException(__d('view_extension', 'Invalid direction for moving record')); } switch ($direct) { case 'top': $delta = true; // no break case 'up': $method = 'moveUp'; break; case 'bottom': $delta = true; // no break case 'down': $method = 'moveDown'; break; } $newParentId = null; $optionsEvent = compact('id', 'newParentId', 'method', 'delta'); $event = new CakeEvent('Model.beforeUpdateTree', $model, [$optionsEvent]); $model->getEventManager()->dispatch($event); if ($event->isStopped()) { return false; } $result = $model->$method($id, $delta); if ($result) { $event = new CakeEvent('Model.afterUpdateTree', $model); $model->getEventManager()->dispatch($event); } return $result; }
[ "public", "function", "moveItem", "(", "Model", "$", "model", ",", "$", "direct", "=", "null", ",", "$", "id", "=", "null", ",", "$", "delta", "=", "1", ")", "{", "$", "direct", "=", "mb_strtolower", "(", "$", "direct", ")", ";", "$", "delta", "=...
Move item to new position of tree @param Model $model Model using this behavior. @param string $direct Direction for moving: `up`, `down`, `top`, `bottom` @param int $id ID of record for moving @param int $delta Delta for moving @throws InternalErrorException if delta for moving < 0 @throws InternalErrorException if direction for moving not is: `up`, `down`, `top` or `bottom` @triggers Model.beforeUpdateTree $model array($options) @triggers Model.afterUpdateTree $model @return bool Success
[ "Move", "item", "to", "new", "position", "of", "tree" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/Behavior/MoveBehavior.php#L138-L179
train
anklimsk/cakephp-theme
Model/Behavior/MoveBehavior.php
MoveBehavior.moveDrop
public function moveDrop(Model $model, $id = null, $newParentId = null, $oldParentId = null, $dropData = null) { if (empty($id)) { return false; } $changeRoot = false; $dataSource = $model->getDataSource(); $dataSource->begin(); if ($newParentId != $oldParentId) { $changeRoot = true; if (!$this->_changeParent($model, $id, $newParentId)) { $dataSource->rollback(); return false; } } $newDataList = []; if (!empty($dropData) && is_array($dropData)) { $newDataList = Hash::extract($dropData, '0.{n}.id'); } $oldDataList = $this->_getSubTree($model, $newParentId); if ($newDataList == $oldDataList) { if (!$changeRoot) { return true; } $dataSource->rollback(); return false; } $indexNew = array_search($id, $newDataList); $indexOld = array_search($id, $oldDataList); if (($indexNew === false) || ($indexOld === false)) { return false; } $delta = $indexNew - $indexOld; $method = 'moveDown'; if ($delta < 0) { $delta *= -1; $method = 'moveUp'; } $optionsEvent = compact('id', 'newParentId', 'method', 'delta'); $event = new CakeEvent('Model.beforeUpdateTree', $model, [$optionsEvent]); $model->getEventManager()->dispatch($event); if ($event->isStopped()) { $dataSource->rollback(); return false; } $result = $model->$method($id, $delta); if ($result) { $dataSource->commit(); $event = new CakeEvent('Model.afterUpdateTree', $model); $model->getEventManager()->dispatch($event); } else { $dataSource->rollback(); } return $result; }
php
public function moveDrop(Model $model, $id = null, $newParentId = null, $oldParentId = null, $dropData = null) { if (empty($id)) { return false; } $changeRoot = false; $dataSource = $model->getDataSource(); $dataSource->begin(); if ($newParentId != $oldParentId) { $changeRoot = true; if (!$this->_changeParent($model, $id, $newParentId)) { $dataSource->rollback(); return false; } } $newDataList = []; if (!empty($dropData) && is_array($dropData)) { $newDataList = Hash::extract($dropData, '0.{n}.id'); } $oldDataList = $this->_getSubTree($model, $newParentId); if ($newDataList == $oldDataList) { if (!$changeRoot) { return true; } $dataSource->rollback(); return false; } $indexNew = array_search($id, $newDataList); $indexOld = array_search($id, $oldDataList); if (($indexNew === false) || ($indexOld === false)) { return false; } $delta = $indexNew - $indexOld; $method = 'moveDown'; if ($delta < 0) { $delta *= -1; $method = 'moveUp'; } $optionsEvent = compact('id', 'newParentId', 'method', 'delta'); $event = new CakeEvent('Model.beforeUpdateTree', $model, [$optionsEvent]); $model->getEventManager()->dispatch($event); if ($event->isStopped()) { $dataSource->rollback(); return false; } $result = $model->$method($id, $delta); if ($result) { $dataSource->commit(); $event = new CakeEvent('Model.afterUpdateTree', $model); $model->getEventManager()->dispatch($event); } else { $dataSource->rollback(); } return $result; }
[ "public", "function", "moveDrop", "(", "Model", "$", "model", ",", "$", "id", "=", "null", ",", "$", "newParentId", "=", "null", ",", "$", "oldParentId", "=", "null", ",", "$", "dropData", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "id", ...
Move item to new position of tree use drag and drop. @param Model $model Model using this behavior. @param int|string $id The ID of the item to moving to new position. @param int|string|null $newParentId New parent ID of item. @param int|string|null $oldParentId Old parent ID of item. @param array $dropData Array of ID subtree for item. @return bool @triggers Model.beforeUpdateTree $model array($options) @triggers Model.afterUpdateTree $model @see https://github.com/johnny/jquery-sortable
[ "Move", "item", "to", "new", "position", "of", "tree", "use", "drag", "and", "drop", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/Behavior/MoveBehavior.php#L194-L258
train
inc2734/wp-oembed-blog-card
src/App/Setup/Assets.php
Assets._wp_oembed_blog_card_render
public function _wp_oembed_blog_card_render() { if ( empty( $_GET['url'] ) ) { return; } header( 'Content-Type: text/html; charset=utf-8' ); $url = esc_url_raw( wp_unslash( $_GET['url'] ) ); echo wp_kses_post( View::get_template( $url ) ); die(); }
php
public function _wp_oembed_blog_card_render() { if ( empty( $_GET['url'] ) ) { return; } header( 'Content-Type: text/html; charset=utf-8' ); $url = esc_url_raw( wp_unslash( $_GET['url'] ) ); echo wp_kses_post( View::get_template( $url ) ); die(); }
[ "public", "function", "_wp_oembed_blog_card_render", "(", ")", "{", "if", "(", "empty", "(", "$", "_GET", "[", "'url'", "]", ")", ")", "{", "return", ";", "}", "header", "(", "'Content-Type: text/html; charset=utf-8'", ")", ";", "$", "url", "=", "esc_url_raw...
Render blog card with ajax @SuppressWarnings(PHPMD.ExitExpression) @return void
[ "Render", "blog", "card", "with", "ajax" ]
4882994152f9003db9c68517a53090cbef13ff4d
https://github.com/inc2734/wp-oembed-blog-card/blob/4882994152f9003db9c68517a53090cbef13ff4d/src/App/Setup/Assets.php#L82-L91
train
mgallegos/decima-accounting
src/Mgallegos/DecimaAccounting/Accounting/Services/PeriodManagement/PeriodManager.php
PeriodManager.getLastPeriodOfFiscalYear
public function getLastPeriodOfFiscalYear(array $input) { $period = $this->Period->lastPeriodbyOrganizationAndByFiscalYear($this->AuthenticationManager->getCurrentUserOrganizationId(), $input['id'])->toArray(); $period['endDate'] = $this->Carbon->createFromFormat('Y-m-d', $period['end_date'])->format($this->Lang->get('form.phpShortDateFormat')); unset($period['end_date']); $period['month'] = $period['month'] . ' - ' . $this->Lang->get('decima-accounting::period-management.' . $period['month']); return json_encode($period); }
php
public function getLastPeriodOfFiscalYear(array $input) { $period = $this->Period->lastPeriodbyOrganizationAndByFiscalYear($this->AuthenticationManager->getCurrentUserOrganizationId(), $input['id'])->toArray(); $period['endDate'] = $this->Carbon->createFromFormat('Y-m-d', $period['end_date'])->format($this->Lang->get('form.phpShortDateFormat')); unset($period['end_date']); $period['month'] = $period['month'] . ' - ' . $this->Lang->get('decima-accounting::period-management.' . $period['month']); return json_encode($period); }
[ "public", "function", "getLastPeriodOfFiscalYear", "(", "array", "$", "input", ")", "{", "$", "period", "=", "$", "this", "->", "Period", "->", "lastPeriodbyOrganizationAndByFiscalYear", "(", "$", "this", "->", "AuthenticationManager", "->", "getCurrentUserOrganizatio...
Get last period of fiscal year @param array $input An array as follows: array(id => $id); @return array An array as follows: array( 'id' = $id, 'month' => $month, 'end_date' => $endDate)
[ "Get", "last", "period", "of", "fiscal", "year" ]
6410585303a13892e64e9dfeacbae0ca212b458b
https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Services/PeriodManagement/PeriodManager.php#L233-L242
train
mgallegos/decima-accounting
src/Mgallegos/DecimaAccounting/Accounting/Services/PeriodManagement/PeriodManager.php
PeriodManager.getCurrentMonthPeriod
public function getCurrentMonthPeriod($organizationId = null) { if(empty($organizationId)) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id'); } $fiscalYearId = $this->FiscalYear->lastFiscalYearByOrganization($organizationId); $Date = new Carbon('first day of this month'); $Date2 = new Carbon('last day of this month'); return $this->Period->periodByStardDateByEndDateByFiscalYearAndByOrganizationId($Date->format('Y-m-d'), $Date2->format('Y-m-d'), $fiscalYearId, $organizationId); }
php
public function getCurrentMonthPeriod($organizationId = null) { if(empty($organizationId)) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id'); } $fiscalYearId = $this->FiscalYear->lastFiscalYearByOrganization($organizationId); $Date = new Carbon('first day of this month'); $Date2 = new Carbon('last day of this month'); return $this->Period->periodByStardDateByEndDateByFiscalYearAndByOrganizationId($Date->format('Y-m-d'), $Date2->format('Y-m-d'), $fiscalYearId, $organizationId); }
[ "public", "function", "getCurrentMonthPeriod", "(", "$", "organizationId", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "organizationId", ")", ")", "{", "$", "organizationId", "=", "$", "this", "->", "AuthenticationManager", "->", "getCurrentUserOrganiza...
Get current month period @return Mgallegos\DecimaAccounting\Period
[ "Get", "current", "month", "period" ]
6410585303a13892e64e9dfeacbae0ca212b458b
https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Services/PeriodManagement/PeriodManager.php#L248-L261
train
mgallegos/decima-accounting
src/Mgallegos/DecimaAccounting/Accounting/Services/PeriodManagement/PeriodManager.php
PeriodManager.getPeriodByDateAndByOrganizationId
public function getPeriodByDateAndByOrganizationId($date, $organizationId = null, $databaseConnectionName = null) { if(empty($organizationId)) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id'); } return $this->Period->periodByDateAndByOrganizationId($date, $organizationId, $databaseConnectionName); }
php
public function getPeriodByDateAndByOrganizationId($date, $organizationId = null, $databaseConnectionName = null) { if(empty($organizationId)) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id'); } return $this->Period->periodByDateAndByOrganizationId($date, $organizationId, $databaseConnectionName); }
[ "public", "function", "getPeriodByDateAndByOrganizationId", "(", "$", "date", ",", "$", "organizationId", "=", "null", ",", "$", "databaseConnectionName", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "organizationId", ")", ")", "{", "$", "organizationI...
Get period by date @return Mgallegos\DecimaAccounting\Period
[ "Get", "period", "by", "date" ]
6410585303a13892e64e9dfeacbae0ca212b458b
https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Services/PeriodManagement/PeriodManager.php#L268-L276
train
mgallegos/decima-accounting
src/Mgallegos/DecimaAccounting/Accounting/Services/PeriodManagement/PeriodManager.php
PeriodManager.getBalanceAccountsClosingPeriods
public function getBalanceAccountsClosingPeriods(array $input) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id'); $fiscalYearId = $this->FiscalYear->lastFiscalYearByOrganization($organizationId); if($fiscalYearId == $input['id']) { return json_encode(array('info' => $this->Lang->get('decima-accounting::period-management.invalidFiscalYear'))); } $period = json_decode($this->getLastPeriodOfFiscalYear($input), true); $FiscalYear = $this->FiscalYear->byId($input['id']); $FiscalYear = $this->FiscalYear->byYearAndByOrganization($FiscalYear->year + 1, $organizationId); $period2 = $this->Period->firstPeriodbyOrganizationAndByFiscalYear($this->AuthenticationManager->getCurrentUserOrganizationId(), $FiscalYear->id)->toArray(); $period2['endDate'] = $this->Carbon->createFromFormat('Y-m-d', $period2['end_date'])->format($this->Lang->get('form.phpShortDateFormat')); unset($period2['end_date']); $period2['month'] = $period2['month'] . ' - ' . $this->Lang->get('decima-accounting::period-management.' . $period2['month']); return json_encode(array('id0' => $period['id'], 'month0' => $period['month'], 'endDate0' => $period['endDate'], 'id1' => $period2['id'], 'month1' => $period2['month'], 'endDate1' => $period2['endDate'], 'fiscalYearId' => $FiscalYear->id)); }
php
public function getBalanceAccountsClosingPeriods(array $input) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id'); $fiscalYearId = $this->FiscalYear->lastFiscalYearByOrganization($organizationId); if($fiscalYearId == $input['id']) { return json_encode(array('info' => $this->Lang->get('decima-accounting::period-management.invalidFiscalYear'))); } $period = json_decode($this->getLastPeriodOfFiscalYear($input), true); $FiscalYear = $this->FiscalYear->byId($input['id']); $FiscalYear = $this->FiscalYear->byYearAndByOrganization($FiscalYear->year + 1, $organizationId); $period2 = $this->Period->firstPeriodbyOrganizationAndByFiscalYear($this->AuthenticationManager->getCurrentUserOrganizationId(), $FiscalYear->id)->toArray(); $period2['endDate'] = $this->Carbon->createFromFormat('Y-m-d', $period2['end_date'])->format($this->Lang->get('form.phpShortDateFormat')); unset($period2['end_date']); $period2['month'] = $period2['month'] . ' - ' . $this->Lang->get('decima-accounting::period-management.' . $period2['month']); return json_encode(array('id0' => $period['id'], 'month0' => $period['month'], 'endDate0' => $period['endDate'], 'id1' => $period2['id'], 'month1' => $period2['month'], 'endDate1' => $period2['endDate'], 'fiscalYearId' => $FiscalYear->id)); }
[ "public", "function", "getBalanceAccountsClosingPeriods", "(", "array", "$", "input", ")", "{", "$", "organizationId", "=", "$", "this", "->", "AuthenticationManager", "->", "getCurrentUserOrganization", "(", "'id'", ")", ";", "$", "fiscalYearId", "=", "$", "this"...
Get last period of fiscal year and first period of the next fiscal year @param array $input An array as follows: array(id => $id); @return array An array as follows: array( 'id' = $id, 'month' => $month, 'end_date' => $endDate)
[ "Get", "last", "period", "of", "fiscal", "year", "and", "first", "period", "of", "the", "next", "fiscal", "year" ]
6410585303a13892e64e9dfeacbae0ca212b458b
https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Services/PeriodManagement/PeriodManager.php#L287-L311
train
mgallegos/decima-accounting
src/Mgallegos/DecimaAccounting/Accounting/Services/PeriodManagement/PeriodManager.php
PeriodManager.openPeriod
public function openPeriod(array $input) { $this->DB->transaction(function() use ($input) { $loggedUserId = $this->AuthenticationManager->getLoggedUserId(); $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id'); $Period = $this->Period->byId($input['id']); $Journal = $this->Journal->create(array('journalized_id' => $input['id'], 'journalized_type' => $this->Period->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId)); // $this->Journal->attachDetail($Journal->id, array('field' => $this->Lang->get('decima-accounting::journal-management.status'), 'field_lang_key' => 'decima-accounting::journal-management.status', 'old_value' => $this->Lang->get('decima-accounting::period-management.closed'), 'new_value' => $this->Lang->get('decima-accounting::period-management.opened')), $Journal); $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-accounting::period-management.periodOpenedJournal', array('period' => $this->Lang->get('decima-accounting::period-management.' . $Period->month))), $Journal)); $this->Period->update(array('is_closed' => false), $Period); }); return json_encode(array('success' => $this->Lang->get('form.defaultSuccessOperationMessage'), 'periods' => $this->getPeriods(), 'periodsFilter' => $this->getPeriods2())); }
php
public function openPeriod(array $input) { $this->DB->transaction(function() use ($input) { $loggedUserId = $this->AuthenticationManager->getLoggedUserId(); $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id'); $Period = $this->Period->byId($input['id']); $Journal = $this->Journal->create(array('journalized_id' => $input['id'], 'journalized_type' => $this->Period->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId)); // $this->Journal->attachDetail($Journal->id, array('field' => $this->Lang->get('decima-accounting::journal-management.status'), 'field_lang_key' => 'decima-accounting::journal-management.status', 'old_value' => $this->Lang->get('decima-accounting::period-management.closed'), 'new_value' => $this->Lang->get('decima-accounting::period-management.opened')), $Journal); $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-accounting::period-management.periodOpenedJournal', array('period' => $this->Lang->get('decima-accounting::period-management.' . $Period->month))), $Journal)); $this->Period->update(array('is_closed' => false), $Period); }); return json_encode(array('success' => $this->Lang->get('form.defaultSuccessOperationMessage'), 'periods' => $this->getPeriods(), 'periodsFilter' => $this->getPeriods2())); }
[ "public", "function", "openPeriod", "(", "array", "$", "input", ")", "{", "$", "this", "->", "DB", "->", "transaction", "(", "function", "(", ")", "use", "(", "$", "input", ")", "{", "$", "loggedUserId", "=", "$", "this", "->", "AuthenticationManager", ...
Open an existing period @param array $input An array as follows: array(id => $id); @return JSON encoded string A string as follows: In case of success: {"success" : form.defaultSuccessOperationMessage}
[ "Open", "an", "existing", "period" ]
6410585303a13892e64e9dfeacbae0ca212b458b
https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Services/PeriodManagement/PeriodManager.php#L383-L398
train
mgallegos/decima-accounting
src/Mgallegos/DecimaAccounting/Accounting/Services/PeriodManagement/PeriodManager.php
PeriodManager.closePeriod
public function closePeriod(array $input) { $canBeClosed = true; $this->DB->transaction(function() use ($input, &$canBeClosed) { $loggedUserId = $this->AuthenticationManager->getLoggedUserId(); $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id'); if($this->JournalVoucher->getByOrganizationByPeriodAndByStatus($organizationId, array($input['id']), 'A')->count() > 0) { $canBeClosed = false; return; } $Period = $this->Period->byId($input['id']); $Journal = $this->Journal->create(array('journalized_id' => $input['id'], 'journalized_type' => $this->Period->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId)); // $this->Journal->attachDetail($Journal->id, array('field' => $this->Lang->get('decima-accounting::journal-management.status'), 'field_lang_key' => 'decima-accounting::journal-management.status', 'old_value' => $this->Lang->get('decima-accounting::period-management.opened'), 'new_value' => $this->Lang->get('decima-accounting::period-management.closed')), $Journal); $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-accounting::period-management.periodClosedJournal', array('period' => $this->Lang->get('decima-accounting::period-management.' . $Period->month))), $Journal)); $this->Period->update(array('is_closed' => true), $Period); }); if(!$canBeClosed) { return json_encode(array('success' => false, 'info' => $this->Lang->get('decima-accounting::period-management.voucherException'))); } return json_encode(array('success' => $this->Lang->get('form.defaultSuccessOperationMessage'), 'periods' => $this->getPeriods(), 'periodsFilter' => $this->getPeriods2())); }
php
public function closePeriod(array $input) { $canBeClosed = true; $this->DB->transaction(function() use ($input, &$canBeClosed) { $loggedUserId = $this->AuthenticationManager->getLoggedUserId(); $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id'); if($this->JournalVoucher->getByOrganizationByPeriodAndByStatus($organizationId, array($input['id']), 'A')->count() > 0) { $canBeClosed = false; return; } $Period = $this->Period->byId($input['id']); $Journal = $this->Journal->create(array('journalized_id' => $input['id'], 'journalized_type' => $this->Period->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId)); // $this->Journal->attachDetail($Journal->id, array('field' => $this->Lang->get('decima-accounting::journal-management.status'), 'field_lang_key' => 'decima-accounting::journal-management.status', 'old_value' => $this->Lang->get('decima-accounting::period-management.opened'), 'new_value' => $this->Lang->get('decima-accounting::period-management.closed')), $Journal); $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-accounting::period-management.periodClosedJournal', array('period' => $this->Lang->get('decima-accounting::period-management.' . $Period->month))), $Journal)); $this->Period->update(array('is_closed' => true), $Period); }); if(!$canBeClosed) { return json_encode(array('success' => false, 'info' => $this->Lang->get('decima-accounting::period-management.voucherException'))); } return json_encode(array('success' => $this->Lang->get('form.defaultSuccessOperationMessage'), 'periods' => $this->getPeriods(), 'periodsFilter' => $this->getPeriods2())); }
[ "public", "function", "closePeriod", "(", "array", "$", "input", ")", "{", "$", "canBeClosed", "=", "true", ";", "$", "this", "->", "DB", "->", "transaction", "(", "function", "(", ")", "use", "(", "$", "input", ",", "&", "$", "canBeClosed", ")", "{"...
Close an existing period @param array $input An array as follows: array(id => $id); @return JSON encoded string A string as follows: In case of success: {"success" : form.defaultSuccessOperationMessage}
[ "Close", "an", "existing", "period" ]
6410585303a13892e64e9dfeacbae0ca212b458b
https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Services/PeriodManagement/PeriodManager.php#L410-L438
train
byjg/xmlnuke
xmlnuke-php5/src/Xmlnuke/Library/OAuthClient/v10/OAuthRequest.php
OAuthRequest.get_signable_parameters
public function get_signable_parameters() {/*{{{*/ // Grab all parameters $params = $this->parameters; // Remove oauth_signature if present if (isset($params['oauth_signature'])) { unset($params['oauth_signature']); } // Urlencode both keys and values $keys = OAuthUtil::urlencode_rfc3986(array_keys($params)); $values = OAuthUtil::urlencode_rfc3986(array_values($params)); $params = array_combine($keys, $values); // Sort by keys (natsort) uksort($params, 'strcmp'); // Generate key=value pairs $pairs = array(); foreach ($params as $key=>$value ) { if (is_array($value)) { // If the value is an array, it's because there are multiple // with the same key, sort them, then add all the pairs natsort($value); foreach ($value as $v2) { $pairs[] = $key . '=' . $v2; } } else { $pairs[] = $key . '=' . $value; } } // Return the pairs, concated with & return implode('&', $pairs); }
php
public function get_signable_parameters() {/*{{{*/ // Grab all parameters $params = $this->parameters; // Remove oauth_signature if present if (isset($params['oauth_signature'])) { unset($params['oauth_signature']); } // Urlencode both keys and values $keys = OAuthUtil::urlencode_rfc3986(array_keys($params)); $values = OAuthUtil::urlencode_rfc3986(array_values($params)); $params = array_combine($keys, $values); // Sort by keys (natsort) uksort($params, 'strcmp'); // Generate key=value pairs $pairs = array(); foreach ($params as $key=>$value ) { if (is_array($value)) { // If the value is an array, it's because there are multiple // with the same key, sort them, then add all the pairs natsort($value); foreach ($value as $v2) { $pairs[] = $key . '=' . $v2; } } else { $pairs[] = $key . '=' . $value; } } // Return the pairs, concated with & return implode('&', $pairs); }
[ "public", "function", "get_signable_parameters", "(", ")", "{", "/*{{{*/", "// Grab all parameters", "$", "params", "=", "$", "this", "->", "parameters", ";", "// Remove oauth_signature if present", "if", "(", "isset", "(", "$", "params", "[", "'oauth_signature'", "...
Returns the normalized parameters of the request This will be all (except oauth_signature) parameters, sorted first by key, and if duplicate keys, then by value. The returned string will be all the key=value pairs concated by &. @return string
[ "Returns", "the", "normalized", "parameters", "of", "the", "request" ]
aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7
https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Library/OAuthClient/v10/OAuthRequest.php#L98-L132
train
byjg/xmlnuke
xmlnuke-php5/src/Xmlnuke/Library/OAuthClient/v10/OAuthRequest.php
OAuthRequest.to_postdata
public function to_postdata() {/*{{{*/ $total = array(); foreach ($this->parameters as $k => $v) { if (is_array($v)) { foreach ($v as $va) { $total[] = OAuthUtil::urlencode_rfc3986($k) . "[]=" . OAuthUtil::urlencode_rfc3986($va); } } else { $total[] = OAuthUtil::urlencode_rfc3986($k) . "=" . OAuthUtil::urlencode_rfc3986($v); } } $out = implode("&", $total); return $out; }
php
public function to_postdata() {/*{{{*/ $total = array(); foreach ($this->parameters as $k => $v) { if (is_array($v)) { foreach ($v as $va) { $total[] = OAuthUtil::urlencode_rfc3986($k) . "[]=" . OAuthUtil::urlencode_rfc3986($va); } } else { $total[] = OAuthUtil::urlencode_rfc3986($k) . "=" . OAuthUtil::urlencode_rfc3986($v); } } $out = implode("&", $total); return $out; }
[ "public", "function", "to_postdata", "(", ")", "{", "/*{{{*/", "$", "total", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "parameters", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_array", "(", "$", "v", ")", ")", ...
builds the data one would send in a POST request TODO(morten.fangel): this function might be easily replaced with http_build_query() and corrections for rfc3986 compatibility.. but not sure
[ "builds", "the", "data", "one", "would", "send", "in", "a", "POST", "request" ]
aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7
https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Library/OAuthClient/v10/OAuthRequest.php#L197-L210
train
honeybee/trellis
src/Runtime/Attribute/EmbeddedEntityList/EmbeddedEntityListAttribute.php
EmbeddedEntityListAttribute.buildValidationRules
protected function buildValidationRules() { $rules = new RuleList(); $options = $this->getOptions(); $options[self::OPTION_ENTITY_TYPES] = $this->getEmbeddedEntityTypeMap(); $rules->push( new EmbeddedEntityListRule('valid-embedded-entity-list-data', $options) ); return $rules; }
php
protected function buildValidationRules() { $rules = new RuleList(); $options = $this->getOptions(); $options[self::OPTION_ENTITY_TYPES] = $this->getEmbeddedEntityTypeMap(); $rules->push( new EmbeddedEntityListRule('valid-embedded-entity-list-data', $options) ); return $rules; }
[ "protected", "function", "buildValidationRules", "(", ")", "{", "$", "rules", "=", "new", "RuleList", "(", ")", ";", "$", "options", "=", "$", "this", "->", "getOptions", "(", ")", ";", "$", "options", "[", "self", "::", "OPTION_ENTITY_TYPES", "]", "=", ...
Return a list of rules used to validate a specific attribute instance's value. @return RuleList
[ "Return", "a", "list", "of", "rules", "used", "to", "validate", "a", "specific", "attribute", "instance", "s", "value", "." ]
511300e193b22adc48a22e8ea8294ad40d53f681
https://github.com/honeybee/trellis/blob/511300e193b22adc48a22e8ea8294ad40d53f681/src/Runtime/Attribute/EmbeddedEntityList/EmbeddedEntityListAttribute.php#L128-L140
train
Malwarebytes/Altamira
src/Altamira/ChartIterator.php
ChartIterator.getScripts
public function getScripts() { $retVal = ''; while ( $this->scripts->valid() ) { $retVal .= "<script type='text/javascript'>\n{$this->scripts->get()}\n</script>\n"; $this->scripts->next(); } return $retVal; }
php
public function getScripts() { $retVal = ''; while ( $this->scripts->valid() ) { $retVal .= "<script type='text/javascript'>\n{$this->scripts->get()}\n</script>\n"; $this->scripts->next(); } return $retVal; }
[ "public", "function", "getScripts", "(", ")", "{", "$", "retVal", "=", "''", ";", "while", "(", "$", "this", "->", "scripts", "->", "valid", "(", ")", ")", "{", "$", "retVal", ".=", "\"<script type='text/javascript'>\\n{$this->scripts->get()}\\n</script>\\n\"", ...
Returns inline js, in case you don't want to immediately render. @return string
[ "Returns", "inline", "js", "in", "case", "you", "don", "t", "want", "to", "immediately", "render", "." ]
38e320f68070d7a0b6902c6c3f904995d4a8cdfc
https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/ChartIterator.php#L116-L125
train
Malwarebytes/Altamira
src/Altamira/ChartIterator.php
ChartIterator.getLibraries
public function getLibraries() { $config = \Altamira\Config::getInstance(); $libraryToPath = array( \Altamira\JsWriter\Flot::LIBRARY => $config['js.flotlib'], \Altamira\JsWriter\JqPlot::LIBRARY => $config['js.jqplotlib'] ); $libraryKeys = array_unique( array_keys( $this->libraries ) ); $libraryPaths = array(); foreach ($libraryKeys as $key) { $libraryPaths[] = $libraryToPath[$key]; } return $libraryPaths; }
php
public function getLibraries() { $config = \Altamira\Config::getInstance(); $libraryToPath = array( \Altamira\JsWriter\Flot::LIBRARY => $config['js.flotlib'], \Altamira\JsWriter\JqPlot::LIBRARY => $config['js.jqplotlib'] ); $libraryKeys = array_unique( array_keys( $this->libraries ) ); $libraryPaths = array(); foreach ($libraryKeys as $key) { $libraryPaths[] = $libraryToPath[$key]; } return $libraryPaths; }
[ "public", "function", "getLibraries", "(", ")", "{", "$", "config", "=", "\\", "Altamira", "\\", "Config", "::", "getInstance", "(", ")", ";", "$", "libraryToPath", "=", "array", "(", "\\", "Altamira", "\\", "JsWriter", "\\", "Flot", "::", "LIBRARY", "=>...
Provides libraries paths based on config values @return array
[ "Provides", "libraries", "paths", "based", "on", "config", "values" ]
38e320f68070d7a0b6902c6c3f904995d4a8cdfc
https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/ChartIterator.php#L131-L146
train
Malwarebytes/Altamira
src/Altamira/ChartIterator.php
ChartIterator.renderCss
public function renderCss() { $config = \Altamira\Config::getInstance(); foreach ( $this->libraries as $library => $junk ) { switch( $library ) { case \Altamira\JsWriter\Flot::LIBRARY: break; case \Altamira\JsWriter\JqPlot::LIBRARY: default: $cssPath = $config['css.jqplotpath']; } } if ( isset( $cssPath ) ) { echo "<link rel='stylesheet' type='text/css' href='{$cssPath}'></link>"; } return $this; }
php
public function renderCss() { $config = \Altamira\Config::getInstance(); foreach ( $this->libraries as $library => $junk ) { switch( $library ) { case \Altamira\JsWriter\Flot::LIBRARY: break; case \Altamira\JsWriter\JqPlot::LIBRARY: default: $cssPath = $config['css.jqplotpath']; } } if ( isset( $cssPath ) ) { echo "<link rel='stylesheet' type='text/css' href='{$cssPath}'></link>"; } return $this; }
[ "public", "function", "renderCss", "(", ")", "{", "$", "config", "=", "\\", "Altamira", "\\", "Config", "::", "getInstance", "(", ")", ";", "foreach", "(", "$", "this", "->", "libraries", "as", "$", "library", "=>", "$", "junk", ")", "{", "switch", "...
Echoes any CSS that is needed for the libraries to render correctly @return \Altamira\ChartIterator provides fluent interface
[ "Echoes", "any", "CSS", "that", "is", "needed", "for", "the", "libraries", "to", "render", "correctly" ]
38e320f68070d7a0b6902c6c3f904995d4a8cdfc
https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/ChartIterator.php#L165-L186
train
melisplatform/melis-installer
src/Controller/InstallerController.php
InstallerController.getForm
protected function getForm($configPath) { $form = null; $melisConfig = $this->serviceLocator->get('MelisInstallerConfig'); $formConfig = $melisConfig->getItem($configPath); if ($formConfig) { $factory = new \Zend\Form\Factory(); $formElements = $this->getServiceLocator()->get('FormElementManager'); $factory->setFormElementManager($formElements); $form = $factory->createForm($formConfig); } return $form; }
php
protected function getForm($configPath) { $form = null; $melisConfig = $this->serviceLocator->get('MelisInstallerConfig'); $formConfig = $melisConfig->getItem($configPath); if ($formConfig) { $factory = new \Zend\Form\Factory(); $formElements = $this->getServiceLocator()->get('FormElementManager'); $factory->setFormElementManager($formElements); $form = $factory->createForm($formConfig); } return $form; }
[ "protected", "function", "getForm", "(", "$", "configPath", ")", "{", "$", "form", "=", "null", ";", "$", "melisConfig", "=", "$", "this", "->", "serviceLocator", "->", "get", "(", "'MelisInstallerConfig'", ")", ";", "$", "formConfig", "=", "$", "melisConf...
Retrieves the array configuration from app.forms @param string $configPath @return Form
[ "Retrieves", "the", "array", "configuration", "from", "app", ".", "forms" ]
f34d925b847c1389a5498844fdae890eeb34e461
https://github.com/melisplatform/melis-installer/blob/f34d925b847c1389a5498844fdae890eeb34e461/src/Controller/InstallerController.php#L175-L189
train
melisplatform/melis-installer
src/Controller/InstallerController.php
InstallerController.systemConfigurationChecker
protected function systemConfigurationChecker() { $response = []; $data = []; $errors = []; $dataExt = []; $dataVar = []; $checkDataExt = 0; $success = 0; $translator = $this->getServiceLocator()->get('translator'); $installHelper = $this->getServiceLocator()->get('InstallerHelper'); $installHelper->setRequiredExtensions([ 'openssl', 'json', 'pdo_mysql', 'intl', ]); foreach ($installHelper->getRequiredExtensions() as $ext) { if (in_array($ext, $installHelper->getPhpExtensions())) { $dataExt[$ext] = $installHelper->isExtensionsExists($ext); } else { $dataExt[$ext] = sprintf($translator->translate('tr_melis_installer_step_1_0_extension_not_loaded'), $ext); } } $dataVar = $installHelper->checkEnvironmentVariables(); // checks if all PHP configuration is fine if (!empty($dataExt)) { foreach ($dataExt as $ext => $status) { if ((int) $status === 1) { $checkDataExt = 1; } else { $checkDataExt = 0; } } } if (!empty($dataVar)) { foreach ($dataVar as $var => $value) { $currentVal = trim($value); if (is_null($currentVal)) { $dataVar[$var] = sprintf($translator->translate('tr_melis_installer_step_1_0_php_variable_not_set'), $var); array_push($errors, sprintf($translator->translate('tr_melis_installer_step_1_0_php_variable_not_set'), $var)); } elseif ($currentVal || $currentVal == '0' || $currentVal == '-1') { $dataVar[$var] = 1; } } } else { array_push($errors, $translator->translate('tr_melis_installer_step_1_0_php_requied_variables_empty')); } // last checking if (empty($errors) && $checkDataExt === 1) { $success = 1; } $response = [ 'success' => $success, 'errors' => $errors, 'data' => [ 'extensions' => $dataExt, 'variables' => $dataVar, ], ]; return $response; }
php
protected function systemConfigurationChecker() { $response = []; $data = []; $errors = []; $dataExt = []; $dataVar = []; $checkDataExt = 0; $success = 0; $translator = $this->getServiceLocator()->get('translator'); $installHelper = $this->getServiceLocator()->get('InstallerHelper'); $installHelper->setRequiredExtensions([ 'openssl', 'json', 'pdo_mysql', 'intl', ]); foreach ($installHelper->getRequiredExtensions() as $ext) { if (in_array($ext, $installHelper->getPhpExtensions())) { $dataExt[$ext] = $installHelper->isExtensionsExists($ext); } else { $dataExt[$ext] = sprintf($translator->translate('tr_melis_installer_step_1_0_extension_not_loaded'), $ext); } } $dataVar = $installHelper->checkEnvironmentVariables(); // checks if all PHP configuration is fine if (!empty($dataExt)) { foreach ($dataExt as $ext => $status) { if ((int) $status === 1) { $checkDataExt = 1; } else { $checkDataExt = 0; } } } if (!empty($dataVar)) { foreach ($dataVar as $var => $value) { $currentVal = trim($value); if (is_null($currentVal)) { $dataVar[$var] = sprintf($translator->translate('tr_melis_installer_step_1_0_php_variable_not_set'), $var); array_push($errors, sprintf($translator->translate('tr_melis_installer_step_1_0_php_variable_not_set'), $var)); } elseif ($currentVal || $currentVal == '0' || $currentVal == '-1') { $dataVar[$var] = 1; } } } else { array_push($errors, $translator->translate('tr_melis_installer_step_1_0_php_requied_variables_empty')); } // last checking if (empty($errors) && $checkDataExt === 1) { $success = 1; } $response = [ 'success' => $success, 'errors' => $errors, 'data' => [ 'extensions' => $dataExt, 'variables' => $dataVar, ], ]; return $response; }
[ "protected", "function", "systemConfigurationChecker", "(", ")", "{", "$", "response", "=", "[", "]", ";", "$", "data", "=", "[", "]", ";", "$", "errors", "=", "[", "]", ";", "$", "dataExt", "=", "[", "]", ";", "$", "dataVar", "=", "[", "]", ";",...
Checks the PHP Environment and Variables @return Array
[ "Checks", "the", "PHP", "Environment", "and", "Variables" ]
f34d925b847c1389a5498844fdae890eeb34e461
https://github.com/melisplatform/melis-installer/blob/f34d925b847c1389a5498844fdae890eeb34e461/src/Controller/InstallerController.php#L195-L268
train
melisplatform/melis-installer
src/Controller/InstallerController.php
InstallerController.vHostSetupChecker
protected function vHostSetupChecker() { $translator = $this->getServiceLocator()->get('translator'); $success = 0; $error = []; $platform = null; $module = null; if (!empty(getenv('MELIS_PLATFORM'))) { $platform = getenv('MELIS_PLATFORM'); } else { $error['platform'] = $translator->translate('tr_melis_installer_step_1_1_no_paltform_declared'); } if (!empty(getenv('MELIS_MODULE'))) { $module = getenv('MELIS_MODULE'); } else { $error['module'] = $translator->translate('tr_melis_installer_step_1_1_no_module_declared'); } if (empty($error)) { $success = 1; } $response = [ 'success' => $success, 'errors' => $error, 'data' => [ 'platform' => $platform, 'module' => $module, ], ]; return $response; }
php
protected function vHostSetupChecker() { $translator = $this->getServiceLocator()->get('translator'); $success = 0; $error = []; $platform = null; $module = null; if (!empty(getenv('MELIS_PLATFORM'))) { $platform = getenv('MELIS_PLATFORM'); } else { $error['platform'] = $translator->translate('tr_melis_installer_step_1_1_no_paltform_declared'); } if (!empty(getenv('MELIS_MODULE'))) { $module = getenv('MELIS_MODULE'); } else { $error['module'] = $translator->translate('tr_melis_installer_step_1_1_no_module_declared'); } if (empty($error)) { $success = 1; } $response = [ 'success' => $success, 'errors' => $error, 'data' => [ 'platform' => $platform, 'module' => $module, ], ]; return $response; }
[ "protected", "function", "vHostSetupChecker", "(", ")", "{", "$", "translator", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'translator'", ")", ";", "$", "success", "=", "0", ";", "$", "error", "=", "[", "]", ";", "$", "...
Checks if the Vhost platform and module variable are set @return Array
[ "Checks", "if", "the", "Vhost", "platform", "and", "module", "variable", "are", "set" ]
f34d925b847c1389a5498844fdae890eeb34e461
https://github.com/melisplatform/melis-installer/blob/f34d925b847c1389a5498844fdae890eeb34e461/src/Controller/InstallerController.php#L274-L311
train
melisplatform/melis-installer
src/Controller/InstallerController.php
InstallerController.checkDirectoryRights
protected function checkDirectoryRights() { $translator = $this->getServiceLocator()->get('translator'); $installHelper = $this->getServiceLocator()->get('InstallerHelper'); $configDir = $installHelper->getDir('config'); $module = $this->getModuleSvc()->getAllModules(); $success = 0; $errors = []; $data = []; for ($x = 0; $x < count($configDir); $x++) { $configDir[$x] = 'config/' . $configDir[$x]; } array_push($configDir, 'config'); /** * Add config platform, MelisSites and public dir to check permission */ array_push($configDir, 'config/autoload/platforms/'); array_push($configDir, 'module/MelisModuleConfig/'); array_push($configDir, 'module/MelisModuleConfig/languages'); array_push($configDir, 'module/MelisModuleConfig/config'); array_push($configDir, 'module/MelisSites/'); array_push($configDir, 'dbdeploy/'); array_push($configDir, 'dbdeploy/data'); array_push($configDir, 'public/'); array_push($configDir, 'cache/'); array_push($configDir, 'test/'); for ($x = 0; $x < count($module); $x++) { $module[$x] = $this->getModuleSvc()->getModulePath($module[$x], false) . '/config'; } $dirs = array_merge($configDir, $module); $results = []; foreach ($dirs as $dir) { if (file_exists($dir)) { if ($installHelper->isDirWritable($dir)) { $results[$dir] = 1; } else { $results[$dir] = sprintf($translator->translate('tr_melis_installer_step_1_2_dir_not_writable'), $dir); array_push($errors, sprintf($translator->translate('tr_melis_installer_step_1_2_dir_not_writable'), $dir)); } } } if (empty($errors)) { $success = 1; } $response = [ 'success' => $success, 'errors' => $errors, 'data' => $results, ]; return $response; }
php
protected function checkDirectoryRights() { $translator = $this->getServiceLocator()->get('translator'); $installHelper = $this->getServiceLocator()->get('InstallerHelper'); $configDir = $installHelper->getDir('config'); $module = $this->getModuleSvc()->getAllModules(); $success = 0; $errors = []; $data = []; for ($x = 0; $x < count($configDir); $x++) { $configDir[$x] = 'config/' . $configDir[$x]; } array_push($configDir, 'config'); /** * Add config platform, MelisSites and public dir to check permission */ array_push($configDir, 'config/autoload/platforms/'); array_push($configDir, 'module/MelisModuleConfig/'); array_push($configDir, 'module/MelisModuleConfig/languages'); array_push($configDir, 'module/MelisModuleConfig/config'); array_push($configDir, 'module/MelisSites/'); array_push($configDir, 'dbdeploy/'); array_push($configDir, 'dbdeploy/data'); array_push($configDir, 'public/'); array_push($configDir, 'cache/'); array_push($configDir, 'test/'); for ($x = 0; $x < count($module); $x++) { $module[$x] = $this->getModuleSvc()->getModulePath($module[$x], false) . '/config'; } $dirs = array_merge($configDir, $module); $results = []; foreach ($dirs as $dir) { if (file_exists($dir)) { if ($installHelper->isDirWritable($dir)) { $results[$dir] = 1; } else { $results[$dir] = sprintf($translator->translate('tr_melis_installer_step_1_2_dir_not_writable'), $dir); array_push($errors, sprintf($translator->translate('tr_melis_installer_step_1_2_dir_not_writable'), $dir)); } } } if (empty($errors)) { $success = 1; } $response = [ 'success' => $success, 'errors' => $errors, 'data' => $results, ]; return $response; }
[ "protected", "function", "checkDirectoryRights", "(", ")", "{", "$", "translator", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'translator'", ")", ";", "$", "installHelper", "=", "$", "this", "->", "getServiceLocator", "(", ")",...
Check the directory rights if it is writable or not @return Array
[ "Check", "the", "directory", "rights", "if", "it", "is", "writable", "or", "not" ]
f34d925b847c1389a5498844fdae890eeb34e461
https://github.com/melisplatform/melis-installer/blob/f34d925b847c1389a5498844fdae890eeb34e461/src/Controller/InstallerController.php#L317-L378
train
melisplatform/melis-installer
src/Controller/InstallerController.php
InstallerController.getEnvironments
protected function getEnvironments() { $env = []; $container = new Container('melisinstaller'); if (isset($container['environments']) && isset($container['environments']['new'])) { $env = $container['environments']['new']; } return $env; }
php
protected function getEnvironments() { $env = []; $container = new Container('melisinstaller'); if (isset($container['environments']) && isset($container['environments']['new'])) { $env = $container['environments']['new']; } return $env; }
[ "protected", "function", "getEnvironments", "(", ")", "{", "$", "env", "=", "[", "]", ";", "$", "container", "=", "new", "Container", "(", "'melisinstaller'", ")", ";", "if", "(", "isset", "(", "$", "container", "[", "'environments'", "]", ")", "&&", "...
Returns the set environments in the session @return Array
[ "Returns", "the", "set", "environments", "in", "the", "session" ]
f34d925b847c1389a5498844fdae890eeb34e461
https://github.com/melisplatform/melis-installer/blob/f34d925b847c1389a5498844fdae890eeb34e461/src/Controller/InstallerController.php#L391-L401
train
melisplatform/melis-installer
src/Controller/InstallerController.php
InstallerController.getCurrentPlatform
protected function getCurrentPlatform() { $env = []; $container = new Container('melisinstaller'); if (isset($container['environments']) && isset($container['environments']['default_environment'])) { $env = $container['environments']['default_environment']; } return $env; }
php
protected function getCurrentPlatform() { $env = []; $container = new Container('melisinstaller'); if (isset($container['environments']) && isset($container['environments']['default_environment'])) { $env = $container['environments']['default_environment']; } return $env; }
[ "protected", "function", "getCurrentPlatform", "(", ")", "{", "$", "env", "=", "[", "]", ";", "$", "container", "=", "new", "Container", "(", "'melisinstaller'", ")", ";", "if", "(", "isset", "(", "$", "container", "[", "'environments'", "]", ")", "&&", ...
Returns the current values environment in the session @return Array
[ "Returns", "the", "current", "values", "environment", "in", "the", "session" ]
f34d925b847c1389a5498844fdae890eeb34e461
https://github.com/melisplatform/melis-installer/blob/f34d925b847c1389a5498844fdae890eeb34e461/src/Controller/InstallerController.php#L407-L417
train
melisplatform/melis-installer
src/Controller/InstallerController.php
InstallerController.checkSysConfigAction
public function checkSysConfigAction() { $success = 0; $errors = []; if ($this->getRequest()->isXmlHttpRequest()) { $response = $this->systemConfigurationChecker(); $success = $response['success']; $errors = $response['errors']; // add status to session $container = new Container('melisinstaller'); $container['steps'][$this->steps[0]] = ['page' => 1, 'success' => $success]; } return new JsonModel([ 'success' => $success, 'errors' => $errors, ]); }
php
public function checkSysConfigAction() { $success = 0; $errors = []; if ($this->getRequest()->isXmlHttpRequest()) { $response = $this->systemConfigurationChecker(); $success = $response['success']; $errors = $response['errors']; // add status to session $container = new Container('melisinstaller'); $container['steps'][$this->steps[0]] = ['page' => 1, 'success' => $success]; } return new JsonModel([ 'success' => $success, 'errors' => $errors, ]); }
[ "public", "function", "checkSysConfigAction", "(", ")", "{", "$", "success", "=", "0", ";", "$", "errors", "=", "[", "]", ";", "if", "(", "$", "this", "->", "getRequest", "(", ")", "->", "isXmlHttpRequest", "(", ")", ")", "{", "$", "response", "=", ...
This function is used for rechecking the status the desired step @return \Zend\View\Model\JsonModel
[ "This", "function", "is", "used", "for", "rechecking", "the", "status", "the", "desired", "step" ]
f34d925b847c1389a5498844fdae890eeb34e461
https://github.com/melisplatform/melis-installer/blob/f34d925b847c1389a5498844fdae890eeb34e461/src/Controller/InstallerController.php#L465-L484
train
melisplatform/melis-installer
src/Controller/InstallerController.php
InstallerController.checkVhostSetupAction
public function checkVhostSetupAction() { $success = 0; $errors = []; if ($this->getRequest()->isXmlHttpRequest()) { $response = $this->vHostSetupChecker(); $success = $response['success']; $errors = $response['errors']; // add status to session $container = new Container('melisinstaller'); $container['steps'][$this->steps[1]] = ['page' => 2, 'success' => $success]; } return new JsonModel([ 'success' => $success, 'errors' => $errors, ]); }
php
public function checkVhostSetupAction() { $success = 0; $errors = []; if ($this->getRequest()->isXmlHttpRequest()) { $response = $this->vHostSetupChecker(); $success = $response['success']; $errors = $response['errors']; // add status to session $container = new Container('melisinstaller'); $container['steps'][$this->steps[1]] = ['page' => 2, 'success' => $success]; } return new JsonModel([ 'success' => $success, 'errors' => $errors, ]); }
[ "public", "function", "checkVhostSetupAction", "(", ")", "{", "$", "success", "=", "0", ";", "$", "errors", "=", "[", "]", ";", "if", "(", "$", "this", "->", "getRequest", "(", ")", "->", "isXmlHttpRequest", "(", ")", ")", "{", "$", "response", "=", ...
This step rechecks the Step 1.1 which is the Vhost Setup just to check that everything fine. @return \Zend\View\Model\JsonModel
[ "This", "step", "rechecks", "the", "Step", "1", ".", "1", "which", "is", "the", "Vhost", "Setup", "just", "to", "check", "that", "everything", "fine", "." ]
f34d925b847c1389a5498844fdae890eeb34e461
https://github.com/melisplatform/melis-installer/blob/f34d925b847c1389a5498844fdae890eeb34e461/src/Controller/InstallerController.php#L491-L510
train
melisplatform/melis-installer
src/Controller/InstallerController.php
InstallerController.checkFileSystemRightsAction
public function checkFileSystemRightsAction() { $success = 0; $errors = []; if ($this->getRequest()->isXmlHttpRequest()) { $response = $this->checkDirectoryRights(); $success = $response['success']; $errors = $response['errors']; // add status to session $container = new Container('melisinstaller'); $container['steps'][$this->steps[2]] = ['page' => 3, 'success' => $success]; } return new JsonModel([ 'success' => $success, 'errors' => $errors, ]); }
php
public function checkFileSystemRightsAction() { $success = 0; $errors = []; if ($this->getRequest()->isXmlHttpRequest()) { $response = $this->checkDirectoryRights(); $success = $response['success']; $errors = $response['errors']; // add status to session $container = new Container('melisinstaller'); $container['steps'][$this->steps[2]] = ['page' => 3, 'success' => $success]; } return new JsonModel([ 'success' => $success, 'errors' => $errors, ]); }
[ "public", "function", "checkFileSystemRightsAction", "(", ")", "{", "$", "success", "=", "0", ";", "$", "errors", "=", "[", "]", ";", "if", "(", "$", "this", "->", "getRequest", "(", ")", "->", "isXmlHttpRequest", "(", ")", ")", "{", "$", "response", ...
Rechecks Step 1.2 File System Rights @return \Zend\View\Model\JsonModel
[ "Rechecks", "Step", "1", ".", "2", "File", "System", "Rights" ]
f34d925b847c1389a5498844fdae890eeb34e461
https://github.com/melisplatform/melis-installer/blob/f34d925b847c1389a5498844fdae890eeb34e461/src/Controller/InstallerController.php#L516-L535
train
melisplatform/melis-installer
src/Controller/InstallerController.php
InstallerController.rollBackAction
public function rollBackAction() { $success = 0; $errors = []; $installHelper = $this->getServiceLocator()->get('InstallerHelper'); $container = new Container('melisinstaller'); if (!empty($container->getArrayCopy()) && in_array(array_keys($container['steps']), [$this->steps])) { $tablesInstalled = isset($container['db_install_tables']) ? $container['db_install_tables'] : []; $siteModule = 'module/MelisSites/' . $container['cms_data']['website_module'] . '/'; $dbConfigFile = 'config/autoload/platforms/' . $installHelper->getMelisPlatform() . '.php'; $config = include($dbConfigFile); // drop table $installHelper->setDbAdapter($config['db']); foreach ($tablesInstalled as $table) { if ($installHelper->isDbTableExists($table)) { $installHelper->executeRawQuery("DROP TABLE " . trim($table)); } } // delete site module if (file_exists($siteModule)) { unlink($siteModule); } //delete db config file if (file_exists($dbConfigFile)) { unlink($dbConfigFile); } // clear session $container->getManager()->destroy(); $success = 1; } return new JsonModel([ 'success' => $success, ]); }
php
public function rollBackAction() { $success = 0; $errors = []; $installHelper = $this->getServiceLocator()->get('InstallerHelper'); $container = new Container('melisinstaller'); if (!empty($container->getArrayCopy()) && in_array(array_keys($container['steps']), [$this->steps])) { $tablesInstalled = isset($container['db_install_tables']) ? $container['db_install_tables'] : []; $siteModule = 'module/MelisSites/' . $container['cms_data']['website_module'] . '/'; $dbConfigFile = 'config/autoload/platforms/' . $installHelper->getMelisPlatform() . '.php'; $config = include($dbConfigFile); // drop table $installHelper->setDbAdapter($config['db']); foreach ($tablesInstalled as $table) { if ($installHelper->isDbTableExists($table)) { $installHelper->executeRawQuery("DROP TABLE " . trim($table)); } } // delete site module if (file_exists($siteModule)) { unlink($siteModule); } //delete db config file if (file_exists($dbConfigFile)) { unlink($dbConfigFile); } // clear session $container->getManager()->destroy(); $success = 1; } return new JsonModel([ 'success' => $success, ]); }
[ "public", "function", "rollBackAction", "(", ")", "{", "$", "success", "=", "0", ";", "$", "errors", "=", "[", "]", ";", "$", "installHelper", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'InstallerHelper'", ")", ";", "$", ...
Execute this when setup has errors or setup has failed
[ "Execute", "this", "when", "setup", "has", "errors", "or", "setup", "has", "failed" ]
f34d925b847c1389a5498844fdae890eeb34e461
https://github.com/melisplatform/melis-installer/blob/f34d925b847c1389a5498844fdae890eeb34e461/src/Controller/InstallerController.php#L1724-L1766
train
melisplatform/melis-installer
src/Controller/InstallerController.php
InstallerController.hasMelisCmsModule
protected function hasMelisCmsModule() { $modulesSvc = $this->getServiceLocator()->get('MelisAssetManagerModulesService'); $modules = $modulesSvc->getAllModules(); $path = $modulesSvc->getModulePath('MelisCms'); $isExists = 0; if (file_exists($path)) { $isExists = 1; } return $isExists; }
php
protected function hasMelisCmsModule() { $modulesSvc = $this->getServiceLocator()->get('MelisAssetManagerModulesService'); $modules = $modulesSvc->getAllModules(); $path = $modulesSvc->getModulePath('MelisCms'); $isExists = 0; if (file_exists($path)) { $isExists = 1; } return $isExists; }
[ "protected", "function", "hasMelisCmsModule", "(", ")", "{", "$", "modulesSvc", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'MelisAssetManagerModulesService'", ")", ";", "$", "modules", "=", "$", "modulesSvc", "->", "getAllModules",...
Checks if the current project has MelisCms Module @return Array
[ "Checks", "if", "the", "current", "project", "has", "MelisCms", "Module" ]
f34d925b847c1389a5498844fdae890eeb34e461
https://github.com/melisplatform/melis-installer/blob/f34d925b847c1389a5498844fdae890eeb34e461/src/Controller/InstallerController.php#L1806-L1818
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/Config/Ui/Fields/TextListField.php
TextListField.build
public function build(ConfigInterface $config, $width, ManialinkInterface $manialink, ManialinkFactory $manialinkFactory): Renderable { $input = $this ->uiFactory ->createInput($config->getPath(), '') ->setWidth($width * 0.66); $addButton = $this->uiFactory ->createButton('Add') ->setWidth($width * 0.33) ->setAction( $this->actionFactory->createManialinkAction( $manialink, function (ManialinkInterface $manialink, $login, $entries, $args) use ($manialinkFactory) { /** @var TextListConfig $config */ $config = $args['config']; if (!empty($entries[$config->getPath()])) { $config->add(trim($entries[$config->getPath()])); $manialinkFactory->update($manialink->getUserGroup()); } }, ['config' => $config] ) ); $elements = [$this->uiFactory->createLayoutLine(0,0, [$input, $addButton])]; foreach ($config->get() as $element) { $elements[] = $this->getElementLine($config, $manialink, $element, $width, $manialinkFactory); } return $this->uiFactory->createLayoutRow(0, 0, $elements, 0.5); }
php
public function build(ConfigInterface $config, $width, ManialinkInterface $manialink, ManialinkFactory $manialinkFactory): Renderable { $input = $this ->uiFactory ->createInput($config->getPath(), '') ->setWidth($width * 0.66); $addButton = $this->uiFactory ->createButton('Add') ->setWidth($width * 0.33) ->setAction( $this->actionFactory->createManialinkAction( $manialink, function (ManialinkInterface $manialink, $login, $entries, $args) use ($manialinkFactory) { /** @var TextListConfig $config */ $config = $args['config']; if (!empty($entries[$config->getPath()])) { $config->add(trim($entries[$config->getPath()])); $manialinkFactory->update($manialink->getUserGroup()); } }, ['config' => $config] ) ); $elements = [$this->uiFactory->createLayoutLine(0,0, [$input, $addButton])]; foreach ($config->get() as $element) { $elements[] = $this->getElementLine($config, $manialink, $element, $width, $manialinkFactory); } return $this->uiFactory->createLayoutRow(0, 0, $elements, 0.5); }
[ "public", "function", "build", "(", "ConfigInterface", "$", "config", ",", "$", "width", ",", "ManialinkInterface", "$", "manialink", ",", "ManialinkFactory", "$", "manialinkFactory", ")", ":", "Renderable", "{", "$", "input", "=", "$", "this", "->", "uiFactor...
Create interface for the config value. @param ConfigInterface $config @return Renderable
[ "Create", "interface", "for", "the", "config", "value", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Config/Ui/Fields/TextListField.php#L48-L80
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/Config/Ui/Fields/TextListField.php
TextListField.getElementLine
protected function getElementLine($config, $manialink, $element, $width, $manialinkFactory) { $label = $this->uiFactory ->createLabel($this->getElementName($element)) ->setX(2) ->setWidth($width * 0.66); $delButton = $this->uiFactory ->createButton('Remove') ->setWidth($width * 0.33) ->setAction( $this->actionFactory->createManialinkAction( $manialink, function (ManialinkInterface $manialink, $login, $entries, $args) use ($manialinkFactory) { /** @var TextListConfig $config */ $config = $args['config']; $config->remove($args['element']); $manialinkFactory->update($manialink->getUserGroup()); }, ['config' => $config, 'element' => $element] ) ); return $this->uiFactory->createLayoutLine(0,0, [$label, $delButton]); }
php
protected function getElementLine($config, $manialink, $element, $width, $manialinkFactory) { $label = $this->uiFactory ->createLabel($this->getElementName($element)) ->setX(2) ->setWidth($width * 0.66); $delButton = $this->uiFactory ->createButton('Remove') ->setWidth($width * 0.33) ->setAction( $this->actionFactory->createManialinkAction( $manialink, function (ManialinkInterface $manialink, $login, $entries, $args) use ($manialinkFactory) { /** @var TextListConfig $config */ $config = $args['config']; $config->remove($args['element']); $manialinkFactory->update($manialink->getUserGroup()); }, ['config' => $config, 'element' => $element] ) ); return $this->uiFactory->createLayoutLine(0,0, [$label, $delButton]); }
[ "protected", "function", "getElementLine", "(", "$", "config", ",", "$", "manialink", ",", "$", "element", ",", "$", "width", ",", "$", "manialinkFactory", ")", "{", "$", "label", "=", "$", "this", "->", "uiFactory", "->", "createLabel", "(", "$", "this"...
Get the display of a single line. @param $config @param $manialink @param $element @param $width @param $manialinkFactory @return \eXpansion\Framework\Gui\Layouts\LayoutLine
[ "Get", "the", "display", "of", "a", "single", "line", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Config/Ui/Fields/TextListField.php#L93-L117
train
CottaCush/yii2-widgets
src/Widgets/ActionButtons.php
ActionButtons.renderActions
private function renderActions() { $this->beginButtonGroup(); foreach ($this->visibleActions as $action) { $label = ArrayHelper::getValue($action, $this->actionLabelProperty, ''); $url = ArrayHelper::getValue($action, $this->actionUrlProperty, null); $options = ArrayHelper::getValue($action, $this->actionOptionsProperty, []); // Use $this->buttonClasses as base classes, then override with any classes specified in options $actionClasses = ArrayHelper::getValue($options, 'class', []); $options['class'] = $this->linkClasses; Html::addCssClass($options, $actionClasses); echo Html::a($label, $url, $options); } $this->endButtonGroup(); }
php
private function renderActions() { $this->beginButtonGroup(); foreach ($this->visibleActions as $action) { $label = ArrayHelper::getValue($action, $this->actionLabelProperty, ''); $url = ArrayHelper::getValue($action, $this->actionUrlProperty, null); $options = ArrayHelper::getValue($action, $this->actionOptionsProperty, []); // Use $this->buttonClasses as base classes, then override with any classes specified in options $actionClasses = ArrayHelper::getValue($options, 'class', []); $options['class'] = $this->linkClasses; Html::addCssClass($options, $actionClasses); echo Html::a($label, $url, $options); } $this->endButtonGroup(); }
[ "private", "function", "renderActions", "(", ")", "{", "$", "this", "->", "beginButtonGroup", "(", ")", ";", "foreach", "(", "$", "this", "->", "visibleActions", "as", "$", "action", ")", "{", "$", "label", "=", "ArrayHelper", "::", "getValue", "(", "$",...
Render the actions as separate links
[ "Render", "the", "actions", "as", "separate", "links" ]
e13c09e8d78e3a01b3d64cdb53abba9d41db6277
https://github.com/CottaCush/yii2-widgets/blob/e13c09e8d78e3a01b3d64cdb53abba9d41db6277/src/Widgets/ActionButtons.php#L109-L125
train
CottaCush/yii2-widgets
src/Widgets/ActionButtons.php
ActionButtons.renderActionButton
private function renderActionButton() { $actionButtonOptions = $this->actionButtonOptions; Html::addCssClass($actionButtonOptions, $this->linkClasses); $this->beginButtonGroup(); echo Html::button($this->actionsButtonLabel . $this->caretHtml, $actionButtonOptions); echo Html::beginTag('ul', ['class' => 'dropdown-menu dropdown-menu-right']); foreach ($this->visibleActions as $action) { $label = ArrayHelper::getValue($action, $this->actionLabelProperty, ''); $url = ArrayHelper::getValue($action, $this->actionUrlProperty, null); $options = ArrayHelper::getValue($action, $this->actionOptionsProperty, []); echo Html::tag('li', Html::a($label, $url, $options)); } echo Html::endTag('ul'); $this->endButtonGroup(); }
php
private function renderActionButton() { $actionButtonOptions = $this->actionButtonOptions; Html::addCssClass($actionButtonOptions, $this->linkClasses); $this->beginButtonGroup(); echo Html::button($this->actionsButtonLabel . $this->caretHtml, $actionButtonOptions); echo Html::beginTag('ul', ['class' => 'dropdown-menu dropdown-menu-right']); foreach ($this->visibleActions as $action) { $label = ArrayHelper::getValue($action, $this->actionLabelProperty, ''); $url = ArrayHelper::getValue($action, $this->actionUrlProperty, null); $options = ArrayHelper::getValue($action, $this->actionOptionsProperty, []); echo Html::tag('li', Html::a($label, $url, $options)); } echo Html::endTag('ul'); $this->endButtonGroup(); }
[ "private", "function", "renderActionButton", "(", ")", "{", "$", "actionButtonOptions", "=", "$", "this", "->", "actionButtonOptions", ";", "Html", "::", "addCssClass", "(", "$", "actionButtonOptions", ",", "$", "this", "->", "linkClasses", ")", ";", "$", "thi...
Render the action button dropdown
[ "Render", "the", "action", "button", "dropdown" ]
e13c09e8d78e3a01b3d64cdb53abba9d41db6277
https://github.com/CottaCush/yii2-widgets/blob/e13c09e8d78e3a01b3d64cdb53abba9d41db6277/src/Widgets/ActionButtons.php#L130-L150
train
Corviz/framework
src/File/File.php
File.copy
public function copy(string $destination, $overwrite = false) : bool { $copied = false; if ($this->isFile()) { $exists = file_exists($destination); if (!$exists || ($exists && $overwrite)) { $copied = copy($this->realPath, $destination); } } return $copied; }
php
public function copy(string $destination, $overwrite = false) : bool { $copied = false; if ($this->isFile()) { $exists = file_exists($destination); if (!$exists || ($exists && $overwrite)) { $copied = copy($this->realPath, $destination); } } return $copied; }
[ "public", "function", "copy", "(", "string", "$", "destination", ",", "$", "overwrite", "=", "false", ")", ":", "bool", "{", "$", "copied", "=", "false", ";", "if", "(", "$", "this", "->", "isFile", "(", ")", ")", "{", "$", "exists", "=", "file_exi...
Copy the current source to destination. @param string $destination @param bool $overwrite @return bool
[ "Copy", "the", "current", "source", "to", "destination", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/File/File.php#L23-L35
train
Corviz/framework
src/File/File.php
File.delete
public function delete() : bool { $removed = null; if ($this->isDirectory()) { $removed = rmdir($this->realPath); } else { $removed = unlink($this->realPath); } return $removed; }
php
public function delete() : bool { $removed = null; if ($this->isDirectory()) { $removed = rmdir($this->realPath); } else { $removed = unlink($this->realPath); } return $removed; }
[ "public", "function", "delete", "(", ")", ":", "bool", "{", "$", "removed", "=", "null", ";", "if", "(", "$", "this", "->", "isDirectory", "(", ")", ")", "{", "$", "removed", "=", "rmdir", "(", "$", "this", "->", "realPath", ")", ";", "}", "else"...
Remove a file from the disk. @return bool
[ "Remove", "a", "file", "from", "the", "disk", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/File/File.php#L42-L53
train
Corviz/framework
src/File/File.php
File.getSize
public function getSize() : int { $size = -1; if ($this->isFile()) { $size = filesize($this->realPath); } return $size; }
php
public function getSize() : int { $size = -1; if ($this->isFile()) { $size = filesize($this->realPath); } return $size; }
[ "public", "function", "getSize", "(", ")", ":", "int", "{", "$", "size", "=", "-", "1", ";", "if", "(", "$", "this", "->", "isFile", "(", ")", ")", "{", "$", "size", "=", "filesize", "(", "$", "this", "->", "realPath", ")", ";", "}", "return", ...
Gets the size of a file. If the current source is not a file, returns -1. @return int
[ "Gets", "the", "size", "of", "a", "file", ".", "If", "the", "current", "source", "is", "not", "a", "file", "returns", "-", "1", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/File/File.php#L94-L103
train
Corviz/framework
src/File/File.php
File.read
public function read() { $contents = false; if ($this->isFile() && $this->isReadable()) { $contents = file_get_contents($this->realPath); } return $contents; }
php
public function read() { $contents = false; if ($this->isFile() && $this->isReadable()) { $contents = file_get_contents($this->realPath); } return $contents; }
[ "public", "function", "read", "(", ")", "{", "$", "contents", "=", "false", ";", "if", "(", "$", "this", "->", "isFile", "(", ")", "&&", "$", "this", "->", "isReadable", "(", ")", ")", "{", "$", "contents", "=", "file_get_contents", "(", "$", "this...
Read the file contents, based on PHP file_get_contents function This function will return a string containing the contents, or FALSE on failure. @return bool|string
[ "Read", "the", "file", "contents", "based", "on", "PHP", "file_get_contents", "function", "This", "function", "will", "return", "a", "string", "containing", "the", "contents", "or", "FALSE", "on", "failure", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/File/File.php#L152-L161
train
Corviz/framework
src/File/File.php
File.rename
public function rename(string $newName) : bool { $renamed = rename($this->realPath, $newName); if ($renamed) { $this->realPath = realpath($newName); } return $renamed; }
php
public function rename(string $newName) : bool { $renamed = rename($this->realPath, $newName); if ($renamed) { $this->realPath = realpath($newName); } return $renamed; }
[ "public", "function", "rename", "(", "string", "$", "newName", ")", ":", "bool", "{", "$", "renamed", "=", "rename", "(", "$", "this", "->", "realPath", ",", "$", "newName", ")", ";", "if", "(", "$", "renamed", ")", "{", "$", "this", "->", "realPat...
Give the source a new name. @param string $newName @return bool
[ "Give", "the", "source", "a", "new", "name", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/File/File.php#L170-L179
train
byjg/xmlnuke
xmlnuke-php5/src/Xmlnuke/Core/Engine/AutoLoad.php
AutoLoad.autoLoad_XmlnukeFramework
protected function autoLoad_XmlnukeFramework($className) { foreach (AutoLoad::$_folders[AutoLoad::FRAMEWORK_XMLNUKE] as $prefix) { // PSR-0 Classes // convert namespace to full file path $class = PHPXMLNUKEDIR . $prefix . str_replace('\\', '/', $className); $class = ( file_exists("$class.php") ? "$class.php" : ( file_exists("$class.class.php") ? "$class.class.php" : null ) ); if (!empty($class) && \Xmlnuke\Util\FileUtil::isReadable($class)) { require_once($class); break; } } }
php
protected function autoLoad_XmlnukeFramework($className) { foreach (AutoLoad::$_folders[AutoLoad::FRAMEWORK_XMLNUKE] as $prefix) { // PSR-0 Classes // convert namespace to full file path $class = PHPXMLNUKEDIR . $prefix . str_replace('\\', '/', $className); $class = ( file_exists("$class.php") ? "$class.php" : ( file_exists("$class.class.php") ? "$class.class.php" : null ) ); if (!empty($class) && \Xmlnuke\Util\FileUtil::isReadable($class)) { require_once($class); break; } } }
[ "protected", "function", "autoLoad_XmlnukeFramework", "(", "$", "className", ")", "{", "foreach", "(", "AutoLoad", "::", "$", "_folders", "[", "AutoLoad", "::", "FRAMEWORK_XMLNUKE", "]", "as", "$", "prefix", ")", "{", "// PSR-0 Classes", "// convert namespace to ful...
Auto Load method for Core Xmlnuke and 3rd Party
[ "Auto", "Load", "method", "for", "Core", "Xmlnuke", "and", "3rd", "Party" ]
aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7
https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Core/Engine/AutoLoad.php#L74-L97
train
byjg/xmlnuke
xmlnuke-php5/src/Xmlnuke/Core/Engine/AutoLoad.php
AutoLoad.autoLoad_UserProjects
protected function autoLoad_UserProjects($className) { $class = str_replace('\\', '/', ($className[0] == '\\' ? substr($className, 1) : $className)); foreach (AutoLoad::$_folders[AutoLoad::USER_PROJECTS] as $libName => $libDir) { $file = $libDir . '/' . $class; $file = ( file_exists("$file.php") ? "$file.php" : ( file_exists("$file.class.php") ? "$file.class.php" : null ) ); if (!empty($file) && \Xmlnuke\Util\FileUtil::isReadable($file)) { require_once $file; return; } } return; }
php
protected function autoLoad_UserProjects($className) { $class = str_replace('\\', '/', ($className[0] == '\\' ? substr($className, 1) : $className)); foreach (AutoLoad::$_folders[AutoLoad::USER_PROJECTS] as $libName => $libDir) { $file = $libDir . '/' . $class; $file = ( file_exists("$file.php") ? "$file.php" : ( file_exists("$file.class.php") ? "$file.class.php" : null ) ); if (!empty($file) && \Xmlnuke\Util\FileUtil::isReadable($file)) { require_once $file; return; } } return; }
[ "protected", "function", "autoLoad_UserProjects", "(", "$", "className", ")", "{", "$", "class", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "(", "$", "className", "[", "0", "]", "==", "'\\\\'", "?", "substr", "(", "$", "className", ",", "1", "...
MODULES HAVE AN SPECIAL WAY OF LOAD.
[ "MODULES", "HAVE", "AN", "SPECIAL", "WAY", "OF", "LOAD", "." ]
aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7
https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Core/Engine/AutoLoad.php#L101-L126
train
TheBnl/event-tickets
code/checkout/PaymentProcessor.php
PaymentProcessor.createPayment
public function createPayment($gateway) { if (!GatewayInfo::isSupported($gateway)) { user_error(_t( "PaymentProcessor.INVALID_GATEWAY", "`{gateway}` is not supported.", null, array('gateway' => (string)$gateway) ), E_USER_ERROR); } // Create a payment $this->payment = Payment::create()->init( $gateway, $this->reservation->Total, self::config()->get('currency') ); // Set a reference to the reservation $this->payment->ReservationID = $this->reservation->ID; return $this->payment; }
php
public function createPayment($gateway) { if (!GatewayInfo::isSupported($gateway)) { user_error(_t( "PaymentProcessor.INVALID_GATEWAY", "`{gateway}` is not supported.", null, array('gateway' => (string)$gateway) ), E_USER_ERROR); } // Create a payment $this->payment = Payment::create()->init( $gateway, $this->reservation->Total, self::config()->get('currency') ); // Set a reference to the reservation $this->payment->ReservationID = $this->reservation->ID; return $this->payment; }
[ "public", "function", "createPayment", "(", "$", "gateway", ")", "{", "if", "(", "!", "GatewayInfo", "::", "isSupported", "(", "$", "gateway", ")", ")", "{", "user_error", "(", "_t", "(", "\"PaymentProcessor.INVALID_GATEWAY\"", ",", "\"`{gateway}` is not supported...
Create a payment trough the given payment gateway @param string $gateway @return Payment
[ "Create", "a", "payment", "trough", "the", "given", "payment", "gateway" ]
d18db4146a141795fd50689057130a6fd41ac397
https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/checkout/PaymentProcessor.php#L94-L116
train
TheBnl/event-tickets
code/checkout/PaymentProcessor.php
PaymentProcessor.createServiceFactory
public function createServiceFactory() { $factory = ServiceFactory::create(); $service = $factory->getService($this->payment, ServiceFactory::INTENT_PAYMENT); try { $serviceResponse = $service->initiate($this->getGatewayData()); } catch (Exception $ex) { // error out when an exception occurs user_error($ex->getMessage(), E_USER_WARNING); return null; } return $serviceResponse; }
php
public function createServiceFactory() { $factory = ServiceFactory::create(); $service = $factory->getService($this->payment, ServiceFactory::INTENT_PAYMENT); try { $serviceResponse = $service->initiate($this->getGatewayData()); } catch (Exception $ex) { // error out when an exception occurs user_error($ex->getMessage(), E_USER_WARNING); return null; } return $serviceResponse; }
[ "public", "function", "createServiceFactory", "(", ")", "{", "$", "factory", "=", "ServiceFactory", "::", "create", "(", ")", ";", "$", "service", "=", "$", "factory", "->", "getService", "(", "$", "this", "->", "payment", ",", "ServiceFactory", "::", "INT...
Create the service factory Catch any exceptions that might occur @return null|ServiceResponse
[ "Create", "the", "service", "factory", "Catch", "any", "exceptions", "that", "might", "occur" ]
d18db4146a141795fd50689057130a6fd41ac397
https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/checkout/PaymentProcessor.php#L124-L138
train
joshiausdemwald/Force.com-Toolkit-for-PHP-5.3
Soap/Client/Connection/Hydrator/SfdcResultHydrator.php
SfdcResultHydrator.doHydrateList
public function doHydrateList(array $list, $parentKey = null) { $retVal = parent::doHydrateList($list, $parentKey); if('Id' === $parentKey) { if($retVal->count() > 0) { return $retVal->get(0); } return null; } return $retVal; }
php
public function doHydrateList(array $list, $parentKey = null) { $retVal = parent::doHydrateList($list, $parentKey); if('Id' === $parentKey) { if($retVal->count() > 0) { return $retVal->get(0); } return null; } return $retVal; }
[ "public", "function", "doHydrateList", "(", "array", "$", "list", ",", "$", "parentKey", "=", "null", ")", "{", "$", "retVal", "=", "parent", "::", "doHydrateList", "(", "$", "list", ",", "$", "parentKey", ")", ";", "if", "(", "'Id'", "===", "$", "pa...
Regard duplicate Id attributes that come as a list, transform into single result. @param array $list @param string|null $parentKey @return mixed
[ "Regard", "duplicate", "Id", "attributes", "that", "come", "as", "a", "list", "transform", "into", "single", "result", "." ]
7fd3194eb3155f019e34439e586e6baf6cbb202f
https://github.com/joshiausdemwald/Force.com-Toolkit-for-PHP-5.3/blob/7fd3194eb3155f019e34439e586e6baf6cbb202f/Soap/Client/Connection/Hydrator/SfdcResultHydrator.php#L17-L30
train
ansas/php-component
src/Component/Collection/Collection.php
Collection.remove
public function remove($key, $remove = true) { if ($remove && $this->has($key, self::HAS_EXISTS)) { $key = $this->normalizeKey($key); unset($this->data[$key]); } return $this; }
php
public function remove($key, $remove = true) { if ($remove && $this->has($key, self::HAS_EXISTS)) { $key = $this->normalizeKey($key); unset($this->data[$key]); } return $this; }
[ "public", "function", "remove", "(", "$", "key", ",", "$", "remove", "=", "true", ")", "{", "if", "(", "$", "remove", "&&", "$", "this", "->", "has", "(", "$", "key", ",", "self", "::", "HAS_EXISTS", ")", ")", "{", "$", "key", "=", "$", "this",...
Removes specified collection item. @param mixed $key The item key. @param bool $remove [optional] Conditional remove statement. @return $this
[ "Removes", "specified", "collection", "item", "." ]
24574a1e32d5f1355a6e2b6f20f49b1eda7250ba
https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/Collection/Collection.php#L475-L483
train
ansas/php-component
src/Component/Collection/Collection.php
Collection.removeEmpty
public function removeEmpty($considerEmpty = ['']) { foreach ($this->all() as $key => $value) { if (!is_scalar($value) && !is_null($value)) { continue; } foreach ($considerEmpty as $empty) { if ($value === $empty) { $this->remove($key); break; } } } return $this; }
php
public function removeEmpty($considerEmpty = ['']) { foreach ($this->all() as $key => $value) { if (!is_scalar($value) && !is_null($value)) { continue; } foreach ($considerEmpty as $empty) { if ($value === $empty) { $this->remove($key); break; } } } return $this; }
[ "public", "function", "removeEmpty", "(", "$", "considerEmpty", "=", "[", "''", "]", ")", "{", "foreach", "(", "$", "this", "->", "all", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "is_scalar", "(", "$", "value", ")"...
Removes empty collection items. @param array $considerEmpty [optional] @return $this
[ "Removes", "empty", "collection", "items", "." ]
24574a1e32d5f1355a6e2b6f20f49b1eda7250ba
https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/Collection/Collection.php#L492-L507
train
ansas/php-component
src/Component/Collection/Collection.php
Collection.sort
public function sort($sortBy = self::SORT_BY_KEYS_ASC, $sortFlags = SORT_REGULAR) { /** @noinspection SpellCheckingInspection */ $sortFunctions = [ self::SORT_BY_KEYS_ASC => 'ksort', self::SORT_BY_KEYS_DESC => 'krsort', self::SORT_BY_VALUES_ASC => 'asort', self::SORT_BY_VALUES_DESC => 'arsort', ]; if (!isset($sortFunctions[$sortBy])) { throw new InvalidArgumentException("SortBy {$sortBy} not supported"); } $function = $sortFunctions[$sortBy]; $function($this->data, $sortFlags); return $this; }
php
public function sort($sortBy = self::SORT_BY_KEYS_ASC, $sortFlags = SORT_REGULAR) { /** @noinspection SpellCheckingInspection */ $sortFunctions = [ self::SORT_BY_KEYS_ASC => 'ksort', self::SORT_BY_KEYS_DESC => 'krsort', self::SORT_BY_VALUES_ASC => 'asort', self::SORT_BY_VALUES_DESC => 'arsort', ]; if (!isset($sortFunctions[$sortBy])) { throw new InvalidArgumentException("SortBy {$sortBy} not supported"); } $function = $sortFunctions[$sortBy]; $function($this->data, $sortFlags); return $this; }
[ "public", "function", "sort", "(", "$", "sortBy", "=", "self", "::", "SORT_BY_KEYS_ASC", ",", "$", "sortFlags", "=", "SORT_REGULAR", ")", "{", "/** @noinspection SpellCheckingInspection */", "$", "sortFunctions", "=", "[", "self", "::", "SORT_BY_KEYS_ASC", "=>", "...
Sort collection. @param int $sortBy Sort by flag (see self::SORT_ constants) @param int $sortFlags Sort flags (see PHP SORT_ constants) @return $this @throws InvalidArgumentException
[ "Sort", "collection", "." ]
24574a1e32d5f1355a6e2b6f20f49b1eda7250ba
https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/Collection/Collection.php#L588-L606
train
byjg/xmlnuke
xmlnuke-php5/src/Xmlnuke/Modules/XSLTheme.php
XSLTheme.generateList
private function generateList($caption, $paragraph, $filelist, $xslUsed, $xsl) { $paragraph->addXmlnukeObject(new XmlnukeText($caption,true)); $listCollection = new XmlListCollection(XmlListType::UnorderedList ); $paragraph->addXmlnukeObject($listCollection); foreach($filelist as $file) { $xslname = FileUtil::ExtractFileName($file); $xslname = $xsl->removeLanguage($xslname); if(!in_array ($xslname, $xslUsed)) { $objectList = new XmlnukeSpanCollection(); $listCollection->addXmlnukeObject($objectList); $xslUsed[] = $xslname; if ($xslname == "index") { $anchor = new XmlAnchorCollection("engine:xmlnuke?xml=index&xsl=index"); $anchor->addXmlnukeObject(new XmlnukeText($xslname,true)); $objectList->addXmlnukeObject($anchor); } else { $anchor = new XmlAnchorCollection("module:Xmlnuke.XSLTheme?xsl=" . $xslname); $anchor->addXmlnukeObject(new XmlnukeText($xslname,true)); $objectList->addXmlnukeObject($anchor); } } } }
php
private function generateList($caption, $paragraph, $filelist, $xslUsed, $xsl) { $paragraph->addXmlnukeObject(new XmlnukeText($caption,true)); $listCollection = new XmlListCollection(XmlListType::UnorderedList ); $paragraph->addXmlnukeObject($listCollection); foreach($filelist as $file) { $xslname = FileUtil::ExtractFileName($file); $xslname = $xsl->removeLanguage($xslname); if(!in_array ($xslname, $xslUsed)) { $objectList = new XmlnukeSpanCollection(); $listCollection->addXmlnukeObject($objectList); $xslUsed[] = $xslname; if ($xslname == "index") { $anchor = new XmlAnchorCollection("engine:xmlnuke?xml=index&xsl=index"); $anchor->addXmlnukeObject(new XmlnukeText($xslname,true)); $objectList->addXmlnukeObject($anchor); } else { $anchor = new XmlAnchorCollection("module:Xmlnuke.XSLTheme?xsl=" . $xslname); $anchor->addXmlnukeObject(new XmlnukeText($xslname,true)); $objectList->addXmlnukeObject($anchor); } } } }
[ "private", "function", "generateList", "(", "$", "caption", ",", "$", "paragraph", ",", "$", "filelist", ",", "$", "xslUsed", ",", "$", "xsl", ")", "{", "$", "paragraph", "->", "addXmlnukeObject", "(", "new", "XmlnukeText", "(", "$", "caption", ",", "tru...
Create and show the list of Xsl Templates @param String $caption @param XmlParagraphCollection $paragraph @param Array $filelist @param Array $xslUsed @param XSLFilenameProcessor $xsl
[ "Create", "and", "show", "the", "list", "of", "Xsl", "Templates" ]
aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7
https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Modules/XSLTheme.php#L129-L160
train
vube/php-filesystem
src/Vube/FileSystem/PathTranslator.php
PathTranslator.translate
function translate($path) { if(static::isWindowsOS()) { if(preg_match('%^([A-Z]):(.*)%', $path, $matches)) { // $path contains something like 'C:' at the start, // so it's an absolute path from the root. $drive = $matches[1]; $file = $matches[2]; $unixFile = str_replace('\\', '/', $file); if(static::isWindowsMsys()) { $path = '/' . strtolower($drive) . $unixFile; } else if(static::isWindowsCygwin()) { $path = '/cygdrive/' . strtolower($drive) . $unixFile; } } else { // $path does not look like 'C:' so we assume it to be relative if(static::isWindowsMsys() || static::isWindowsCygwin()) $path = str_replace('\\', '/', $path);; } } return $path; }
php
function translate($path) { if(static::isWindowsOS()) { if(preg_match('%^([A-Z]):(.*)%', $path, $matches)) { // $path contains something like 'C:' at the start, // so it's an absolute path from the root. $drive = $matches[1]; $file = $matches[2]; $unixFile = str_replace('\\', '/', $file); if(static::isWindowsMsys()) { $path = '/' . strtolower($drive) . $unixFile; } else if(static::isWindowsCygwin()) { $path = '/cygdrive/' . strtolower($drive) . $unixFile; } } else { // $path does not look like 'C:' so we assume it to be relative if(static::isWindowsMsys() || static::isWindowsCygwin()) $path = str_replace('\\', '/', $path);; } } return $path; }
[ "function", "translate", "(", "$", "path", ")", "{", "if", "(", "static", "::", "isWindowsOS", "(", ")", ")", "{", "if", "(", "preg_match", "(", "'%^([A-Z]):(.*)%'", ",", "$", "path", ",", "$", "matches", ")", ")", "{", "// $path contains something like 'C...
Translate a Windows path into a POSIX path, if necessary. On POSIX systems this does nothing. On Windows+MSYS: "C:\Windows" => "/c/Windows" On Windows+Cygwin: "C:\Windows" => "/cygdrive/c/Windows" @param string $path The input path which may be absolute or relative @return string POSIX path
[ "Translate", "a", "Windows", "path", "into", "a", "POSIX", "path", "if", "necessary", "." ]
147513e8c3809a1d9d947d2753780c0671cc3194
https://github.com/vube/php-filesystem/blob/147513e8c3809a1d9d947d2753780c0671cc3194/src/Vube/FileSystem/PathTranslator.php#L27-L58
train
BR0kEN-/behat-debug-extension
src/ServiceContainer/DebugExtension.php
DebugExtension.definition
private function definition(ContainerBuilder $container, $class, $tag, array $arguments = []) { $definition = new Definition(strtr(__NAMESPACE__, ['ServiceContainer' => $class]), $arguments); return $container ->setDefinition($tag . '.' . self::id($class), $definition) ->addTag($tag); }
php
private function definition(ContainerBuilder $container, $class, $tag, array $arguments = []) { $definition = new Definition(strtr(__NAMESPACE__, ['ServiceContainer' => $class]), $arguments); return $container ->setDefinition($tag . '.' . self::id($class), $definition) ->addTag($tag); }
[ "private", "function", "definition", "(", "ContainerBuilder", "$", "container", ",", "$", "class", ",", "$", "tag", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "$", "definition", "=", "new", "Definition", "(", "strtr", "(", "__NAMESPACE__", ...
Define a new service in DI container. @param ContainerBuilder $container DI container. @param string $class Class in namespace of extension. @param string $tag Tag of the definition. @param array $arguments Dependency arguments. @return Definition Tagged definition.
[ "Define", "a", "new", "service", "in", "DI", "container", "." ]
5dcb1e01bdbb19246009eaa805c53b33a76ddfe1
https://github.com/BR0kEN-/behat-debug-extension/blob/5dcb1e01bdbb19246009eaa805c53b33a76ddfe1/src/ServiceContainer/DebugExtension.php#L75-L82
train
Corviz/framework
src/DI/Container.php
Container.invoke
public function invoke( $obj, string $method, array $params = [] ) { if (is_string($obj)) { //Attempt to retrieve object from //the container. $obj = $this->get($obj); } elseif (!is_object($obj)) { //Not a valid argument. throw new \Exception('Invalid object'); } $map = $this->generateArgumentsMap( $obj, $method, $params ); $mapParams = $this->getParamsFromMap($map); return $obj->$method(...$mapParams); }
php
public function invoke( $obj, string $method, array $params = [] ) { if (is_string($obj)) { //Attempt to retrieve object from //the container. $obj = $this->get($obj); } elseif (!is_object($obj)) { //Not a valid argument. throw new \Exception('Invalid object'); } $map = $this->generateArgumentsMap( $obj, $method, $params ); $mapParams = $this->getParamsFromMap($map); return $obj->$method(...$mapParams); }
[ "public", "function", "invoke", "(", "$", "obj", ",", "string", "$", "method", ",", "array", "$", "params", "=", "[", "]", ")", "{", "if", "(", "is_string", "(", "$", "obj", ")", ")", "{", "//Attempt to retrieve object from", "//the container.", "$", "ob...
Calls an object method, injecting its dependencies. @param mixed $obj @param string $method @param array $params @throws \Exception @return mixed
[ "Calls", "an", "object", "method", "injecting", "its", "dependencies", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/DI/Container.php#L67-L89
train
Corviz/framework
src/DI/Container.php
Container.build
private function build(string $name) { $instance = null; $map = $this->map[$name]; if (is_array($map)) { $params = $this->getParamsFromMap($map); $instance = new $name(...$params); } elseif ($map instanceof \Closure) { $instance = $map($this); } elseif (is_object($map)) { $instance = $map; } elseif (is_string($map)) { $instance = $this->get($map); } else { throw new \Exception('Invalid map'); } return $instance; }
php
private function build(string $name) { $instance = null; $map = $this->map[$name]; if (is_array($map)) { $params = $this->getParamsFromMap($map); $instance = new $name(...$params); } elseif ($map instanceof \Closure) { $instance = $map($this); } elseif (is_object($map)) { $instance = $map; } elseif (is_string($map)) { $instance = $this->get($map); } else { throw new \Exception('Invalid map'); } return $instance; }
[ "private", "function", "build", "(", "string", "$", "name", ")", "{", "$", "instance", "=", "null", ";", "$", "map", "=", "$", "this", "->", "map", "[", "$", "name", "]", ";", "if", "(", "is_array", "(", "$", "map", ")", ")", "{", "$", "params"...
Build an object according to the map information. @param string $name @throws \Exception @return object
[ "Build", "an", "object", "according", "to", "the", "map", "information", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/DI/Container.php#L125-L144
train
seboettg/Collection
src/Seboettg/Collection/Collections.php
Collections.sort
public static function sort(ArrayList &$list, Comparator $comparator) { $array = $list->toArray(); usort($array, [$comparator, "compare"]); $list->replace($array); return $list; }
php
public static function sort(ArrayList &$list, Comparator $comparator) { $array = $list->toArray(); usort($array, [$comparator, "compare"]); $list->replace($array); return $list; }
[ "public", "static", "function", "sort", "(", "ArrayList", "&", "$", "list", ",", "Comparator", "$", "comparator", ")", "{", "$", "array", "=", "$", "list", "->", "toArray", "(", ")", ";", "usort", "(", "$", "array", ",", "[", "$", "comparator", ",", ...
Sorts the specified list according to the order induced by the specified comparator. All elements in the list must be mutually comparable. @param ArrayList $list @param Comparator $comparator @return ArrayList
[ "Sorts", "the", "specified", "list", "according", "to", "the", "order", "induced", "by", "the", "specified", "comparator", ".", "All", "elements", "in", "the", "list", "must", "be", "mutually", "comparable", "." ]
d9ca9bf9a52a4d150d162e4a8825e5b9e9e02262
https://github.com/seboettg/Collection/blob/d9ca9bf9a52a4d150d162e4a8825e5b9e9e02262/src/Seboettg/Collection/Collections.php#L32-L38
train
Malwarebytes/Altamira
src/Altamira/Config.php
Config.getPluginPath
public function getPluginPath( $library ) { switch ( $library ) { case \Altamira\JsWriter\Flot::LIBRARY: return $this['js.flotpluginpath']; case \Altamira\JsWriter\JqPlot::LIBRARY: return $this['js.jqplotpluginpath']; } }
php
public function getPluginPath( $library ) { switch ( $library ) { case \Altamira\JsWriter\Flot::LIBRARY: return $this['js.flotpluginpath']; case \Altamira\JsWriter\JqPlot::LIBRARY: return $this['js.jqplotpluginpath']; } }
[ "public", "function", "getPluginPath", "(", "$", "library", ")", "{", "switch", "(", "$", "library", ")", "{", "case", "\\", "Altamira", "\\", "JsWriter", "\\", "Flot", "::", "LIBRARY", ":", "return", "$", "this", "[", "'js.flotpluginpath'", "]", ";", "c...
Provided a library, returns a path for plugins @param string $library @return string
[ "Provided", "a", "library", "returns", "a", "path", "for", "plugins" ]
38e320f68070d7a0b6902c6c3f904995d4a8cdfc
https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/Config.php#L64-L72
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/Core/Services/Application/Dispatcher.php
Dispatcher.reset
public function reset(Map $map) { $this->pluginManager->reset($map); $this->dataProviderManager->reset($this->pluginManager, $map); }
php
public function reset(Map $map) { $this->pluginManager->reset($map); $this->dataProviderManager->reset($this->pluginManager, $map); }
[ "public", "function", "reset", "(", "Map", "$", "map", ")", "{", "$", "this", "->", "pluginManager", "->", "reset", "(", "$", "map", ")", ";", "$", "this", "->", "dataProviderManager", "->", "reset", "(", "$", "this", "->", "pluginManager", ",", "$", ...
Reset the dispatcher elements when game mode changes. @param Map $map Current map. @return void @throws
[ "Reset", "the", "dispatcher", "elements", "when", "game", "mode", "changes", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Services/Application/Dispatcher.php#L73-L77
train
GlobalTradingTechnologies/ad-poller
src/Sync/Events/EventSynchronizer.php
EventSynchronizer.prepareEntriesToDeliver
private function prepareEntriesToDeliver(array $entries) { $binaryAttributes = ['objectguid', 'objectsid']; foreach ($entries as $key => &$entry) { foreach ($binaryAttributes as $binaryAttribute) { if (array_key_exists($binaryAttribute, $entry)) { if (is_array($entry[$binaryAttribute])) { foreach ($entry[$binaryAttribute] as &$value) { $value = bin2hex($value); } } else { $entry[$binaryAttribute] = bin2hex($entry[$binaryAttribute]); } } } } return $entries; }
php
private function prepareEntriesToDeliver(array $entries) { $binaryAttributes = ['objectguid', 'objectsid']; foreach ($entries as $key => &$entry) { foreach ($binaryAttributes as $binaryAttribute) { if (array_key_exists($binaryAttribute, $entry)) { if (is_array($entry[$binaryAttribute])) { foreach ($entry[$binaryAttribute] as &$value) { $value = bin2hex($value); } } else { $entry[$binaryAttribute] = bin2hex($entry[$binaryAttribute]); } } } } return $entries; }
[ "private", "function", "prepareEntriesToDeliver", "(", "array", "$", "entries", ")", "{", "$", "binaryAttributes", "=", "[", "'objectguid'", ",", "'objectsid'", "]", ";", "foreach", "(", "$", "entries", "as", "$", "key", "=>", "&", "$", "entry", ")", "{", ...
Replaces bin values with hex representations in order to be able to deliver entries safely @param array $entries list of entries @return array
[ "Replaces", "bin", "values", "with", "hex", "representations", "in", "order", "to", "be", "able", "to", "deliver", "entries", "safely" ]
c90073b13a6963970e70af67c6439dfe8c48739e
https://github.com/GlobalTradingTechnologies/ad-poller/blob/c90073b13a6963970e70af67c6439dfe8c48739e/src/Sync/Events/EventSynchronizer.php#L84-L103
train
dfeyer/Ttree.Oembed
Classes/Consumer.php
Consumer.consume
public function consume($url, Provider $provider = null, $format = self::FORMAT_DEFAULT) { if ($this->requestParameters instanceof RequestParameters) { $cacheKey = sha1($url . json_encode($this->requestParameters->toArray())); } else { $cacheKey = sha1($url); } // Check if the resource is cached if ($this->resourceCache->has($cacheKey)) { return $this->resourceCache->get($cacheKey); } try { // Try to find a provider matching the supplied URL if no one has been supplied. if (!$provider) { $provider = $this->findProviderForUrl($url); } if ($provider instanceof Provider) { // If a provider was supplied or we found one, store the endpoint URL. $endPoint = $provider->getEndpoint(); } else { // If no provider was found, try to discover the endpoint URL. $discover = new Discoverer(); $endPoint = $discover->getEndpointForUrl($url); } $requestUrl = $this->buildOEmbedRequestUrl($url, $endPoint, $format); $content = $this->browser->getContent($requestUrl); $methodName = 'process' . ucfirst(strtolower($format)) . 'Response'; $resource = $this->$methodName($content); // Save the resource in cache $this->resourceCache->set($cacheKey, $resource); } catch (Exception $exception) { $this->systemLogger->logException($exception); $resource = null; } return $this->postProcessResource($resource); }
php
public function consume($url, Provider $provider = null, $format = self::FORMAT_DEFAULT) { if ($this->requestParameters instanceof RequestParameters) { $cacheKey = sha1($url . json_encode($this->requestParameters->toArray())); } else { $cacheKey = sha1($url); } // Check if the resource is cached if ($this->resourceCache->has($cacheKey)) { return $this->resourceCache->get($cacheKey); } try { // Try to find a provider matching the supplied URL if no one has been supplied. if (!$provider) { $provider = $this->findProviderForUrl($url); } if ($provider instanceof Provider) { // If a provider was supplied or we found one, store the endpoint URL. $endPoint = $provider->getEndpoint(); } else { // If no provider was found, try to discover the endpoint URL. $discover = new Discoverer(); $endPoint = $discover->getEndpointForUrl($url); } $requestUrl = $this->buildOEmbedRequestUrl($url, $endPoint, $format); $content = $this->browser->getContent($requestUrl); $methodName = 'process' . ucfirst(strtolower($format)) . 'Response'; $resource = $this->$methodName($content); // Save the resource in cache $this->resourceCache->set($cacheKey, $resource); } catch (Exception $exception) { $this->systemLogger->logException($exception); $resource = null; } return $this->postProcessResource($resource); }
[ "public", "function", "consume", "(", "$", "url", ",", "Provider", "$", "provider", "=", "null", ",", "$", "format", "=", "self", "::", "FORMAT_DEFAULT", ")", "{", "if", "(", "$", "this", "->", "requestParameters", "instanceof", "RequestParameters", ")", "...
Consume an oEmbed resource using the specified provider if supplied or try to discover the right one. @param string $url The URL of the resource to consume. @param Provider $provider The provider to use. @param string $format The format of the data to fetch. @return AbstractResource An object representation of the oEmbed resource or NULL on error
[ "Consume", "an", "oEmbed", "resource", "using", "the", "specified", "provider", "if", "supplied", "or", "try", "to", "discover", "the", "right", "one", "." ]
1f38d18f51c1abe96c19fe4760acc9ef907194df
https://github.com/dfeyer/Ttree.Oembed/blob/1f38d18f51c1abe96c19fe4760acc9ef907194df/Classes/Consumer.php#L106-L149
train
dfeyer/Ttree.Oembed
Classes/Consumer.php
Consumer.buildOEmbedRequestUrl
protected function buildOEmbedRequestUrl($resource, $endPoint, $format = self::FORMAT_DEFAULT) { $parameters = [ 'url' => $resource, 'format' => $format, 'version' => self::VERSION ]; if ($this->getRequestParameters() !== null) { $parameters = Arrays::arrayMergeRecursiveOverrule($this->getRequestParameters()->toArray(), $parameters); } $urlParams = http_build_query($parameters, '', '&'); $url = $endPoint . ((strpos($endPoint, '?') !== false) ? '&' : '?') . $urlParams; return $url; }
php
protected function buildOEmbedRequestUrl($resource, $endPoint, $format = self::FORMAT_DEFAULT) { $parameters = [ 'url' => $resource, 'format' => $format, 'version' => self::VERSION ]; if ($this->getRequestParameters() !== null) { $parameters = Arrays::arrayMergeRecursiveOverrule($this->getRequestParameters()->toArray(), $parameters); } $urlParams = http_build_query($parameters, '', '&'); $url = $endPoint . ((strpos($endPoint, '?') !== false) ? '&' : '?') . $urlParams; return $url; }
[ "protected", "function", "buildOEmbedRequestUrl", "(", "$", "resource", ",", "$", "endPoint", ",", "$", "format", "=", "self", "::", "FORMAT_DEFAULT", ")", "{", "$", "parameters", "=", "[", "'url'", "=>", "$", "resource", ",", "'format'", "=>", "$", "forma...
Build the oEmbed request URL according to the specification. @param string $resource The URL of the resource to fetch. @param string $endPoint The provider endpoint URL @param string $format The format of the response we'd like to receive. @return string
[ "Build", "the", "oEmbed", "request", "URL", "according", "to", "the", "specification", "." ]
1f38d18f51c1abe96c19fe4760acc9ef907194df
https://github.com/dfeyer/Ttree.Oembed/blob/1f38d18f51c1abe96c19fe4760acc9ef907194df/Classes/Consumer.php#L194-L210
train