id
int32
0
241k
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
16,700
helthe/Chronos
CronExpression.php
CronExpression.matches
public function matches(\DateTime $date) { foreach ($this->fields as $field) { if (!$field->matches($date)) { return false; } } return true; }
php
public function matches(\DateTime $date) { foreach ($this->fields as $field) { if (!$field->matches($date)) { return false; } } return true; }
[ "public", "function", "matches", "(", "\\", "DateTime", "$", "date", ")", "{", "foreach", "(", "$", "this", "->", "fields", "as", "$", "field", ")", "{", "if", "(", "!", "$", "field", "->", "matches", "(", "$", "date", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if the CRON expression matches the given date. @param \DateTime $date @return Boolean
[ "Checks", "if", "the", "CRON", "expression", "matches", "the", "given", "date", "." ]
6c783c55c32b323550fc6f21cd644c2be82720b0
https://github.com/helthe/Chronos/blob/6c783c55c32b323550fc6f21cd644c2be82720b0/CronExpression.php#L109-L118
16,701
helthe/Chronos
CronExpression.php
CronExpression.getField
private function getField($position, $value) { switch ($position) { case 0: return new MinuteField($value); case 1: return new HourField($value); case 2: return new DayOfMonthField($value); case 3: return new MonthField($value); case 4: return new DayOfWeekField($value); case 5: return new YearField($value); default: throw new \InvalidArgumentException(sprintf('%s is not a valid CRON expression position.', $position)); } }
php
private function getField($position, $value) { switch ($position) { case 0: return new MinuteField($value); case 1: return new HourField($value); case 2: return new DayOfMonthField($value); case 3: return new MonthField($value); case 4: return new DayOfWeekField($value); case 5: return new YearField($value); default: throw new \InvalidArgumentException(sprintf('%s is not a valid CRON expression position.', $position)); } }
[ "private", "function", "getField", "(", "$", "position", ",", "$", "value", ")", "{", "switch", "(", "$", "position", ")", "{", "case", "0", ":", "return", "new", "MinuteField", "(", "$", "value", ")", ";", "case", "1", ":", "return", "new", "HourField", "(", "$", "value", ")", ";", "case", "2", ":", "return", "new", "DayOfMonthField", "(", "$", "value", ")", ";", "case", "3", ":", "return", "new", "MonthField", "(", "$", "value", ")", ";", "case", "4", ":", "return", "new", "DayOfWeekField", "(", "$", "value", ")", ";", "case", "5", ":", "return", "new", "YearField", "(", "$", "value", ")", ";", "default", ":", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'%s is not a valid CRON expression position.'", ",", "$", "position", ")", ")", ";", "}", "}" ]
Get the field object for the given position with the given value. @param string $position @param string $value @return FieldInterface @throws \InvalidArgumentException
[ "Get", "the", "field", "object", "for", "the", "given", "position", "with", "the", "given", "value", "." ]
6c783c55c32b323550fc6f21cd644c2be82720b0
https://github.com/helthe/Chronos/blob/6c783c55c32b323550fc6f21cd644c2be82720b0/CronExpression.php#L129-L147
16,702
dunkelfrosch/phpcoverfish
src/PHPCoverFish/CoverFishScanCommand.php
CoverFishScanCommand.configure
protected function configure() { $this ->setName('scan') ->setDescription('scan phpunit test files for static code analysis') ->setHelp($this->getHelpOutput()) ->addArgument( 'phpunit-config', InputArgument::OPTIONAL, 'the source path of your corresponding phpunit xml config file (e.g. ./tests/phpunit.xml)' ) ->addOption( 'phpunit-config-suite', null, InputOption::VALUE_OPTIONAL, 'name of the target test suite inside your php config xml file, this test suite will be scanned' ) ->addOption( 'raw-scan-path', null, InputOption::VALUE_OPTIONAL, 'raw mode option: the source path of your corresponding phpunit test files or a specific testFile (e.g. tests/), this option will always override phpunit.xml settings!' ) ->addOption( 'raw-autoload-file', null, InputOption::VALUE_OPTIONAL, 'raw-mode option: your application autoload file and path (e.g. ../app/autoload.php for running in symfony context), this option will always override phpunit.xml settings!' ) ->addOption( 'raw-exclude-path', null, InputOption::VALUE_OPTIONAL, 'raw-mode option: exclude a specific path from planned scan', null ) ->addOption( 'output-format', 'f', InputOption::VALUE_OPTIONAL, 'output format of scan result (json|text)', 'text' ) ->addOption( 'output-level', 'l', InputOption::VALUE_OPTIONAL, 'level of output information (0:minimal, 1: normal (default), 2: detailed)', 1 ) ->addOption( 'stop-on-error', null, InputOption::VALUE_OPTIONAL, 'stop on first application error raises', false ) ->addOption( 'stop-on-failure', null, InputOption::VALUE_OPTIONAL, 'stop on first detected coverFish failure raises', false ) ; }
php
protected function configure() { $this ->setName('scan') ->setDescription('scan phpunit test files for static code analysis') ->setHelp($this->getHelpOutput()) ->addArgument( 'phpunit-config', InputArgument::OPTIONAL, 'the source path of your corresponding phpunit xml config file (e.g. ./tests/phpunit.xml)' ) ->addOption( 'phpunit-config-suite', null, InputOption::VALUE_OPTIONAL, 'name of the target test suite inside your php config xml file, this test suite will be scanned' ) ->addOption( 'raw-scan-path', null, InputOption::VALUE_OPTIONAL, 'raw mode option: the source path of your corresponding phpunit test files or a specific testFile (e.g. tests/), this option will always override phpunit.xml settings!' ) ->addOption( 'raw-autoload-file', null, InputOption::VALUE_OPTIONAL, 'raw-mode option: your application autoload file and path (e.g. ../app/autoload.php for running in symfony context), this option will always override phpunit.xml settings!' ) ->addOption( 'raw-exclude-path', null, InputOption::VALUE_OPTIONAL, 'raw-mode option: exclude a specific path from planned scan', null ) ->addOption( 'output-format', 'f', InputOption::VALUE_OPTIONAL, 'output format of scan result (json|text)', 'text' ) ->addOption( 'output-level', 'l', InputOption::VALUE_OPTIONAL, 'level of output information (0:minimal, 1: normal (default), 2: detailed)', 1 ) ->addOption( 'stop-on-error', null, InputOption::VALUE_OPTIONAL, 'stop on first application error raises', false ) ->addOption( 'stop-on-failure', null, InputOption::VALUE_OPTIONAL, 'stop on first detected coverFish failure raises', false ) ; }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "setName", "(", "'scan'", ")", "->", "setDescription", "(", "'scan phpunit test files for static code analysis'", ")", "->", "setHelp", "(", "$", "this", "->", "getHelpOutput", "(", ")", ")", "->", "addArgument", "(", "'phpunit-config'", ",", "InputArgument", "::", "OPTIONAL", ",", "'the source path of your corresponding phpunit xml config file (e.g. ./tests/phpunit.xml)'", ")", "->", "addOption", "(", "'phpunit-config-suite'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'name of the target test suite inside your php config xml file, this test suite will be scanned'", ")", "->", "addOption", "(", "'raw-scan-path'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'raw mode option: the source path of your corresponding phpunit test files or a specific testFile (e.g. tests/), this option will always override phpunit.xml settings!'", ")", "->", "addOption", "(", "'raw-autoload-file'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'raw-mode option: your application autoload file and path (e.g. ../app/autoload.php for running in symfony context), this option will always override phpunit.xml settings!'", ")", "->", "addOption", "(", "'raw-exclude-path'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'raw-mode option: exclude a specific path from planned scan'", ",", "null", ")", "->", "addOption", "(", "'output-format'", ",", "'f'", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'output format of scan result (json|text)'", ",", "'text'", ")", "->", "addOption", "(", "'output-level'", ",", "'l'", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'level of output information (0:minimal, 1: normal (default), 2: detailed)'", ",", "1", ")", "->", "addOption", "(", "'stop-on-error'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'stop on first application error raises'", ",", "false", ")", "->", "addOption", "(", "'stop-on-failure'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'stop on first detected coverFish failure raises'", ",", "false", ")", ";", "}" ]
additional options and arguments for our cli application
[ "additional", "options", "and", "arguments", "for", "our", "cli", "application" ]
779bd399ec8f4cadb3b7854200695c5eb3f5a8ad
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/CoverFishScanCommand.php#L34-L99
16,703
dunkelfrosch/phpcoverfish
src/PHPCoverFish/CoverFishScanCommand.php
CoverFishScanCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $this->showExecTitle($input, $output); $this->prepareExecute($input); $cliOptions = array( 'sys_phpunit_config' => $input->getArgument('phpunit-config'), 'sys_phpunit_config_test_suite' => $input->getOption('phpunit-config-suite'), 'sys_stop_on_error' => $input->getOption('stop-on-error'), 'sys_stop_on_failure' => $input->getOption('stop-on-failure'), 'raw_scan_source' => $input->getOption('raw-scan-path'), 'raw_scan_autoload_file' => $input->getOption('raw-autoload-file'), 'raw_scan_exclude_path' => $input->getOption('raw-exclude-path'), ); $outOptions = array( 'out_verbose' => $input->getOption('verbose'), 'out_format' => $input->getOption('output-format'), 'out_level' => (int) $input->getOption('output-level'), 'out_no_ansi' => $input->getOption('no-ansi'), 'out_no_echo' => $input->getOption('quiet'), ); try { $scanner = new CoverFishScanner($cliOptions, $outOptions, $output); $scanner->analysePHPUnitFiles(); } catch (CoverFishFailExit $e) { return CoverFishFailExit::RETURN_CODE_SCAN_FAIL; } return 0; }
php
protected function execute(InputInterface $input, OutputInterface $output) { $this->showExecTitle($input, $output); $this->prepareExecute($input); $cliOptions = array( 'sys_phpunit_config' => $input->getArgument('phpunit-config'), 'sys_phpunit_config_test_suite' => $input->getOption('phpunit-config-suite'), 'sys_stop_on_error' => $input->getOption('stop-on-error'), 'sys_stop_on_failure' => $input->getOption('stop-on-failure'), 'raw_scan_source' => $input->getOption('raw-scan-path'), 'raw_scan_autoload_file' => $input->getOption('raw-autoload-file'), 'raw_scan_exclude_path' => $input->getOption('raw-exclude-path'), ); $outOptions = array( 'out_verbose' => $input->getOption('verbose'), 'out_format' => $input->getOption('output-format'), 'out_level' => (int) $input->getOption('output-level'), 'out_no_ansi' => $input->getOption('no-ansi'), 'out_no_echo' => $input->getOption('quiet'), ); try { $scanner = new CoverFishScanner($cliOptions, $outOptions, $output); $scanner->analysePHPUnitFiles(); } catch (CoverFishFailExit $e) { return CoverFishFailExit::RETURN_CODE_SCAN_FAIL; } return 0; }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "this", "->", "showExecTitle", "(", "$", "input", ",", "$", "output", ")", ";", "$", "this", "->", "prepareExecute", "(", "$", "input", ")", ";", "$", "cliOptions", "=", "array", "(", "'sys_phpunit_config'", "=>", "$", "input", "->", "getArgument", "(", "'phpunit-config'", ")", ",", "'sys_phpunit_config_test_suite'", "=>", "$", "input", "->", "getOption", "(", "'phpunit-config-suite'", ")", ",", "'sys_stop_on_error'", "=>", "$", "input", "->", "getOption", "(", "'stop-on-error'", ")", ",", "'sys_stop_on_failure'", "=>", "$", "input", "->", "getOption", "(", "'stop-on-failure'", ")", ",", "'raw_scan_source'", "=>", "$", "input", "->", "getOption", "(", "'raw-scan-path'", ")", ",", "'raw_scan_autoload_file'", "=>", "$", "input", "->", "getOption", "(", "'raw-autoload-file'", ")", ",", "'raw_scan_exclude_path'", "=>", "$", "input", "->", "getOption", "(", "'raw-exclude-path'", ")", ",", ")", ";", "$", "outOptions", "=", "array", "(", "'out_verbose'", "=>", "$", "input", "->", "getOption", "(", "'verbose'", ")", ",", "'out_format'", "=>", "$", "input", "->", "getOption", "(", "'output-format'", ")", ",", "'out_level'", "=>", "(", "int", ")", "$", "input", "->", "getOption", "(", "'output-level'", ")", ",", "'out_no_ansi'", "=>", "$", "input", "->", "getOption", "(", "'no-ansi'", ")", ",", "'out_no_echo'", "=>", "$", "input", "->", "getOption", "(", "'quiet'", ")", ",", ")", ";", "try", "{", "$", "scanner", "=", "new", "CoverFishScanner", "(", "$", "cliOptions", ",", "$", "outOptions", ",", "$", "output", ")", ";", "$", "scanner", "->", "analysePHPUnitFiles", "(", ")", ";", "}", "catch", "(", "CoverFishFailExit", "$", "e", ")", "{", "return", "CoverFishFailExit", "::", "RETURN_CODE_SCAN_FAIL", ";", "}", "return", "0", ";", "}" ]
exec command "scan" @param InputInterface $input @param OutputInterface $output @return string @throws \Exception
[ "exec", "command", "scan" ]
779bd399ec8f4cadb3b7854200695c5eb3f5a8ad
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/CoverFishScanCommand.php#L183-L214
16,704
dunkelfrosch/phpcoverfish
src/PHPCoverFish/CoverFishScanCommand.php
CoverFishScanCommand.prepareExecute
public function prepareExecute(InputInterface $input) { $this->coverFishHelper = new CoverFishHelper(); $phpUnitConfigFile = $input->getArgument('phpunit-config'); if (false === empty($phpUnitConfigFile) && false === $this->coverFishHelper->checkFileOrPath($phpUnitConfigFile)) { throw new \Exception(sprintf('phpunit config file "%s" not found! please define your phpunit.xml config file to use (e.g. tests/phpunit.xml)', $phpUnitConfigFile)); } $testPathOrFile = $input->getOption('raw-scan-path'); if (false === empty($testPathOrFile) && false === $this->coverFishHelper->checkFileOrPath($testPathOrFile)) { throw new \Exception(sprintf('test path/file "%s" not found! please define test file path (e.g. tests/)', $testPathOrFile)); } }
php
public function prepareExecute(InputInterface $input) { $this->coverFishHelper = new CoverFishHelper(); $phpUnitConfigFile = $input->getArgument('phpunit-config'); if (false === empty($phpUnitConfigFile) && false === $this->coverFishHelper->checkFileOrPath($phpUnitConfigFile)) { throw new \Exception(sprintf('phpunit config file "%s" not found! please define your phpunit.xml config file to use (e.g. tests/phpunit.xml)', $phpUnitConfigFile)); } $testPathOrFile = $input->getOption('raw-scan-path'); if (false === empty($testPathOrFile) && false === $this->coverFishHelper->checkFileOrPath($testPathOrFile)) { throw new \Exception(sprintf('test path/file "%s" not found! please define test file path (e.g. tests/)', $testPathOrFile)); } }
[ "public", "function", "prepareExecute", "(", "InputInterface", "$", "input", ")", "{", "$", "this", "->", "coverFishHelper", "=", "new", "CoverFishHelper", "(", ")", ";", "$", "phpUnitConfigFile", "=", "$", "input", "->", "getArgument", "(", "'phpunit-config'", ")", ";", "if", "(", "false", "===", "empty", "(", "$", "phpUnitConfigFile", ")", "&&", "false", "===", "$", "this", "->", "coverFishHelper", "->", "checkFileOrPath", "(", "$", "phpUnitConfigFile", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'phpunit config file \"%s\" not found! please define your phpunit.xml config file to use (e.g. tests/phpunit.xml)'", ",", "$", "phpUnitConfigFile", ")", ")", ";", "}", "$", "testPathOrFile", "=", "$", "input", "->", "getOption", "(", "'raw-scan-path'", ")", ";", "if", "(", "false", "===", "empty", "(", "$", "testPathOrFile", ")", "&&", "false", "===", "$", "this", "->", "coverFishHelper", "->", "checkFileOrPath", "(", "$", "testPathOrFile", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'test path/file \"%s\" not found! please define test file path (e.g. tests/)'", ",", "$", "testPathOrFile", ")", ")", ";", "}", "}" ]
prepare exec of command "scan" @param InputInterface $input @throws \Exception
[ "prepare", "exec", "of", "command", "scan" ]
779bd399ec8f4cadb3b7854200695c5eb3f5a8ad
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/CoverFishScanCommand.php#L223-L238
16,705
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.migrate
public function migrate($request) { $migrationTarget = isset($request['MigrationTarget']) ? $request['MigrationTarget'] : ''; $fileMigrationTarget = isset($request['FileMigrationTarget']) ? $request['FileMigrationTarget'] : ''; $includeSelected = isset($request['IncludeSelected']) ? $request['IncludeSelected'] : 0; $includeChildren = isset($request['IncludeChildren']) ? $request['IncludeChildren'] : 0; $duplicates = isset($request['DuplicateMethod']) ? $request['DuplicateMethod'] : ExternalContentTransformer::DS_OVERWRITE; $selected = isset($request['ID']) ? $request['ID'] : 0; if(!$selected){ $messageType = 'bad'; $message = _t('ExternalContent.NOITEMSELECTED', 'No item selected to import.'); } if(!$migrationTarget || !$fileMigrationTarget){ $messageType = 'bad'; $message = _t('ExternalContent.NOTARGETSELECTED', 'No target to import to selected.'); } if ($selected && ($migrationTarget || $fileMigrationTarget)) { // get objects and start stuff $target = null; $targetType = 'SiteTree'; if ($migrationTarget) { $target = DataObject::get_by_id('SiteTree', $migrationTarget); } else { $targetType = 'File'; $target = DataObject::get_by_id('File', $fileMigrationTarget); } $from = ExternalContent::getDataObjectFor($selected); if ($from instanceof ExternalContentSource) { $selected = false; } if (isset($request['Repeat']) && $request['Repeat'] > 0) { $job = new ScheduledExternalImportJob($request['Repeat'], $from, $target, $includeSelected, $includeChildren, $targetType, $duplicates, $request); singleton('QueuedJobService')->queueJob($job); $messageType = 'good'; $message = _t('ExternalContent.CONTENTMIGRATEQUEUED', 'Import job queued.'); } else { $importer = $from->getContentImporter($targetType); if ($importer) { $result = $importer->import($from, $target, $includeSelected, $includeChildren, $duplicates, $request); $messageType = 'good'; if ($result instanceof QueuedExternalContentImporter) { $message = _t('ExternalContent.CONTENTMIGRATEQUEUED', 'Import job queued.'); } else { $message = _t('ExternalContent.CONTENTMIGRATED', 'Import Successful.'); } } } } Session::set("FormInfo.Form_EditForm.formError.message",$message); Session::set("FormInfo.Form_EditForm.formError.type", $messageType); return $this->getResponseNegotiator()->respond($this->request); }
php
public function migrate($request) { $migrationTarget = isset($request['MigrationTarget']) ? $request['MigrationTarget'] : ''; $fileMigrationTarget = isset($request['FileMigrationTarget']) ? $request['FileMigrationTarget'] : ''; $includeSelected = isset($request['IncludeSelected']) ? $request['IncludeSelected'] : 0; $includeChildren = isset($request['IncludeChildren']) ? $request['IncludeChildren'] : 0; $duplicates = isset($request['DuplicateMethod']) ? $request['DuplicateMethod'] : ExternalContentTransformer::DS_OVERWRITE; $selected = isset($request['ID']) ? $request['ID'] : 0; if(!$selected){ $messageType = 'bad'; $message = _t('ExternalContent.NOITEMSELECTED', 'No item selected to import.'); } if(!$migrationTarget || !$fileMigrationTarget){ $messageType = 'bad'; $message = _t('ExternalContent.NOTARGETSELECTED', 'No target to import to selected.'); } if ($selected && ($migrationTarget || $fileMigrationTarget)) { // get objects and start stuff $target = null; $targetType = 'SiteTree'; if ($migrationTarget) { $target = DataObject::get_by_id('SiteTree', $migrationTarget); } else { $targetType = 'File'; $target = DataObject::get_by_id('File', $fileMigrationTarget); } $from = ExternalContent::getDataObjectFor($selected); if ($from instanceof ExternalContentSource) { $selected = false; } if (isset($request['Repeat']) && $request['Repeat'] > 0) { $job = new ScheduledExternalImportJob($request['Repeat'], $from, $target, $includeSelected, $includeChildren, $targetType, $duplicates, $request); singleton('QueuedJobService')->queueJob($job); $messageType = 'good'; $message = _t('ExternalContent.CONTENTMIGRATEQUEUED', 'Import job queued.'); } else { $importer = $from->getContentImporter($targetType); if ($importer) { $result = $importer->import($from, $target, $includeSelected, $includeChildren, $duplicates, $request); $messageType = 'good'; if ($result instanceof QueuedExternalContentImporter) { $message = _t('ExternalContent.CONTENTMIGRATEQUEUED', 'Import job queued.'); } else { $message = _t('ExternalContent.CONTENTMIGRATED', 'Import Successful.'); } } } } Session::set("FormInfo.Form_EditForm.formError.message",$message); Session::set("FormInfo.Form_EditForm.formError.type", $messageType); return $this->getResponseNegotiator()->respond($this->request); }
[ "public", "function", "migrate", "(", "$", "request", ")", "{", "$", "migrationTarget", "=", "isset", "(", "$", "request", "[", "'MigrationTarget'", "]", ")", "?", "$", "request", "[", "'MigrationTarget'", "]", ":", "''", ";", "$", "fileMigrationTarget", "=", "isset", "(", "$", "request", "[", "'FileMigrationTarget'", "]", ")", "?", "$", "request", "[", "'FileMigrationTarget'", "]", ":", "''", ";", "$", "includeSelected", "=", "isset", "(", "$", "request", "[", "'IncludeSelected'", "]", ")", "?", "$", "request", "[", "'IncludeSelected'", "]", ":", "0", ";", "$", "includeChildren", "=", "isset", "(", "$", "request", "[", "'IncludeChildren'", "]", ")", "?", "$", "request", "[", "'IncludeChildren'", "]", ":", "0", ";", "$", "duplicates", "=", "isset", "(", "$", "request", "[", "'DuplicateMethod'", "]", ")", "?", "$", "request", "[", "'DuplicateMethod'", "]", ":", "ExternalContentTransformer", "::", "DS_OVERWRITE", ";", "$", "selected", "=", "isset", "(", "$", "request", "[", "'ID'", "]", ")", "?", "$", "request", "[", "'ID'", "]", ":", "0", ";", "if", "(", "!", "$", "selected", ")", "{", "$", "messageType", "=", "'bad'", ";", "$", "message", "=", "_t", "(", "'ExternalContent.NOITEMSELECTED'", ",", "'No item selected to import.'", ")", ";", "}", "if", "(", "!", "$", "migrationTarget", "||", "!", "$", "fileMigrationTarget", ")", "{", "$", "messageType", "=", "'bad'", ";", "$", "message", "=", "_t", "(", "'ExternalContent.NOTARGETSELECTED'", ",", "'No target to import to selected.'", ")", ";", "}", "if", "(", "$", "selected", "&&", "(", "$", "migrationTarget", "||", "$", "fileMigrationTarget", ")", ")", "{", "// get objects and start stuff", "$", "target", "=", "null", ";", "$", "targetType", "=", "'SiteTree'", ";", "if", "(", "$", "migrationTarget", ")", "{", "$", "target", "=", "DataObject", "::", "get_by_id", "(", "'SiteTree'", ",", "$", "migrationTarget", ")", ";", "}", "else", "{", "$", "targetType", "=", "'File'", ";", "$", "target", "=", "DataObject", "::", "get_by_id", "(", "'File'", ",", "$", "fileMigrationTarget", ")", ";", "}", "$", "from", "=", "ExternalContent", "::", "getDataObjectFor", "(", "$", "selected", ")", ";", "if", "(", "$", "from", "instanceof", "ExternalContentSource", ")", "{", "$", "selected", "=", "false", ";", "}", "if", "(", "isset", "(", "$", "request", "[", "'Repeat'", "]", ")", "&&", "$", "request", "[", "'Repeat'", "]", ">", "0", ")", "{", "$", "job", "=", "new", "ScheduledExternalImportJob", "(", "$", "request", "[", "'Repeat'", "]", ",", "$", "from", ",", "$", "target", ",", "$", "includeSelected", ",", "$", "includeChildren", ",", "$", "targetType", ",", "$", "duplicates", ",", "$", "request", ")", ";", "singleton", "(", "'QueuedJobService'", ")", "->", "queueJob", "(", "$", "job", ")", ";", "$", "messageType", "=", "'good'", ";", "$", "message", "=", "_t", "(", "'ExternalContent.CONTENTMIGRATEQUEUED'", ",", "'Import job queued.'", ")", ";", "}", "else", "{", "$", "importer", "=", "$", "from", "->", "getContentImporter", "(", "$", "targetType", ")", ";", "if", "(", "$", "importer", ")", "{", "$", "result", "=", "$", "importer", "->", "import", "(", "$", "from", ",", "$", "target", ",", "$", "includeSelected", ",", "$", "includeChildren", ",", "$", "duplicates", ",", "$", "request", ")", ";", "$", "messageType", "=", "'good'", ";", "if", "(", "$", "result", "instanceof", "QueuedExternalContentImporter", ")", "{", "$", "message", "=", "_t", "(", "'ExternalContent.CONTENTMIGRATEQUEUED'", ",", "'Import job queued.'", ")", ";", "}", "else", "{", "$", "message", "=", "_t", "(", "'ExternalContent.CONTENTMIGRATED'", ",", "'Import Successful.'", ")", ";", "}", "}", "}", "}", "Session", "::", "set", "(", "\"FormInfo.Form_EditForm.formError.message\"", ",", "$", "message", ")", ";", "Session", "::", "set", "(", "\"FormInfo.Form_EditForm.formError.type\"", ",", "$", "messageType", ")", ";", "return", "$", "this", "->", "getResponseNegotiator", "(", ")", "->", "respond", "(", "$", "this", "->", "request", ")", ";", "}" ]
Action to migrate a selected object through to SS @param array $request
[ "Action", "to", "migrate", "a", "selected", "object", "through", "to", "SS" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L150-L209
16,706
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.getRecord
public function getRecord($id) { if(is_numeric($id)) { return parent::getRecord($id); } else { return ExternalContent::getDataObjectFor($id); } }
php
public function getRecord($id) { if(is_numeric($id)) { return parent::getRecord($id); } else { return ExternalContent::getDataObjectFor($id); } }
[ "public", "function", "getRecord", "(", "$", "id", ")", "{", "if", "(", "is_numeric", "(", "$", "id", ")", ")", "{", "return", "parent", "::", "getRecord", "(", "$", "id", ")", ";", "}", "else", "{", "return", "ExternalContent", "::", "getDataObjectFor", "(", "$", "id", ")", ";", "}", "}" ]
Return the record corresponding to the given ID. Both the numeric IDs of ExternalContentSource records and the composite IDs of ExternalContentItem entries are supported. @param string $id The ID @return Dataobject The relevant object
[ "Return", "the", "record", "corresponding", "to", "the", "given", "ID", "." ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L220-L226
16,707
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.EditForm
public function EditForm($request = null) { HtmlEditorField::include_js(); $cur = $this->getCurrentPageID(); if ($cur) { $record = $this->currentPage(); if (!$record) return false; if ($record && !$record->canView()) return Security::permissionFailure($this); } if ($this->hasMethod('getEditForm')) { return $this->getEditForm($this->getCurrentPageID()); } return false; }
php
public function EditForm($request = null) { HtmlEditorField::include_js(); $cur = $this->getCurrentPageID(); if ($cur) { $record = $this->currentPage(); if (!$record) return false; if ($record && !$record->canView()) return Security::permissionFailure($this); } if ($this->hasMethod('getEditForm')) { return $this->getEditForm($this->getCurrentPageID()); } return false; }
[ "public", "function", "EditForm", "(", "$", "request", "=", "null", ")", "{", "HtmlEditorField", "::", "include_js", "(", ")", ";", "$", "cur", "=", "$", "this", "->", "getCurrentPageID", "(", ")", ";", "if", "(", "$", "cur", ")", "{", "$", "record", "=", "$", "this", "->", "currentPage", "(", ")", ";", "if", "(", "!", "$", "record", ")", "return", "false", ";", "if", "(", "$", "record", "&&", "!", "$", "record", "->", "canView", "(", ")", ")", "return", "Security", "::", "permissionFailure", "(", "$", "this", ")", ";", "}", "if", "(", "$", "this", "->", "hasMethod", "(", "'getEditForm'", ")", ")", "{", "return", "$", "this", "->", "getEditForm", "(", "$", "this", "->", "getCurrentPageID", "(", ")", ")", ";", "}", "return", "false", ";", "}" ]
Return the edit form @see cms/code/LeftAndMain#EditForm()
[ "Return", "the", "edit", "form" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L233-L250
16,708
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.AddForm
public function AddForm() { $classes = ClassInfo::subclassesFor(self::$tree_class); array_shift($classes); foreach ($classes as $key => $class) { if (!singleton($class)->canCreate()) unset($classes[$key]); $classes[$key] = FormField::name_to_label($class); } $fields = new FieldList( new HiddenField("ParentID"), new HiddenField("Locale", 'Locale', i18n::get_locale()), $type = new DropdownField("ProviderType", "", $classes) ); $type->setAttribute('style', 'width:150px'); $actions = new FieldList( FormAction::create("addprovider", _t('ExternalContent.CREATE', "Create")) ->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept') ->setUseButtonTag(true) ); $form = new Form($this, "AddForm", $fields, $actions); $form->addExtraClass('cms-edit-form ' . $this->BaseCSSClasses()); $this->extend('updateEditForm', $form); return $form; }
php
public function AddForm() { $classes = ClassInfo::subclassesFor(self::$tree_class); array_shift($classes); foreach ($classes as $key => $class) { if (!singleton($class)->canCreate()) unset($classes[$key]); $classes[$key] = FormField::name_to_label($class); } $fields = new FieldList( new HiddenField("ParentID"), new HiddenField("Locale", 'Locale', i18n::get_locale()), $type = new DropdownField("ProviderType", "", $classes) ); $type->setAttribute('style', 'width:150px'); $actions = new FieldList( FormAction::create("addprovider", _t('ExternalContent.CREATE', "Create")) ->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept') ->setUseButtonTag(true) ); $form = new Form($this, "AddForm", $fields, $actions); $form->addExtraClass('cms-edit-form ' . $this->BaseCSSClasses()); $this->extend('updateEditForm', $form); return $form; }
[ "public", "function", "AddForm", "(", ")", "{", "$", "classes", "=", "ClassInfo", "::", "subclassesFor", "(", "self", "::", "$", "tree_class", ")", ";", "array_shift", "(", "$", "classes", ")", ";", "foreach", "(", "$", "classes", "as", "$", "key", "=>", "$", "class", ")", "{", "if", "(", "!", "singleton", "(", "$", "class", ")", "->", "canCreate", "(", ")", ")", "unset", "(", "$", "classes", "[", "$", "key", "]", ")", ";", "$", "classes", "[", "$", "key", "]", "=", "FormField", "::", "name_to_label", "(", "$", "class", ")", ";", "}", "$", "fields", "=", "new", "FieldList", "(", "new", "HiddenField", "(", "\"ParentID\"", ")", ",", "new", "HiddenField", "(", "\"Locale\"", ",", "'Locale'", ",", "i18n", "::", "get_locale", "(", ")", ")", ",", "$", "type", "=", "new", "DropdownField", "(", "\"ProviderType\"", ",", "\"\"", ",", "$", "classes", ")", ")", ";", "$", "type", "->", "setAttribute", "(", "'style'", ",", "'width:150px'", ")", ";", "$", "actions", "=", "new", "FieldList", "(", "FormAction", "::", "create", "(", "\"addprovider\"", ",", "_t", "(", "'ExternalContent.CREATE'", ",", "\"Create\"", ")", ")", "->", "addExtraClass", "(", "'ss-ui-action-constructive'", ")", "->", "setAttribute", "(", "'data-icon'", ",", "'accept'", ")", "->", "setUseButtonTag", "(", "true", ")", ")", ";", "$", "form", "=", "new", "Form", "(", "$", "this", ",", "\"AddForm\"", ",", "$", "fields", ",", "$", "actions", ")", ";", "$", "form", "->", "addExtraClass", "(", "'cms-edit-form '", ".", "$", "this", "->", "BaseCSSClasses", "(", ")", ")", ";", "$", "this", "->", "extend", "(", "'updateEditForm'", ",", "$", "form", ")", ";", "return", "$", "form", ";", "}" ]
Get the form used to create a new provider @return Form
[ "Get", "the", "form", "used", "to", "create", "a", "new", "provider" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L390-L419
16,709
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.DeleteItemsForm
function DeleteItemsForm() { $form = new Form( $this, 'DeleteItemsForm', new FieldList( new LiteralField('SelectedPagesNote', sprintf('<p>%s</p>', _t('ExternalContentAdmin.SELECT_CONNECTORS', 'Select the connectors that you want to delete and then click the button below')) ), new HiddenField('csvIDs') ), new FieldList( new FormAction('deleteprovider', _t('ExternalContentAdmin.DELCONNECTORS', 'Delete the selected connectors')) ) ); $form->addExtraClass('actionparams'); return $form; }
php
function DeleteItemsForm() { $form = new Form( $this, 'DeleteItemsForm', new FieldList( new LiteralField('SelectedPagesNote', sprintf('<p>%s</p>', _t('ExternalContentAdmin.SELECT_CONNECTORS', 'Select the connectors that you want to delete and then click the button below')) ), new HiddenField('csvIDs') ), new FieldList( new FormAction('deleteprovider', _t('ExternalContentAdmin.DELCONNECTORS', 'Delete the selected connectors')) ) ); $form->addExtraClass('actionparams'); return $form; }
[ "function", "DeleteItemsForm", "(", ")", "{", "$", "form", "=", "new", "Form", "(", "$", "this", ",", "'DeleteItemsForm'", ",", "new", "FieldList", "(", "new", "LiteralField", "(", "'SelectedPagesNote'", ",", "sprintf", "(", "'<p>%s</p>'", ",", "_t", "(", "'ExternalContentAdmin.SELECT_CONNECTORS'", ",", "'Select the connectors that you want to delete and then click the button below'", ")", ")", ")", ",", "new", "HiddenField", "(", "'csvIDs'", ")", ")", ",", "new", "FieldList", "(", "new", "FormAction", "(", "'deleteprovider'", ",", "_t", "(", "'ExternalContentAdmin.DELCONNECTORS'", ",", "'Delete the selected connectors'", ")", ")", ")", ")", ";", "$", "form", "->", "addExtraClass", "(", "'actionparams'", ")", ";", "return", "$", "form", ";", "}" ]
Copied from AssetAdmin... @return Form
[ "Copied", "from", "AssetAdmin", "..." ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L479-L497
16,710
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.deleteprovider
public function deleteprovider() { $script = ''; $ids = split(' *, *', $_REQUEST['csvIDs']); $script = ''; if (!$ids) return false; foreach ($ids as $id) { if (is_numeric($id)) { $record = ExternalContent::getDataObjectFor($id); if ($record) { $script .= $this->deleteTreeNodeJS($record); $record->delete(); $record->destroy(); } } } $size = sizeof($ids); if ($size > 1) { $message = $size . ' ' . _t('AssetAdmin.FOLDERSDELETED', 'folders deleted.'); } else { $message = $size . ' ' . _t('AssetAdmin.FOLDERDELETED', 'folder deleted.'); } $script .= "statusMessage('$message');"; echo $script; }
php
public function deleteprovider() { $script = ''; $ids = split(' *, *', $_REQUEST['csvIDs']); $script = ''; if (!$ids) return false; foreach ($ids as $id) { if (is_numeric($id)) { $record = ExternalContent::getDataObjectFor($id); if ($record) { $script .= $this->deleteTreeNodeJS($record); $record->delete(); $record->destroy(); } } } $size = sizeof($ids); if ($size > 1) { $message = $size . ' ' . _t('AssetAdmin.FOLDERSDELETED', 'folders deleted.'); } else { $message = $size . ' ' . _t('AssetAdmin.FOLDERDELETED', 'folder deleted.'); } $script .= "statusMessage('$message');"; echo $script; }
[ "public", "function", "deleteprovider", "(", ")", "{", "$", "script", "=", "''", ";", "$", "ids", "=", "split", "(", "' *, *'", ",", "$", "_REQUEST", "[", "'csvIDs'", "]", ")", ";", "$", "script", "=", "''", ";", "if", "(", "!", "$", "ids", ")", "return", "false", ";", "foreach", "(", "$", "ids", "as", "$", "id", ")", "{", "if", "(", "is_numeric", "(", "$", "id", ")", ")", "{", "$", "record", "=", "ExternalContent", "::", "getDataObjectFor", "(", "$", "id", ")", ";", "if", "(", "$", "record", ")", "{", "$", "script", ".=", "$", "this", "->", "deleteTreeNodeJS", "(", "$", "record", ")", ";", "$", "record", "->", "delete", "(", ")", ";", "$", "record", "->", "destroy", "(", ")", ";", "}", "}", "}", "$", "size", "=", "sizeof", "(", "$", "ids", ")", ";", "if", "(", "$", "size", ">", "1", ")", "{", "$", "message", "=", "$", "size", ".", "' '", ".", "_t", "(", "'AssetAdmin.FOLDERSDELETED'", ",", "'folders deleted.'", ")", ";", "}", "else", "{", "$", "message", "=", "$", "size", ".", "' '", ".", "_t", "(", "'AssetAdmin.FOLDERDELETED'", ",", "'folder deleted.'", ")", ";", "}", "$", "script", ".=", "\"statusMessage('$message');\"", ";", "echo", "$", "script", ";", "}" ]
Delete a folder
[ "Delete", "a", "folder" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L502-L530
16,711
factorio-item-browser/export-data
src/Utils/EntityUtils.php
EntityUtils.calculateHashOfArray
public static function calculateHashOfArray(array $data): string { return self::calculateHash((string) json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); }
php
public static function calculateHashOfArray(array $data): string { return self::calculateHash((string) json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); }
[ "public", "static", "function", "calculateHashOfArray", "(", "array", "$", "data", ")", ":", "string", "{", "return", "self", "::", "calculateHash", "(", "(", "string", ")", "json_encode", "(", "$", "data", ",", "JSON_UNESCAPED_SLASHES", "|", "JSON_UNESCAPED_UNICODE", ")", ")", ";", "}" ]
Calculates the hash of the specified data array. @param array $data @return string
[ "Calculates", "the", "hash", "of", "the", "specified", "data", "array", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Utils/EntityUtils.php#L40-L43
16,712
devmobgroup/postcodes
src/Address/Address.php
Address.setPostcode
protected function setPostcode(string $postcode): void { if (! preg_match(self::POSTCODE_FORMAT, $postcode)) { throw new InvalidArgumentException('Postcode must match the expected format: ' . self::POSTCODE_FORMAT); } $this->postcode = $postcode; }
php
protected function setPostcode(string $postcode): void { if (! preg_match(self::POSTCODE_FORMAT, $postcode)) { throw new InvalidArgumentException('Postcode must match the expected format: ' . self::POSTCODE_FORMAT); } $this->postcode = $postcode; }
[ "protected", "function", "setPostcode", "(", "string", "$", "postcode", ")", ":", "void", "{", "if", "(", "!", "preg_match", "(", "self", "::", "POSTCODE_FORMAT", ",", "$", "postcode", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Postcode must match the expected format: '", ".", "self", "::", "POSTCODE_FORMAT", ")", ";", "}", "$", "this", "->", "postcode", "=", "$", "postcode", ";", "}" ]
Set postcode. @param string $postcode @return void
[ "Set", "postcode", "." ]
1a8438fd960a8f50ec28d61af94560892b529f12
https://github.com/devmobgroup/postcodes/blob/1a8438fd960a8f50ec28d61af94560892b529f12/src/Address/Address.php#L103-L110
16,713
webforge-labs/psc-cms
lib/Psc/Doctrine/Mocks/EntityManager.php
EntityManager.merge
public function merge($entity) { // add to merged if (!$this->merged->contains($entity)) { $this->merged->add($entity); } // remove from removed,detached // nicht remove from persisted if ($this->removed->contains($entity)) { $this->removed->removeElement($entity); } if ($this->detached->contains($entity)) { $this->detached->removeElement($entity); } if ($this->delegate) { return parent::persist($entity); } }
php
public function merge($entity) { // add to merged if (!$this->merged->contains($entity)) { $this->merged->add($entity); } // remove from removed,detached // nicht remove from persisted if ($this->removed->contains($entity)) { $this->removed->removeElement($entity); } if ($this->detached->contains($entity)) { $this->detached->removeElement($entity); } if ($this->delegate) { return parent::persist($entity); } }
[ "public", "function", "merge", "(", "$", "entity", ")", "{", "// add to merged", "if", "(", "!", "$", "this", "->", "merged", "->", "contains", "(", "$", "entity", ")", ")", "{", "$", "this", "->", "merged", "->", "add", "(", "$", "entity", ")", ";", "}", "// remove from removed,detached", "// nicht remove from persisted", "if", "(", "$", "this", "->", "removed", "->", "contains", "(", "$", "entity", ")", ")", "{", "$", "this", "->", "removed", "->", "removeElement", "(", "$", "entity", ")", ";", "}", "if", "(", "$", "this", "->", "detached", "->", "contains", "(", "$", "entity", ")", ")", "{", "$", "this", "->", "detached", "->", "removeElement", "(", "$", "entity", ")", ";", "}", "if", "(", "$", "this", "->", "delegate", ")", "{", "return", "parent", "::", "persist", "(", "$", "entity", ")", ";", "}", "}" ]
Der Parameter von merge wird nicht im EntityManager persisted
[ "Der", "Parameter", "von", "merge", "wird", "nicht", "im", "EntityManager", "persisted" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/Mocks/EntityManager.php#L86-L104
16,714
ripaclub/zf2-sphinxsearch-tool
src/Config/Writer/SphinxConf.php
SphinxConf.substituteVars
protected function substituteVars(Config $config, $prefix = '{', $suffix = '}') { $arrayConfig = $config->toArray(); if (isset($arrayConfig['variables'])) { $vars = array_map( function ($x) use ($prefix, $suffix) { return $prefix . $x . $suffix; }, array_keys($arrayConfig['variables']) ); $vals = array_values($arrayConfig['variables']); $tokens = array_combine($vars, $vals); $processor = new Token(); $processor->setTokens($tokens); $processor->process($config); // Remove variables node unset($config->variables); } return $config; }
php
protected function substituteVars(Config $config, $prefix = '{', $suffix = '}') { $arrayConfig = $config->toArray(); if (isset($arrayConfig['variables'])) { $vars = array_map( function ($x) use ($prefix, $suffix) { return $prefix . $x . $suffix; }, array_keys($arrayConfig['variables']) ); $vals = array_values($arrayConfig['variables']); $tokens = array_combine($vars, $vals); $processor = new Token(); $processor->setTokens($tokens); $processor->process($config); // Remove variables node unset($config->variables); } return $config; }
[ "protected", "function", "substituteVars", "(", "Config", "$", "config", ",", "$", "prefix", "=", "'{'", ",", "$", "suffix", "=", "'}'", ")", "{", "$", "arrayConfig", "=", "$", "config", "->", "toArray", "(", ")", ";", "if", "(", "isset", "(", "$", "arrayConfig", "[", "'variables'", "]", ")", ")", "{", "$", "vars", "=", "array_map", "(", "function", "(", "$", "x", ")", "use", "(", "$", "prefix", ",", "$", "suffix", ")", "{", "return", "$", "prefix", ".", "$", "x", ".", "$", "suffix", ";", "}", ",", "array_keys", "(", "$", "arrayConfig", "[", "'variables'", "]", ")", ")", ";", "$", "vals", "=", "array_values", "(", "$", "arrayConfig", "[", "'variables'", "]", ")", ";", "$", "tokens", "=", "array_combine", "(", "$", "vars", ",", "$", "vals", ")", ";", "$", "processor", "=", "new", "Token", "(", ")", ";", "$", "processor", "->", "setTokens", "(", "$", "tokens", ")", ";", "$", "processor", "->", "process", "(", "$", "config", ")", ";", "// Remove variables node", "unset", "(", "$", "config", "->", "variables", ")", ";", "}", "return", "$", "config", ";", "}" ]
Substitute defined variables, if any found and return the new configuration object @param Config $config @param string $prefix @param string $suffix @return Config
[ "Substitute", "defined", "variables", "if", "any", "found", "and", "return", "the", "new", "configuration", "object" ]
4cb51341ccf1db9942e3e578855a579afd608d69
https://github.com/ripaclub/zf2-sphinxsearch-tool/blob/4cb51341ccf1db9942e3e578855a579afd608d69/src/Config/Writer/SphinxConf.php#L72-L91
16,715
ripaclub/zf2-sphinxsearch-tool
src/Config/Writer/SphinxConf.php
SphinxConf.getCommandConfig
protected function getCommandConfig(Config $config, $command) { $string = ''; if (isset($config[$command])) { /** @var Config $config */ $config = $config[$command]; if ($config->count() > 0) { $config = $config->toArray(); /** @var array $config */ $string .= $this->commands[$command] . PHP_EOL . '{' . PHP_EOL . "\t"; $string .= $this->getValuesString($config, true); $string .= PHP_EOL . '}' . PHP_EOL; } } return $string; }
php
protected function getCommandConfig(Config $config, $command) { $string = ''; if (isset($config[$command])) { /** @var Config $config */ $config = $config[$command]; if ($config->count() > 0) { $config = $config->toArray(); /** @var array $config */ $string .= $this->commands[$command] . PHP_EOL . '{' . PHP_EOL . "\t"; $string .= $this->getValuesString($config, true); $string .= PHP_EOL . '}' . PHP_EOL; } } return $string; }
[ "protected", "function", "getCommandConfig", "(", "Config", "$", "config", ",", "$", "command", ")", "{", "$", "string", "=", "''", ";", "if", "(", "isset", "(", "$", "config", "[", "$", "command", "]", ")", ")", "{", "/** @var Config $config */", "$", "config", "=", "$", "config", "[", "$", "command", "]", ";", "if", "(", "$", "config", "->", "count", "(", ")", ">", "0", ")", "{", "$", "config", "=", "$", "config", "->", "toArray", "(", ")", ";", "/** @var array $config */", "$", "string", ".=", "$", "this", "->", "commands", "[", "$", "command", "]", ".", "PHP_EOL", ".", "'{'", ".", "PHP_EOL", ".", "\"\\t\"", ";", "$", "string", ".=", "$", "this", "->", "getValuesString", "(", "$", "config", ",", "true", ")", ";", "$", "string", ".=", "PHP_EOL", ".", "'}'", ".", "PHP_EOL", ";", "}", "}", "return", "$", "string", ";", "}" ]
Creates the config part of the specified command @param Config $config @param string $command @return string
[ "Creates", "the", "config", "part", "of", "the", "specified", "command" ]
4cb51341ccf1db9942e3e578855a579afd608d69
https://github.com/ripaclub/zf2-sphinxsearch-tool/blob/4cb51341ccf1db9942e3e578855a579afd608d69/src/Config/Writer/SphinxConf.php#L100-L115
16,716
ripaclub/zf2-sphinxsearch-tool
src/Config/Writer/SphinxConf.php
SphinxConf.getValuesString
private function getValuesString(array $values, $tab = true) { $glue = $tab ? PHP_EOL . "\t" : PHP_EOL; return implode( $glue, array_map( function ($key) use ($values, $glue) { if (!is_array($values[$key])) { $return = $key . ' = ' . $values[$key]; } else { $return = implode( $glue, array_map( function ($value) use ($key) { return $key . ' = ' . $value; }, $values[$key] ) ); } if ($key == 'charset_table') { $filter = new SeparatorToSeparator(', ', ', \\' . $glue); return $filter->filter($return); } return $return; }, array_keys($values) ) ); }
php
private function getValuesString(array $values, $tab = true) { $glue = $tab ? PHP_EOL . "\t" : PHP_EOL; return implode( $glue, array_map( function ($key) use ($values, $glue) { if (!is_array($values[$key])) { $return = $key . ' = ' . $values[$key]; } else { $return = implode( $glue, array_map( function ($value) use ($key) { return $key . ' = ' . $value; }, $values[$key] ) ); } if ($key == 'charset_table') { $filter = new SeparatorToSeparator(', ', ', \\' . $glue); return $filter->filter($return); } return $return; }, array_keys($values) ) ); }
[ "private", "function", "getValuesString", "(", "array", "$", "values", ",", "$", "tab", "=", "true", ")", "{", "$", "glue", "=", "$", "tab", "?", "PHP_EOL", ".", "\"\\t\"", ":", "PHP_EOL", ";", "return", "implode", "(", "$", "glue", ",", "array_map", "(", "function", "(", "$", "key", ")", "use", "(", "$", "values", ",", "$", "glue", ")", "{", "if", "(", "!", "is_array", "(", "$", "values", "[", "$", "key", "]", ")", ")", "{", "$", "return", "=", "$", "key", ".", "' = '", ".", "$", "values", "[", "$", "key", "]", ";", "}", "else", "{", "$", "return", "=", "implode", "(", "$", "glue", ",", "array_map", "(", "function", "(", "$", "value", ")", "use", "(", "$", "key", ")", "{", "return", "$", "key", ".", "' = '", ".", "$", "value", ";", "}", ",", "$", "values", "[", "$", "key", "]", ")", ")", ";", "}", "if", "(", "$", "key", "==", "'charset_table'", ")", "{", "$", "filter", "=", "new", "SeparatorToSeparator", "(", "', '", ",", "', \\\\'", ".", "$", "glue", ")", ";", "return", "$", "filter", "->", "filter", "(", "$", "return", ")", ";", "}", "return", "$", "return", ";", "}", ",", "array_keys", "(", "$", "values", ")", ")", ")", ";", "}" ]
Construct a string representation from configuration associative values @param array $values @param bool $tab @return string
[ "Construct", "a", "string", "representation", "from", "configuration", "associative", "values" ]
4cb51341ccf1db9942e3e578855a579afd608d69
https://github.com/ripaclub/zf2-sphinxsearch-tool/blob/4cb51341ccf1db9942e3e578855a579afd608d69/src/Config/Writer/SphinxConf.php#L124-L153
16,717
ripaclub/zf2-sphinxsearch-tool
src/Config/Writer/SphinxConf.php
SphinxConf.getSectionConfig
protected function getSectionConfig(Config $config, $section) { $string = ''; if (isset($config[$section])) { /** @var Config $config */ $config = $config[$section]; // If there is at least one section if ($config->count() > 0) { /** @var Config $values */ foreach ($config as $name => $values) { if ($values->count() > 0) { $string .= $this->sections[$section] . ' ' . $name . PHP_EOL . '{' . PHP_EOL . "\t"; $string .= $this->getValuesString($values->toArray()); $string .= PHP_EOL . '}' . PHP_EOL; } } } } return $string; }
php
protected function getSectionConfig(Config $config, $section) { $string = ''; if (isset($config[$section])) { /** @var Config $config */ $config = $config[$section]; // If there is at least one section if ($config->count() > 0) { /** @var Config $values */ foreach ($config as $name => $values) { if ($values->count() > 0) { $string .= $this->sections[$section] . ' ' . $name . PHP_EOL . '{' . PHP_EOL . "\t"; $string .= $this->getValuesString($values->toArray()); $string .= PHP_EOL . '}' . PHP_EOL; } } } } return $string; }
[ "protected", "function", "getSectionConfig", "(", "Config", "$", "config", ",", "$", "section", ")", "{", "$", "string", "=", "''", ";", "if", "(", "isset", "(", "$", "config", "[", "$", "section", "]", ")", ")", "{", "/** @var Config $config */", "$", "config", "=", "$", "config", "[", "$", "section", "]", ";", "// If there is at least one section", "if", "(", "$", "config", "->", "count", "(", ")", ">", "0", ")", "{", "/** @var Config $values */", "foreach", "(", "$", "config", "as", "$", "name", "=>", "$", "values", ")", "{", "if", "(", "$", "values", "->", "count", "(", ")", ">", "0", ")", "{", "$", "string", ".=", "$", "this", "->", "sections", "[", "$", "section", "]", ".", "' '", ".", "$", "name", ".", "PHP_EOL", ".", "'{'", ".", "PHP_EOL", ".", "\"\\t\"", ";", "$", "string", ".=", "$", "this", "->", "getValuesString", "(", "$", "values", "->", "toArray", "(", ")", ")", ";", "$", "string", ".=", "PHP_EOL", ".", "'}'", ".", "PHP_EOL", ";", "}", "}", "}", "}", "return", "$", "string", ";", "}" ]
Creates the config parts of the specified section @param Config $config @param $section @return string
[ "Creates", "the", "config", "parts", "of", "the", "specified", "section" ]
4cb51341ccf1db9942e3e578855a579afd608d69
https://github.com/ripaclub/zf2-sphinxsearch-tool/blob/4cb51341ccf1db9942e3e578855a579afd608d69/src/Config/Writer/SphinxConf.php#L162-L181
16,718
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._arrayInclude
protected function _arrayInclude($path, array $options = [], $type = 'css') { $doc = $this->Document; if (is_array($path)) { $out = ''; foreach ($path as $i) { $out .= $this->{$type}($i, $options); } if (empty($options['block'])) { return $out . $doc->eol; } return null; } return false; }
php
protected function _arrayInclude($path, array $options = [], $type = 'css') { $doc = $this->Document; if (is_array($path)) { $out = ''; foreach ($path as $i) { $out .= $this->{$type}($i, $options); } if (empty($options['block'])) { return $out . $doc->eol; } return null; } return false; }
[ "protected", "function", "_arrayInclude", "(", "$", "path", ",", "array", "$", "options", "=", "[", "]", ",", "$", "type", "=", "'css'", ")", "{", "$", "doc", "=", "$", "this", "->", "Document", ";", "if", "(", "is_array", "(", "$", "path", ")", ")", "{", "$", "out", "=", "''", ";", "foreach", "(", "$", "path", "as", "$", "i", ")", "{", "$", "out", ".=", "$", "this", "->", "{", "$", "type", "}", "(", "$", "i", ",", "$", "options", ")", ";", "}", "if", "(", "empty", "(", "$", "options", "[", "'block'", "]", ")", ")", "{", "return", "$", "out", ".", "$", "doc", "->", "eol", ";", "}", "return", "null", ";", "}", "return", "false", ";", "}" ]
Include array paths. @param array|string $path @param array $options @param string $type @return bool|null|string
[ "Include", "array", "paths", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L43-L60
16,719
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._getCssOutput
protected function _getCssOutput(array $options, $url) { if ($options['rel'] === 'import') { return $this->formatTemplate('style', [ 'attrs' => $this->templater()->formatAttributes($options, ['rel', 'block', 'weight', 'alias']), 'content' => '@import url(' . $url . ');', ]); } return $this->formatTemplate('css', [ 'rel' => $options['rel'], 'url' => $url, 'attrs' => $this->templater()->formatAttributes($options, ['rel', 'block', 'weight', 'alias']), ]); }
php
protected function _getCssOutput(array $options, $url) { if ($options['rel'] === 'import') { return $this->formatTemplate('style', [ 'attrs' => $this->templater()->formatAttributes($options, ['rel', 'block', 'weight', 'alias']), 'content' => '@import url(' . $url . ');', ]); } return $this->formatTemplate('css', [ 'rel' => $options['rel'], 'url' => $url, 'attrs' => $this->templater()->formatAttributes($options, ['rel', 'block', 'weight', 'alias']), ]); }
[ "protected", "function", "_getCssOutput", "(", "array", "$", "options", ",", "$", "url", ")", "{", "if", "(", "$", "options", "[", "'rel'", "]", "===", "'import'", ")", "{", "return", "$", "this", "->", "formatTemplate", "(", "'style'", ",", "[", "'attrs'", "=>", "$", "this", "->", "templater", "(", ")", "->", "formatAttributes", "(", "$", "options", ",", "[", "'rel'", ",", "'block'", ",", "'weight'", ",", "'alias'", "]", ")", ",", "'content'", "=>", "'@import url('", ".", "$", "url", ".", "');'", ",", "]", ")", ";", "}", "return", "$", "this", "->", "formatTemplate", "(", "'css'", ",", "[", "'rel'", "=>", "$", "options", "[", "'rel'", "]", ",", "'url'", "=>", "$", "url", ",", "'attrs'", "=>", "$", "this", "->", "templater", "(", ")", "->", "formatAttributes", "(", "$", "options", ",", "[", "'rel'", ",", "'block'", ",", "'weight'", ",", "'alias'", "]", ")", ",", "]", ")", ";", "}" ]
Get current css output. @param array $options @param string $url @return string
[ "Get", "current", "css", "output", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L80-L94
16,720
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._getCurrentUrlAndOptions
protected function _getCurrentUrlAndOptions($path, array $options, $type, $external) { if (strpos($path, '//') !== false) { $url = $path; $external = true; unset($options['fullBase']); } else { $url = $this->Url->{$type}($path, $options); $options = array_diff_key($options, ['fullBase' => null, 'pathPrefix' => null]); } return [$url, $options, $external]; }
php
protected function _getCurrentUrlAndOptions($path, array $options, $type, $external) { if (strpos($path, '//') !== false) { $url = $path; $external = true; unset($options['fullBase']); } else { $url = $this->Url->{$type}($path, $options); $options = array_diff_key($options, ['fullBase' => null, 'pathPrefix' => null]); } return [$url, $options, $external]; }
[ "protected", "function", "_getCurrentUrlAndOptions", "(", "$", "path", ",", "array", "$", "options", ",", "$", "type", ",", "$", "external", ")", "{", "if", "(", "strpos", "(", "$", "path", ",", "'//'", ")", "!==", "false", ")", "{", "$", "url", "=", "$", "path", ";", "$", "external", "=", "true", ";", "unset", "(", "$", "options", "[", "'fullBase'", "]", ")", ";", "}", "else", "{", "$", "url", "=", "$", "this", "->", "Url", "->", "{", "$", "type", "}", "(", "$", "path", ",", "$", "options", ")", ";", "$", "options", "=", "array_diff_key", "(", "$", "options", ",", "[", "'fullBase'", "=>", "null", ",", "'pathPrefix'", "=>", "null", "]", ")", ";", "}", "return", "[", "$", "url", ",", "$", "options", ",", "$", "external", "]", ";", "}" ]
Get current options and url asset. @param string $path @param array $options @param string $type @param bool $external @return array
[ "Get", "current", "options", "and", "url", "asset", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L117-L129
16,721
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._getScriptOutput
protected function _getScriptOutput(array $options, $url) { return $this->formatTemplate('javascriptlink', [ 'url' => $url, 'attrs' => $this->templater()->formatAttributes($options, ['block', 'once', 'weight', 'alias']), ]); }
php
protected function _getScriptOutput(array $options, $url) { return $this->formatTemplate('javascriptlink', [ 'url' => $url, 'attrs' => $this->templater()->formatAttributes($options, ['block', 'once', 'weight', 'alias']), ]); }
[ "protected", "function", "_getScriptOutput", "(", "array", "$", "options", ",", "$", "url", ")", "{", "return", "$", "this", "->", "formatTemplate", "(", "'javascriptlink'", ",", "[", "'url'", "=>", "$", "url", ",", "'attrs'", "=>", "$", "this", "->", "templater", "(", ")", "->", "formatAttributes", "(", "$", "options", ",", "[", "'block'", ",", "'once'", ",", "'weight'", ",", "'alias'", "]", ")", ",", "]", ")", ";", "}" ]
Get current script output. @param array $options @param string $url @return string
[ "Get", "current", "script", "output", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L138-L144
16,722
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._getTypeOutput
protected function _getTypeOutput(array $options, $url, $type) { $type = Str::low($type); if ($type === 'css') { return $this->_getCssOutput($options, $url); } return $this->_getScriptOutput($options, $url); }
php
protected function _getTypeOutput(array $options, $url, $type) { $type = Str::low($type); if ($type === 'css') { return $this->_getCssOutput($options, $url); } return $this->_getScriptOutput($options, $url); }
[ "protected", "function", "_getTypeOutput", "(", "array", "$", "options", ",", "$", "url", ",", "$", "type", ")", "{", "$", "type", "=", "Str", "::", "low", "(", "$", "type", ")", ";", "if", "(", "$", "type", "===", "'css'", ")", "{", "return", "$", "this", "->", "_getCssOutput", "(", "$", "options", ",", "$", "url", ")", ";", "}", "return", "$", "this", "->", "_getScriptOutput", "(", "$", "options", ",", "$", "url", ")", ";", "}" ]
Get current output by type. @param array $options @param string $url @param string $type @return string
[ "Get", "current", "output", "by", "type", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L154-L162
16,723
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._hasAsset
protected function _hasAsset($path, $type, $external) { return !$this->Url->assetPath($path, $this->_getAssetType($type)) && $external === false; }
php
protected function _hasAsset($path, $type, $external) { return !$this->Url->assetPath($path, $this->_getAssetType($type)) && $external === false; }
[ "protected", "function", "_hasAsset", "(", "$", "path", ",", "$", "type", ",", "$", "external", ")", "{", "return", "!", "$", "this", "->", "Url", "->", "assetPath", "(", "$", "path", ",", "$", "this", "->", "_getAssetType", "(", "$", "type", ")", ")", "&&", "$", "external", "===", "false", ";", "}" ]
Check has asset. @param string $path @param string $type @param bool $external @return bool
[ "Check", "has", "asset", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L172-L175
16,724
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._include
protected function _include($path, array $options = [], $type = 'css') { $doc = $this->Document; $options += ['once' => true, 'block' => null, 'fullBase' => true, 'weight' => 10]; $external = false; $assetArray = $this->_arrayInclude($path, $options, $type); if ($assetArray) { return $assetArray; } $path = $this->_getCurrentPath($path, $assetArray); if (empty($path)) { return null; } $options += ['alias' => Str::slug($path)]; list($url, $options, $external) = $this->_getCurrentUrlAndOptions($path, $options, $type, $external); if (($this->_isOnceIncluded($path, $type, $options)) || $this->_hasAsset($path, $type, $external)) { return null; } unset($options['once']); $this->_includedAssets[$type][$path] = true; $out = $this->_getTypeOutput($options, $url, $type); $options['alias'] = Str::low($options['alias']); if ($options['block'] === 'assets') { $this->_assets[$type][$options['alias']] = [ 'url' => $url, 'output' => $out, 'path' => $path, 'weight' => $options['weight'], ]; return null; } if (empty($options['block'])) { return $out; } $options = $this->_setFetchBlock($options, $type); $this->_View->append($options['block'], $out . $doc->eol); }
php
protected function _include($path, array $options = [], $type = 'css') { $doc = $this->Document; $options += ['once' => true, 'block' => null, 'fullBase' => true, 'weight' => 10]; $external = false; $assetArray = $this->_arrayInclude($path, $options, $type); if ($assetArray) { return $assetArray; } $path = $this->_getCurrentPath($path, $assetArray); if (empty($path)) { return null; } $options += ['alias' => Str::slug($path)]; list($url, $options, $external) = $this->_getCurrentUrlAndOptions($path, $options, $type, $external); if (($this->_isOnceIncluded($path, $type, $options)) || $this->_hasAsset($path, $type, $external)) { return null; } unset($options['once']); $this->_includedAssets[$type][$path] = true; $out = $this->_getTypeOutput($options, $url, $type); $options['alias'] = Str::low($options['alias']); if ($options['block'] === 'assets') { $this->_assets[$type][$options['alias']] = [ 'url' => $url, 'output' => $out, 'path' => $path, 'weight' => $options['weight'], ]; return null; } if (empty($options['block'])) { return $out; } $options = $this->_setFetchBlock($options, $type); $this->_View->append($options['block'], $out . $doc->eol); }
[ "protected", "function", "_include", "(", "$", "path", ",", "array", "$", "options", "=", "[", "]", ",", "$", "type", "=", "'css'", ")", "{", "$", "doc", "=", "$", "this", "->", "Document", ";", "$", "options", "+=", "[", "'once'", "=>", "true", ",", "'block'", "=>", "null", ",", "'fullBase'", "=>", "true", ",", "'weight'", "=>", "10", "]", ";", "$", "external", "=", "false", ";", "$", "assetArray", "=", "$", "this", "->", "_arrayInclude", "(", "$", "path", ",", "$", "options", ",", "$", "type", ")", ";", "if", "(", "$", "assetArray", ")", "{", "return", "$", "assetArray", ";", "}", "$", "path", "=", "$", "this", "->", "_getCurrentPath", "(", "$", "path", ",", "$", "assetArray", ")", ";", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "return", "null", ";", "}", "$", "options", "+=", "[", "'alias'", "=>", "Str", "::", "slug", "(", "$", "path", ")", "]", ";", "list", "(", "$", "url", ",", "$", "options", ",", "$", "external", ")", "=", "$", "this", "->", "_getCurrentUrlAndOptions", "(", "$", "path", ",", "$", "options", ",", "$", "type", ",", "$", "external", ")", ";", "if", "(", "(", "$", "this", "->", "_isOnceIncluded", "(", "$", "path", ",", "$", "type", ",", "$", "options", ")", ")", "||", "$", "this", "->", "_hasAsset", "(", "$", "path", ",", "$", "type", ",", "$", "external", ")", ")", "{", "return", "null", ";", "}", "unset", "(", "$", "options", "[", "'once'", "]", ")", ";", "$", "this", "->", "_includedAssets", "[", "$", "type", "]", "[", "$", "path", "]", "=", "true", ";", "$", "out", "=", "$", "this", "->", "_getTypeOutput", "(", "$", "options", ",", "$", "url", ",", "$", "type", ")", ";", "$", "options", "[", "'alias'", "]", "=", "Str", "::", "low", "(", "$", "options", "[", "'alias'", "]", ")", ";", "if", "(", "$", "options", "[", "'block'", "]", "===", "'assets'", ")", "{", "$", "this", "->", "_assets", "[", "$", "type", "]", "[", "$", "options", "[", "'alias'", "]", "]", "=", "[", "'url'", "=>", "$", "url", ",", "'output'", "=>", "$", "out", ",", "'path'", "=>", "$", "path", ",", "'weight'", "=>", "$", "options", "[", "'weight'", "]", ",", "]", ";", "return", "null", ";", "}", "if", "(", "empty", "(", "$", "options", "[", "'block'", "]", ")", ")", "{", "return", "$", "out", ";", "}", "$", "options", "=", "$", "this", "->", "_setFetchBlock", "(", "$", "options", ",", "$", "type", ")", ";", "$", "this", "->", "_View", "->", "append", "(", "$", "options", "[", "'block'", "]", ",", "$", "out", ".", "$", "doc", "->", "eol", ")", ";", "}" ]
Include asset. @param string|array $path @param array $options @param string $type @return bool|null|string
[ "Include", "asset", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L185-L231
16,725
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._isOnceIncluded
protected function _isOnceIncluded($path, $type, array $options = []) { return $options['once'] && isset($this->_includedAssets[$type][$path]); }
php
protected function _isOnceIncluded($path, $type, array $options = []) { return $options['once'] && isset($this->_includedAssets[$type][$path]); }
[ "protected", "function", "_isOnceIncluded", "(", "$", "path", ",", "$", "type", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "options", "[", "'once'", "]", "&&", "isset", "(", "$", "this", "->", "_includedAssets", "[", "$", "type", "]", "[", "$", "path", "]", ")", ";", "}" ]
Check asset on once include. @param string $path @param string $type @param array $options @return bool
[ "Check", "asset", "on", "once", "include", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L241-L244
16,726
dafiti/datajet-client
src/Datajet/Resource/Batch.php
Batch.finish
public function finish() { $response = $this->client->post("{$this->uriImport}fullimport/finish", [ 'query' => [ 'key' => $this->config['data']['key'], ], ]); $response = json_decode($response->getBody(), true); return isset($response['status']) && $response['status'] === 'ok'; }
php
public function finish() { $response = $this->client->post("{$this->uriImport}fullimport/finish", [ 'query' => [ 'key' => $this->config['data']['key'], ], ]); $response = json_decode($response->getBody(), true); return isset($response['status']) && $response['status'] === 'ok'; }
[ "public", "function", "finish", "(", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "post", "(", "\"{$this->uriImport}fullimport/finish\"", ",", "[", "'query'", "=>", "[", "'key'", "=>", "$", "this", "->", "config", "[", "'data'", "]", "[", "'key'", "]", ",", "]", ",", "]", ")", ";", "$", "response", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "return", "isset", "(", "$", "response", "[", "'status'", "]", ")", "&&", "$", "response", "[", "'status'", "]", "===", "'ok'", ";", "}" ]
Close import queue. @throws \GuzzleHttp\Exception\GuzzleException @return bool
[ "Close", "import", "queue", "." ]
c8555362521690b95451d2006d891b30facd8a46
https://github.com/dafiti/datajet-client/blob/c8555362521690b95451d2006d891b30facd8a46/src/Datajet/Resource/Batch.php#L69-L80
16,727
webforge-labs/psc-cms
lib/Psc/Mail/Helper.php
Helper.send
public static function send(Swift_Message $message, Swift_SmtpTransport $transport = NULL, Swift_Mailer $mailer = NULL) { if (!isset($transport) && !isset($mailer)) { if (Config::req('mail.smtp.user') != NULL) { $transport = Swift_SmtpTransport::newInstance('smtprelaypool.ispgateway.de',465, 'ssl') ->setUsername(Config::req('mail.smtp.user')) ->setPassword(Config::req('mail.smtp.password')); } else { $transport = Swift_Mailtransport::newInstance(); // lokaler mailer } } if (!isset($mailer)) { $mailer = \Swift_Mailer::newInstance($transport); } return $mailer->send($message); }
php
public static function send(Swift_Message $message, Swift_SmtpTransport $transport = NULL, Swift_Mailer $mailer = NULL) { if (!isset($transport) && !isset($mailer)) { if (Config::req('mail.smtp.user') != NULL) { $transport = Swift_SmtpTransport::newInstance('smtprelaypool.ispgateway.de',465, 'ssl') ->setUsername(Config::req('mail.smtp.user')) ->setPassword(Config::req('mail.smtp.password')); } else { $transport = Swift_Mailtransport::newInstance(); // lokaler mailer } } if (!isset($mailer)) { $mailer = \Swift_Mailer::newInstance($transport); } return $mailer->send($message); }
[ "public", "static", "function", "send", "(", "Swift_Message", "$", "message", ",", "Swift_SmtpTransport", "$", "transport", "=", "NULL", ",", "Swift_Mailer", "$", "mailer", "=", "NULL", ")", "{", "if", "(", "!", "isset", "(", "$", "transport", ")", "&&", "!", "isset", "(", "$", "mailer", ")", ")", "{", "if", "(", "Config", "::", "req", "(", "'mail.smtp.user'", ")", "!=", "NULL", ")", "{", "$", "transport", "=", "Swift_SmtpTransport", "::", "newInstance", "(", "'smtprelaypool.ispgateway.de'", ",", "465", ",", "'ssl'", ")", "->", "setUsername", "(", "Config", "::", "req", "(", "'mail.smtp.user'", ")", ")", "->", "setPassword", "(", "Config", "::", "req", "(", "'mail.smtp.password'", ")", ")", ";", "}", "else", "{", "$", "transport", "=", "Swift_Mailtransport", "::", "newInstance", "(", ")", ";", "// lokaler mailer", "}", "}", "if", "(", "!", "isset", "(", "$", "mailer", ")", ")", "{", "$", "mailer", "=", "\\", "Swift_Mailer", "::", "newInstance", "(", "$", "transport", ")", ";", "}", "return", "$", "mailer", "->", "send", "(", "$", "message", ")", ";", "}" ]
Sendet die Message Wird Transport und Mailer nicht angegeben, werden diese erstellt Ist ein Mailer angegeben wird transport nicht erstellt (wird ignoriert) wenn ein SMTP Zugang mit Config[mail.smtp.user] und Config[mail.smtp.password] gesetzt wurde, wird dieser als Transport genutzt ansonsten der lokale Mailer @return die Ausgabe von mailer->send() (int $sent)
[ "Sendet", "die", "Message" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Mail/Helper.php#L99-L116
16,728
parsnick/steak
src/Boot/RegisterBladeExtensions.php
RegisterBladeExtensions.allowHighlightTag
protected function allowHighlightTag(BladeCompiler $compiler) { $compiler->directive('highlight', function ($expression) { if (is_null($expression)) { $expression = "('php')"; } return "<?php \$__env->startSection{$expression}; ?>"; }); $compiler->directive('endhighlight', function () { return <<<'HTML' <?php $last = $__env->stopSection(); echo '<pre><code class="language-', $last, '">', trim($__env->yieldContent($last)), '</code></pre>'; ?> HTML; }); }
php
protected function allowHighlightTag(BladeCompiler $compiler) { $compiler->directive('highlight', function ($expression) { if (is_null($expression)) { $expression = "('php')"; } return "<?php \$__env->startSection{$expression}; ?>"; }); $compiler->directive('endhighlight', function () { return <<<'HTML' <?php $last = $__env->stopSection(); echo '<pre><code class="language-', $last, '">', trim($__env->yieldContent($last)), '</code></pre>'; ?> HTML; }); }
[ "protected", "function", "allowHighlightTag", "(", "BladeCompiler", "$", "compiler", ")", "{", "$", "compiler", "->", "directive", "(", "'highlight'", ",", "function", "(", "$", "expression", ")", "{", "if", "(", "is_null", "(", "$", "expression", ")", ")", "{", "$", "expression", "=", "\"('php')\"", ";", "}", "return", "\"<?php \\$__env->startSection{$expression}; ?>\"", ";", "}", ")", ";", "$", "compiler", "->", "directive", "(", "'endhighlight'", ",", "function", "(", ")", "{", "return", " <<<'HTML'\n<?php $last = $__env->stopSection(); echo '<pre><code class=\"language-', $last, '\">', trim($__env->yieldContent($last)), '</code></pre>'; ?>\nHTML", ";", "}", ")", ";", "}" ]
Add basic syntax highlighting. This just adds markup that is picked up by a javascript highlighting library. @param BladeCompiler $compiler
[ "Add", "basic", "syntax", "highlighting", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Boot/RegisterBladeExtensions.php#L31-L45
16,729
webforge-labs/psc-cms
lib/Psc/CMS/Item/MetaAdapter.php
MetaAdapter.getAdapter
protected function getAdapter($context) { return $this->context === $context || $context === NULL ? $this : new static($this->entityMeta, $context); }
php
protected function getAdapter($context) { return $this->context === $context || $context === NULL ? $this : new static($this->entityMeta, $context); }
[ "protected", "function", "getAdapter", "(", "$", "context", ")", "{", "return", "$", "this", "->", "context", "===", "$", "context", "||", "$", "context", "===", "NULL", "?", "$", "this", ":", "new", "static", "(", "$", "this", "->", "entityMeta", ",", "$", "context", ")", ";", "}" ]
Erstellt einen neuen MetaAdapter im richtigen Context @return MetaAdapter mit dem angegebenen Context
[ "Erstellt", "einen", "neuen", "MetaAdapter", "im", "richtigen", "Context" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Item/MetaAdapter.php#L106-L108
16,730
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/ManiaFlash.php
ManiaFlash.getHashtagMessages
public function getHashtagMessages($name, $offset = 0, $length = 10) { if(!$name) { throw new Exception('Please specify a tag name'); } return $this->execute('GET', '/maniaflash/hashtags/%s/messages/?offset=%d&length=%d', array($name, $offset, $length)); }
php
public function getHashtagMessages($name, $offset = 0, $length = 10) { if(!$name) { throw new Exception('Please specify a tag name'); } return $this->execute('GET', '/maniaflash/hashtags/%s/messages/?offset=%d&length=%d', array($name, $offset, $length)); }
[ "public", "function", "getHashtagMessages", "(", "$", "name", ",", "$", "offset", "=", "0", ",", "$", "length", "=", "10", ")", "{", "if", "(", "!", "$", "name", ")", "{", "throw", "new", "Exception", "(", "'Please specify a tag name'", ")", ";", "}", "return", "$", "this", "->", "execute", "(", "'GET'", ",", "'/maniaflash/hashtags/%s/messages/?offset=%d&length=%d'", ",", "array", "(", "$", "name", ",", "$", "offset", ",", "$", "length", ")", ")", ";", "}" ]
Return latest messages of an hashtag @param string $id @return Object[] - id - author - dateCreated - message - longMessage - mediaURL @throws Exception
[ "Return", "latest", "messages", "of", "an", "hashtag" ]
027a458388035fe66f2f56ff3ea1f85eff2a5a4e
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/ManiaFlash.php#L47-L54
16,731
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/ManiaFlash.php
ManiaFlash.getMessages
public function getMessages($id, $offset = 0, $length = 10) { if(!$id) { throw new Exception('Invalid id'); } return $this->execute('GET', '/maniaflash/channels/%s/messages/?offset=%d&length=%d', array($id, $offset, $length)); }
php
public function getMessages($id, $offset = 0, $length = 10) { if(!$id) { throw new Exception('Invalid id'); } return $this->execute('GET', '/maniaflash/channels/%s/messages/?offset=%d&length=%d', array($id, $offset, $length)); }
[ "public", "function", "getMessages", "(", "$", "id", ",", "$", "offset", "=", "0", ",", "$", "length", "=", "10", ")", "{", "if", "(", "!", "$", "id", ")", "{", "throw", "new", "Exception", "(", "'Invalid id'", ")", ";", "}", "return", "$", "this", "->", "execute", "(", "'GET'", ",", "'/maniaflash/channels/%s/messages/?offset=%d&length=%d'", ",", "array", "(", "$", "id", ",", "$", "offset", ",", "$", "length", ")", ")", ";", "}" ]
Return latest messages of a channel @param string $id @return Object[] - id - author - dateCreated - message - longMessage - mediaURL @throws Exception
[ "Return", "latest", "messages", "of", "a", "channel" ]
027a458388035fe66f2f56ff3ea1f85eff2a5a4e
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/ManiaFlash.php#L68-L75
16,732
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/ManiaFlash.php
ManiaFlash.postMessage
public function postMessage($channelId, $message, $longMessage = null, $mediaURL = null) { return $this->execute('POST', '/maniaflash/channels/%s/', array( $channelId, array( 'message' => $message, 'longMessage' => $longMessage, 'mediaURL' => $mediaURL))); }
php
public function postMessage($channelId, $message, $longMessage = null, $mediaURL = null) { return $this->execute('POST', '/maniaflash/channels/%s/', array( $channelId, array( 'message' => $message, 'longMessage' => $longMessage, 'mediaURL' => $mediaURL))); }
[ "public", "function", "postMessage", "(", "$", "channelId", ",", "$", "message", ",", "$", "longMessage", "=", "null", ",", "$", "mediaURL", "=", "null", ")", "{", "return", "$", "this", "->", "execute", "(", "'POST'", ",", "'/maniaflash/channels/%s/'", ",", "array", "(", "$", "channelId", ",", "array", "(", "'message'", "=>", "$", "message", ",", "'longMessage'", "=>", "$", "longMessage", ",", "'mediaURL'", "=>", "$", "mediaURL", ")", ")", ")", ";", "}" ]
Publish a message on a maniaflash channel @param string $channelId @param string $message @param string $longMessage @param string $mediaUrl @return type
[ "Publish", "a", "message", "on", "a", "maniaflash", "channel" ]
027a458388035fe66f2f56ff3ea1f85eff2a5a4e
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/ManiaFlash.php#L85-L93
16,733
Craftsware/scissor
src/Module/View.php
View.data
private function data($view) { $data['var'] = $this->module->get('var'); if(isset($view['with']) ) { foreach((array) $view['with'] as $name => $value) { $data['var'][$name] = $value; } } $data['file'] = $this->getPath($view, $this->module->get('module')); return $data; }
php
private function data($view) { $data['var'] = $this->module->get('var'); if(isset($view['with']) ) { foreach((array) $view['with'] as $name => $value) { $data['var'][$name] = $value; } } $data['file'] = $this->getPath($view, $this->module->get('module')); return $data; }
[ "private", "function", "data", "(", "$", "view", ")", "{", "$", "data", "[", "'var'", "]", "=", "$", "this", "->", "module", "->", "get", "(", "'var'", ")", ";", "if", "(", "isset", "(", "$", "view", "[", "'with'", "]", ")", ")", "{", "foreach", "(", "(", "array", ")", "$", "view", "[", "'with'", "]", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "data", "[", "'var'", "]", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "$", "data", "[", "'file'", "]", "=", "$", "this", "->", "getPath", "(", "$", "view", ",", "$", "this", "->", "module", "->", "get", "(", "'module'", ")", ")", ";", "return", "$", "data", ";", "}" ]
Prepare the data path for the requested view @param array $view @param array $data
[ "Prepare", "the", "data", "path", "for", "the", "requested", "view" ]
644e4a8ea9859fc30fee36705e54784acd8d43e2
https://github.com/Craftsware/scissor/blob/644e4a8ea9859fc30fee36705e54784acd8d43e2/src/Module/View.php#L137-L154
16,734
Craftsware/scissor
src/Module/View.php
View.load
private function load($view) { $data = $this->data($view); if(file_exists($data['file'])) { extract($data['var']); require $data['file']; } }
php
private function load($view) { $data = $this->data($view); if(file_exists($data['file'])) { extract($data['var']); require $data['file']; } }
[ "private", "function", "load", "(", "$", "view", ")", "{", "$", "data", "=", "$", "this", "->", "data", "(", "$", "view", ")", ";", "if", "(", "file_exists", "(", "$", "data", "[", "'file'", "]", ")", ")", "{", "extract", "(", "$", "data", "[", "'var'", "]", ")", ";", "require", "$", "data", "[", "'file'", "]", ";", "}", "}" ]
View the file to the controller @param array $view
[ "View", "the", "file", "to", "the", "controller" ]
644e4a8ea9859fc30fee36705e54784acd8d43e2
https://github.com/Craftsware/scissor/blob/644e4a8ea9859fc30fee36705e54784acd8d43e2/src/Module/View.php#L164-L174
16,735
Craftsware/scissor
src/Module/View.php
View.getPath
private function getPath($view, $module) { if(isset($module)) { if(isset($view['from'])) { return realpath(dirname($module['path']) . '/' . $view['from'] . '/Views/' . $view['name'] . '.php'); } else { return realpath($module['path'] . '/Views/' . $view['name'] . '.php'); } } }
php
private function getPath($view, $module) { if(isset($module)) { if(isset($view['from'])) { return realpath(dirname($module['path']) . '/' . $view['from'] . '/Views/' . $view['name'] . '.php'); } else { return realpath($module['path'] . '/Views/' . $view['name'] . '.php'); } } }
[ "private", "function", "getPath", "(", "$", "view", ",", "$", "module", ")", "{", "if", "(", "isset", "(", "$", "module", ")", ")", "{", "if", "(", "isset", "(", "$", "view", "[", "'from'", "]", ")", ")", "{", "return", "realpath", "(", "dirname", "(", "$", "module", "[", "'path'", "]", ")", ".", "'/'", ".", "$", "view", "[", "'from'", "]", ".", "'/Views/'", ".", "$", "view", "[", "'name'", "]", ".", "'.php'", ")", ";", "}", "else", "{", "return", "realpath", "(", "$", "module", "[", "'path'", "]", ".", "'/Views/'", ".", "$", "view", "[", "'name'", "]", ".", "'.php'", ")", ";", "}", "}", "}" ]
Get file path for the requested view name @param array $view @param array $mod @return string
[ "Get", "file", "path", "for", "the", "requested", "view", "name" ]
644e4a8ea9859fc30fee36705e54784acd8d43e2
https://github.com/Craftsware/scissor/blob/644e4a8ea9859fc30fee36705e54784acd8d43e2/src/Module/View.php#L195-L209
16,736
ClanCats/Core
src/classes/CCController.php
CCController.has_action
public static function has_action( $path, $action = null ) { $path = CCStr::cut( $path, '@' ); $path = CCStr::cut( $path, '?' ); // fix closure given if ( !is_string( $path ) ) { return false; } // get controllers default action if ( is_null( $action ) ) { $action = static::$_default_action; } // try to load the controller if ( !$controller = static::create( $path ) ) { return false; } return method_exists( $controller, static::$_action_prefix.$action ); }
php
public static function has_action( $path, $action = null ) { $path = CCStr::cut( $path, '@' ); $path = CCStr::cut( $path, '?' ); // fix closure given if ( !is_string( $path ) ) { return false; } // get controllers default action if ( is_null( $action ) ) { $action = static::$_default_action; } // try to load the controller if ( !$controller = static::create( $path ) ) { return false; } return method_exists( $controller, static::$_action_prefix.$action ); }
[ "public", "static", "function", "has_action", "(", "$", "path", ",", "$", "action", "=", "null", ")", "{", "$", "path", "=", "CCStr", "::", "cut", "(", "$", "path", ",", "'@'", ")", ";", "$", "path", "=", "CCStr", "::", "cut", "(", "$", "path", ",", "'?'", ")", ";", "// fix closure given", "if", "(", "!", "is_string", "(", "$", "path", ")", ")", "{", "return", "false", ";", "}", "// get controllers default action", "if", "(", "is_null", "(", "$", "action", ")", ")", "{", "$", "action", "=", "static", "::", "$", "_default_action", ";", "}", "// try to load the controller", "if", "(", "!", "$", "controller", "=", "static", "::", "create", "(", "$", "path", ")", ")", "{", "return", "false", ";", "}", "return", "method_exists", "(", "$", "controller", ",", "static", "::", "$", "_action_prefix", ".", "$", "action", ")", ";", "}" ]
check if a controller implements an action @param string $path @param string $action @return bool
[ "check", "if", "a", "controller", "implements", "an", "action" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCController.php#L84-L108
16,737
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.checkContainerForWrite
public function checkContainerForWrite($container) { $container = static::addContainerToName($container, ''); if (!is_dir($container)) { if (!mkdir($container, 0777, true)) { throw new InternalServerErrorException('Failed to create container.'); } } }
php
public function checkContainerForWrite($container) { $container = static::addContainerToName($container, ''); if (!is_dir($container)) { if (!mkdir($container, 0777, true)) { throw new InternalServerErrorException('Failed to create container.'); } } }
[ "public", "function", "checkContainerForWrite", "(", "$", "container", ")", "{", "$", "container", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "''", ")", ";", "if", "(", "!", "is_dir", "(", "$", "container", ")", ")", "{", "if", "(", "!", "mkdir", "(", "$", "container", ",", "0777", ",", "true", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'Failed to create container.'", ")", ";", "}", "}", "}" ]
Creates the container for this file management if it does not already exist @param string $container @throws \Exception
[ "Creates", "the", "container", "for", "this", "file", "management", "if", "it", "does", "not", "already", "exist" ]
e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L44-L52
16,738
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.createContainer
public function createContainer($properties = [], $check_exist = false) { $container = array_get($properties, 'name', array_get($properties, 'path')); if (empty($container)) { throw new BadRequestException('No name found for container in create request.'); } // does this folder already exist? if ($this->folderExists($container, '')) { if ($check_exist) { throw new BadRequestException("Container '$container' already exists."); } } else { // create the container $dir = static::addContainerToName($container, ''); if (!mkdir($dir, 0777, true)) { throw new InternalServerErrorException('Failed to create container.'); } } return ['name' => $container, 'path' => $container]; // $properties = (empty($properties)) ? '' : json_encode($properties); // $result = file_put_contents($key, $properties); // if (false === $result) { // throw new InternalServerErrorException('Failed to create container properties.'); // } }
php
public function createContainer($properties = [], $check_exist = false) { $container = array_get($properties, 'name', array_get($properties, 'path')); if (empty($container)) { throw new BadRequestException('No name found for container in create request.'); } // does this folder already exist? if ($this->folderExists($container, '')) { if ($check_exist) { throw new BadRequestException("Container '$container' already exists."); } } else { // create the container $dir = static::addContainerToName($container, ''); if (!mkdir($dir, 0777, true)) { throw new InternalServerErrorException('Failed to create container.'); } } return ['name' => $container, 'path' => $container]; // $properties = (empty($properties)) ? '' : json_encode($properties); // $result = file_put_contents($key, $properties); // if (false === $result) { // throw new InternalServerErrorException('Failed to create container properties.'); // } }
[ "public", "function", "createContainer", "(", "$", "properties", "=", "[", "]", ",", "$", "check_exist", "=", "false", ")", "{", "$", "container", "=", "array_get", "(", "$", "properties", ",", "'name'", ",", "array_get", "(", "$", "properties", ",", "'path'", ")", ")", ";", "if", "(", "empty", "(", "$", "container", ")", ")", "{", "throw", "new", "BadRequestException", "(", "'No name found for container in create request.'", ")", ";", "}", "// does this folder already exist?", "if", "(", "$", "this", "->", "folderExists", "(", "$", "container", ",", "''", ")", ")", "{", "if", "(", "$", "check_exist", ")", "{", "throw", "new", "BadRequestException", "(", "\"Container '$container' already exists.\"", ")", ";", "}", "}", "else", "{", "// create the container", "$", "dir", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "''", ")", ";", "if", "(", "!", "mkdir", "(", "$", "dir", ",", "0777", ",", "true", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'Failed to create container.'", ")", ";", "}", "}", "return", "[", "'name'", "=>", "$", "container", ",", "'path'", "=>", "$", "container", "]", ";", "// $properties = (empty($properties)) ? '' : json_encode($properties);", "// $result = file_put_contents($key, $properties);", "// if (false === $result) {", "// throw new InternalServerErrorException('Failed to create container properties.');", "// }", "}" ]
Create a container using properties, where at least name is required @param array $properties @param bool $check_exist If true, throws error if the container already exists @throws \Exception @throws BadRequestException @return array
[ "Create", "a", "container", "using", "properties", "where", "at", "least", "name", "is", "required" ]
e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L135-L162
16,739
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.createContainers
public function createContainers($containers = [], $check_exist = false) { if (empty($containers)) { return []; } $out = []; foreach ($containers as $key => $folder) { try { // path is full path, name is relative to root, take either $out[$key] = $this->createContainer($folder, $check_exist); } catch (\Exception $ex) { // error whole batch here? $out[$key]['error'] = ['message' => $ex->getMessage(), 'code' => $ex->getCode()]; } } return $out; }
php
public function createContainers($containers = [], $check_exist = false) { if (empty($containers)) { return []; } $out = []; foreach ($containers as $key => $folder) { try { // path is full path, name is relative to root, take either $out[$key] = $this->createContainer($folder, $check_exist); } catch (\Exception $ex) { // error whole batch here? $out[$key]['error'] = ['message' => $ex->getMessage(), 'code' => $ex->getCode()]; } } return $out; }
[ "public", "function", "createContainers", "(", "$", "containers", "=", "[", "]", ",", "$", "check_exist", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "containers", ")", ")", "{", "return", "[", "]", ";", "}", "$", "out", "=", "[", "]", ";", "foreach", "(", "$", "containers", "as", "$", "key", "=>", "$", "folder", ")", "{", "try", "{", "// path is full path, name is relative to root, take either", "$", "out", "[", "$", "key", "]", "=", "$", "this", "->", "createContainer", "(", "$", "folder", ",", "$", "check_exist", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "// error whole batch here?", "$", "out", "[", "$", "key", "]", "[", "'error'", "]", "=", "[", "'message'", "=>", "$", "ex", "->", "getMessage", "(", ")", ",", "'code'", "=>", "$", "ex", "->", "getCode", "(", ")", "]", ";", "}", "}", "return", "$", "out", ";", "}" ]
Create multiple containers using array of properties, where at least name is required @param array $containers @param bool $check_exist If true, throws error if the container already exists @return array
[ "Create", "multiple", "containers", "using", "array", "of", "properties", "where", "at", "least", "name", "is", "required" ]
e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L172-L190
16,740
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.listTree
public static function listTree($root, $prefix = '', $delimiter = '') { $dir = $root . ((!empty($prefix)) ? $prefix : ''); $out = []; if (is_dir($dir)) { $files = array_diff(scandir($dir), ['.', '..']); foreach ($files as $file) { $key = $dir . $file; $local = ((!empty($prefix)) ? $prefix : '') . $file; // get file meta if (is_dir($key)) { $stat = stat($key); $out[] = [ 'path' => str_replace(DIRECTORY_SEPARATOR, '/', $local) . '/', 'last_modified' => gmdate('D, d M Y H:i:s \G\M\T', array_get($stat, 'mtime', 0)) ]; if (empty($delimiter)) { $out = array_merge($out, static::listTree($root, $local . DIRECTORY_SEPARATOR)); } } elseif (is_file($key)) { $stat = stat($key); $ext = FileUtilities::getFileExtension($key); $out[] = [ 'path' => str_replace(DIRECTORY_SEPARATOR, '/', $local), 'content_type' => FileUtilities::determineContentType($ext, '', $key), 'last_modified' => gmdate('D, d M Y H:i:s \G\M\T', array_get($stat, 'mtime', 0)), 'content_length' => array_get($stat, 'size', 0) ]; } else { error_log($key); } } } else { throw new NotFoundException("Folder '$prefix' does not exist in storage."); } return $out; }
php
public static function listTree($root, $prefix = '', $delimiter = '') { $dir = $root . ((!empty($prefix)) ? $prefix : ''); $out = []; if (is_dir($dir)) { $files = array_diff(scandir($dir), ['.', '..']); foreach ($files as $file) { $key = $dir . $file; $local = ((!empty($prefix)) ? $prefix : '') . $file; // get file meta if (is_dir($key)) { $stat = stat($key); $out[] = [ 'path' => str_replace(DIRECTORY_SEPARATOR, '/', $local) . '/', 'last_modified' => gmdate('D, d M Y H:i:s \G\M\T', array_get($stat, 'mtime', 0)) ]; if (empty($delimiter)) { $out = array_merge($out, static::listTree($root, $local . DIRECTORY_SEPARATOR)); } } elseif (is_file($key)) { $stat = stat($key); $ext = FileUtilities::getFileExtension($key); $out[] = [ 'path' => str_replace(DIRECTORY_SEPARATOR, '/', $local), 'content_type' => FileUtilities::determineContentType($ext, '', $key), 'last_modified' => gmdate('D, d M Y H:i:s \G\M\T', array_get($stat, 'mtime', 0)), 'content_length' => array_get($stat, 'size', 0) ]; } else { error_log($key); } } } else { throw new NotFoundException("Folder '$prefix' does not exist in storage."); } return $out; }
[ "public", "static", "function", "listTree", "(", "$", "root", ",", "$", "prefix", "=", "''", ",", "$", "delimiter", "=", "''", ")", "{", "$", "dir", "=", "$", "root", ".", "(", "(", "!", "empty", "(", "$", "prefix", ")", ")", "?", "$", "prefix", ":", "''", ")", ";", "$", "out", "=", "[", "]", ";", "if", "(", "is_dir", "(", "$", "dir", ")", ")", "{", "$", "files", "=", "array_diff", "(", "scandir", "(", "$", "dir", ")", ",", "[", "'.'", ",", "'..'", "]", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "key", "=", "$", "dir", ".", "$", "file", ";", "$", "local", "=", "(", "(", "!", "empty", "(", "$", "prefix", ")", ")", "?", "$", "prefix", ":", "''", ")", ".", "$", "file", ";", "// get file meta", "if", "(", "is_dir", "(", "$", "key", ")", ")", "{", "$", "stat", "=", "stat", "(", "$", "key", ")", ";", "$", "out", "[", "]", "=", "[", "'path'", "=>", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "$", "local", ")", ".", "'/'", ",", "'last_modified'", "=>", "gmdate", "(", "'D, d M Y H:i:s \\G\\M\\T'", ",", "array_get", "(", "$", "stat", ",", "'mtime'", ",", "0", ")", ")", "]", ";", "if", "(", "empty", "(", "$", "delimiter", ")", ")", "{", "$", "out", "=", "array_merge", "(", "$", "out", ",", "static", "::", "listTree", "(", "$", "root", ",", "$", "local", ".", "DIRECTORY_SEPARATOR", ")", ")", ";", "}", "}", "elseif", "(", "is_file", "(", "$", "key", ")", ")", "{", "$", "stat", "=", "stat", "(", "$", "key", ")", ";", "$", "ext", "=", "FileUtilities", "::", "getFileExtension", "(", "$", "key", ")", ";", "$", "out", "[", "]", "=", "[", "'path'", "=>", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "$", "local", ")", ",", "'content_type'", "=>", "FileUtilities", "::", "determineContentType", "(", "$", "ext", ",", "''", ",", "$", "key", ")", ",", "'last_modified'", "=>", "gmdate", "(", "'D, d M Y H:i:s \\G\\M\\T'", ",", "array_get", "(", "$", "stat", ",", "'mtime'", ",", "0", ")", ")", ",", "'content_length'", "=>", "array_get", "(", "$", "stat", ",", "'size'", ",", "0", ")", "]", ";", "}", "else", "{", "error_log", "(", "$", "key", ")", ";", "}", "}", "}", "else", "{", "throw", "new", "NotFoundException", "(", "\"Folder '$prefix' does not exist in storage.\"", ")", ";", "}", "return", "$", "out", ";", "}" ]
List folders and files @param string $root root path name @param string $prefix Optional. search only for folders and files by specified prefix. @param string $delimiter Optional. Delimiter, i.e. '/', for specifying folder hierarchy @return array @throws \Exception
[ "List", "folders", "and", "files" ]
e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L932-L969
16,741
voda/php-translator
Antee/i18n/TranslateMacros.php
TranslateMacros.install
public static function install(Compiler $parser) { $me = new static($parser); $callback = array($me, 'macroGettext'); $me->addMacro('_', $callback); $me->addMacro('_n', $callback); $me->addMacro('_p', $callback); $me->addMacro('_np', $callback); }
php
public static function install(Compiler $parser) { $me = new static($parser); $callback = array($me, 'macroGettext'); $me->addMacro('_', $callback); $me->addMacro('_n', $callback); $me->addMacro('_p', $callback); $me->addMacro('_np', $callback); }
[ "public", "static", "function", "install", "(", "Compiler", "$", "parser", ")", "{", "$", "me", "=", "new", "static", "(", "$", "parser", ")", ";", "$", "callback", "=", "array", "(", "$", "me", ",", "'macroGettext'", ")", ";", "$", "me", "->", "addMacro", "(", "'_'", ",", "$", "callback", ")", ";", "$", "me", "->", "addMacro", "(", "'_n'", ",", "$", "callback", ")", ";", "$", "me", "->", "addMacro", "(", "'_p'", ",", "$", "callback", ")", ";", "$", "me", "->", "addMacro", "(", "'_np'", ",", "$", "callback", ")", ";", "}" ]
Add gettext macros @param Template @param ITranslator
[ "Add", "gettext", "macros" ]
b1890ce89f7185b8958e6cf89cf2ad231d5e5f58
https://github.com/voda/php-translator/blob/b1890ce89f7185b8958e6cf89cf2ad231d5e5f58/Antee/i18n/TranslateMacros.php#L65-L72
16,742
voda/php-translator
Antee/i18n/TranslateMacros.php
TranslateMacros.registerHelpers
public static function registerHelpers(Template $template, ITranslator $translator) { $template->registerHelper('gettext', array($translator, 'gettext')); $template->registerHelper('ngettext', array($translator, 'ngettext')); $template->registerHelper('pgettext', array($translator, 'pgettext')); $template->registerHelper('npgettext', array($translator, 'npgettext')); }
php
public static function registerHelpers(Template $template, ITranslator $translator) { $template->registerHelper('gettext', array($translator, 'gettext')); $template->registerHelper('ngettext', array($translator, 'ngettext')); $template->registerHelper('pgettext', array($translator, 'pgettext')); $template->registerHelper('npgettext', array($translator, 'npgettext')); }
[ "public", "static", "function", "registerHelpers", "(", "Template", "$", "template", ",", "ITranslator", "$", "translator", ")", "{", "$", "template", "->", "registerHelper", "(", "'gettext'", ",", "array", "(", "$", "translator", ",", "'gettext'", ")", ")", ";", "$", "template", "->", "registerHelper", "(", "'ngettext'", ",", "array", "(", "$", "translator", ",", "'ngettext'", ")", ")", ";", "$", "template", "->", "registerHelper", "(", "'pgettext'", ",", "array", "(", "$", "translator", ",", "'pgettext'", ")", ")", ";", "$", "template", "->", "registerHelper", "(", "'npgettext'", ",", "array", "(", "$", "translator", ",", "'npgettext'", ")", ")", ";", "}" ]
Add gettext helpers to template. @param Template @param ITranslator
[ "Add", "gettext", "helpers", "to", "template", "." ]
b1890ce89f7185b8958e6cf89cf2ad231d5e5f58
https://github.com/voda/php-translator/blob/b1890ce89f7185b8958e6cf89cf2ad231d5e5f58/Antee/i18n/TranslateMacros.php#L80-L85
16,743
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php
BaseUserRolePeer.doSelectJoinAll
public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(UserRolePeer::DATABASE_NAME); } UserRolePeer::addSelectColumns($criteria); $startcol2 = UserRolePeer::NUM_HYDRATE_COLUMNS; UserPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + UserPeer::NUM_HYDRATE_COLUMNS; RolePeer::addSelectColumns($criteria); $startcol4 = $startcol3 + RolePeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(UserRolePeer::USER_ID, UserPeer::ID, $join_behavior); $criteria->addJoin(UserRolePeer::ROLE_ID, RolePeer::ID, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = UserRolePeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = UserRolePeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = UserRolePeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); UserRolePeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined User rows $key2 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = UserPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = UserPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); UserPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (UserRole) to the collection in $obj2 (User) $obj2->addUserRole($obj1); } // if joined row not null // Add objects for joined Role rows $key3 = RolePeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = RolePeer::getInstanceFromPool($key3); if (!$obj3) { $cls = RolePeer::getOMClass(); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); RolePeer::addInstanceToPool($obj3, $key3); } // if obj3 loaded // Add the $obj1 (UserRole) to the collection in $obj3 (Role) $obj3->addUserRole($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
php
public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(UserRolePeer::DATABASE_NAME); } UserRolePeer::addSelectColumns($criteria); $startcol2 = UserRolePeer::NUM_HYDRATE_COLUMNS; UserPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + UserPeer::NUM_HYDRATE_COLUMNS; RolePeer::addSelectColumns($criteria); $startcol4 = $startcol3 + RolePeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(UserRolePeer::USER_ID, UserPeer::ID, $join_behavior); $criteria->addJoin(UserRolePeer::ROLE_ID, RolePeer::ID, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = UserRolePeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = UserRolePeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = UserRolePeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); UserRolePeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined User rows $key2 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = UserPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = UserPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); UserPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (UserRole) to the collection in $obj2 (User) $obj2->addUserRole($obj1); } // if joined row not null // Add objects for joined Role rows $key3 = RolePeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = RolePeer::getInstanceFromPool($key3); if (!$obj3) { $cls = RolePeer::getOMClass(); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); RolePeer::addInstanceToPool($obj3, $key3); } // if obj3 loaded // Add the $obj1 (UserRole) to the collection in $obj3 (Role) $obj3->addUserRole($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
[ "public", "static", "function", "doSelectJoinAll", "(", "Criteria", "$", "criteria", ",", "$", "con", "=", "null", ",", "$", "join_behavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "criteria", "=", "clone", "$", "criteria", ";", "// Set the correct dbName if it has not been overridden", "if", "(", "$", "criteria", "->", "getDbName", "(", ")", "==", "Propel", "::", "getDefaultDB", "(", ")", ")", "{", "$", "criteria", "->", "setDbName", "(", "UserRolePeer", "::", "DATABASE_NAME", ")", ";", "}", "UserRolePeer", "::", "addSelectColumns", "(", "$", "criteria", ")", ";", "$", "startcol2", "=", "UserRolePeer", "::", "NUM_HYDRATE_COLUMNS", ";", "UserPeer", "::", "addSelectColumns", "(", "$", "criteria", ")", ";", "$", "startcol3", "=", "$", "startcol2", "+", "UserPeer", "::", "NUM_HYDRATE_COLUMNS", ";", "RolePeer", "::", "addSelectColumns", "(", "$", "criteria", ")", ";", "$", "startcol4", "=", "$", "startcol3", "+", "RolePeer", "::", "NUM_HYDRATE_COLUMNS", ";", "$", "criteria", "->", "addJoin", "(", "UserRolePeer", "::", "USER_ID", ",", "UserPeer", "::", "ID", ",", "$", "join_behavior", ")", ";", "$", "criteria", "->", "addJoin", "(", "UserRolePeer", "::", "ROLE_ID", ",", "RolePeer", "::", "ID", ",", "$", "join_behavior", ")", ";", "$", "stmt", "=", "BasePeer", "::", "doSelect", "(", "$", "criteria", ",", "$", "con", ")", ";", "$", "results", "=", "array", "(", ")", ";", "while", "(", "$", "row", "=", "$", "stmt", "->", "fetch", "(", "PDO", "::", "FETCH_NUM", ")", ")", "{", "$", "key1", "=", "UserRolePeer", "::", "getPrimaryKeyHashFromRow", "(", "$", "row", ",", "0", ")", ";", "if", "(", "null", "!==", "(", "$", "obj1", "=", "UserRolePeer", "::", "getInstanceFromPool", "(", "$", "key1", ")", ")", ")", "{", "// We no longer rehydrate the object, since this can cause data loss.", "// See http://www.propelorm.org/ticket/509", "// $obj1->hydrate($row, 0, true); // rehydrate", "}", "else", "{", "$", "cls", "=", "UserRolePeer", "::", "getOMClass", "(", ")", ";", "$", "obj1", "=", "new", "$", "cls", "(", ")", ";", "$", "obj1", "->", "hydrate", "(", "$", "row", ")", ";", "UserRolePeer", "::", "addInstanceToPool", "(", "$", "obj1", ",", "$", "key1", ")", ";", "}", "// if obj1 already loaded", "// Add objects for joined User rows", "$", "key2", "=", "UserPeer", "::", "getPrimaryKeyHashFromRow", "(", "$", "row", ",", "$", "startcol2", ")", ";", "if", "(", "$", "key2", "!==", "null", ")", "{", "$", "obj2", "=", "UserPeer", "::", "getInstanceFromPool", "(", "$", "key2", ")", ";", "if", "(", "!", "$", "obj2", ")", "{", "$", "cls", "=", "UserPeer", "::", "getOMClass", "(", ")", ";", "$", "obj2", "=", "new", "$", "cls", "(", ")", ";", "$", "obj2", "->", "hydrate", "(", "$", "row", ",", "$", "startcol2", ")", ";", "UserPeer", "::", "addInstanceToPool", "(", "$", "obj2", ",", "$", "key2", ")", ";", "}", "// if obj2 loaded", "// Add the $obj1 (UserRole) to the collection in $obj2 (User)", "$", "obj2", "->", "addUserRole", "(", "$", "obj1", ")", ";", "}", "// if joined row not null", "// Add objects for joined Role rows", "$", "key3", "=", "RolePeer", "::", "getPrimaryKeyHashFromRow", "(", "$", "row", ",", "$", "startcol3", ")", ";", "if", "(", "$", "key3", "!==", "null", ")", "{", "$", "obj3", "=", "RolePeer", "::", "getInstanceFromPool", "(", "$", "key3", ")", ";", "if", "(", "!", "$", "obj3", ")", "{", "$", "cls", "=", "RolePeer", "::", "getOMClass", "(", ")", ";", "$", "obj3", "=", "new", "$", "cls", "(", ")", ";", "$", "obj3", "->", "hydrate", "(", "$", "row", ",", "$", "startcol3", ")", ";", "RolePeer", "::", "addInstanceToPool", "(", "$", "obj3", ",", "$", "key3", ")", ";", "}", "// if obj3 loaded", "// Add the $obj1 (UserRole) to the collection in $obj3 (Role)", "$", "obj3", "->", "addUserRole", "(", "$", "obj1", ")", ";", "}", "// if joined row not null", "$", "results", "[", "]", "=", "$", "obj1", ";", "}", "$", "stmt", "->", "closeCursor", "(", ")", ";", "return", "$", "results", ";", "}" ]
Selects a collection of UserRole objects pre-filled with all related objects. @param Criteria $criteria @param PropelPDO $con @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN @return array Array of UserRole objects. @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Selects", "a", "collection", "of", "UserRole", "objects", "pre", "-", "filled", "with", "all", "related", "objects", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php#L765-L845
16,744
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php
BaseUserRolePeer.doUpdate
public static function doUpdate($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(UserRolePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $selectCriteria = new Criteria(UserRolePeer::DATABASE_NAME); if ($values instanceof Criteria) { $criteria = clone $values; // rename for clarity $comparison = $criteria->getComparison(UserRolePeer::USER_ID); $value = $criteria->remove(UserRolePeer::USER_ID); if ($value) { $selectCriteria->add(UserRolePeer::USER_ID, $value, $comparison); } else { $selectCriteria->setPrimaryTableName(UserRolePeer::TABLE_NAME); } $comparison = $criteria->getComparison(UserRolePeer::ROLE_ID); $value = $criteria->remove(UserRolePeer::ROLE_ID); if ($value) { $selectCriteria->add(UserRolePeer::ROLE_ID, $value, $comparison); } else { $selectCriteria->setPrimaryTableName(UserRolePeer::TABLE_NAME); } } else { // $values is UserRole object $criteria = $values->buildCriteria(); // gets full criteria $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) } // set the correct dbName $criteria->setDbName(UserRolePeer::DATABASE_NAME); return BasePeer::doUpdate($selectCriteria, $criteria, $con); }
php
public static function doUpdate($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(UserRolePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $selectCriteria = new Criteria(UserRolePeer::DATABASE_NAME); if ($values instanceof Criteria) { $criteria = clone $values; // rename for clarity $comparison = $criteria->getComparison(UserRolePeer::USER_ID); $value = $criteria->remove(UserRolePeer::USER_ID); if ($value) { $selectCriteria->add(UserRolePeer::USER_ID, $value, $comparison); } else { $selectCriteria->setPrimaryTableName(UserRolePeer::TABLE_NAME); } $comparison = $criteria->getComparison(UserRolePeer::ROLE_ID); $value = $criteria->remove(UserRolePeer::ROLE_ID); if ($value) { $selectCriteria->add(UserRolePeer::ROLE_ID, $value, $comparison); } else { $selectCriteria->setPrimaryTableName(UserRolePeer::TABLE_NAME); } } else { // $values is UserRole object $criteria = $values->buildCriteria(); // gets full criteria $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) } // set the correct dbName $criteria->setDbName(UserRolePeer::DATABASE_NAME); return BasePeer::doUpdate($selectCriteria, $criteria, $con); }
[ "public", "static", "function", "doUpdate", "(", "$", "values", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "if", "(", "$", "con", "===", "null", ")", "{", "$", "con", "=", "Propel", "::", "getConnection", "(", "UserRolePeer", "::", "DATABASE_NAME", ",", "Propel", "::", "CONNECTION_WRITE", ")", ";", "}", "$", "selectCriteria", "=", "new", "Criteria", "(", "UserRolePeer", "::", "DATABASE_NAME", ")", ";", "if", "(", "$", "values", "instanceof", "Criteria", ")", "{", "$", "criteria", "=", "clone", "$", "values", ";", "// rename for clarity", "$", "comparison", "=", "$", "criteria", "->", "getComparison", "(", "UserRolePeer", "::", "USER_ID", ")", ";", "$", "value", "=", "$", "criteria", "->", "remove", "(", "UserRolePeer", "::", "USER_ID", ")", ";", "if", "(", "$", "value", ")", "{", "$", "selectCriteria", "->", "add", "(", "UserRolePeer", "::", "USER_ID", ",", "$", "value", ",", "$", "comparison", ")", ";", "}", "else", "{", "$", "selectCriteria", "->", "setPrimaryTableName", "(", "UserRolePeer", "::", "TABLE_NAME", ")", ";", "}", "$", "comparison", "=", "$", "criteria", "->", "getComparison", "(", "UserRolePeer", "::", "ROLE_ID", ")", ";", "$", "value", "=", "$", "criteria", "->", "remove", "(", "UserRolePeer", "::", "ROLE_ID", ")", ";", "if", "(", "$", "value", ")", "{", "$", "selectCriteria", "->", "add", "(", "UserRolePeer", "::", "ROLE_ID", ",", "$", "value", ",", "$", "comparison", ")", ";", "}", "else", "{", "$", "selectCriteria", "->", "setPrimaryTableName", "(", "UserRolePeer", "::", "TABLE_NAME", ")", ";", "}", "}", "else", "{", "// $values is UserRole object", "$", "criteria", "=", "$", "values", "->", "buildCriteria", "(", ")", ";", "// gets full criteria", "$", "selectCriteria", "=", "$", "values", "->", "buildPkeyCriteria", "(", ")", ";", "// gets criteria w/ primary key(s)", "}", "// set the correct dbName", "$", "criteria", "->", "setDbName", "(", "UserRolePeer", "::", "DATABASE_NAME", ")", ";", "return", "BasePeer", "::", "doUpdate", "(", "$", "selectCriteria", ",", "$", "criteria", ",", "$", "con", ")", ";", "}" ]
Performs an UPDATE on the database, given a UserRole or Criteria object. @param mixed $values Criteria or UserRole object containing data that is used to create the UPDATE statement. @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). @return int The number of affected rows (if supported by underlying database driver). @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Performs", "an", "UPDATE", "on", "the", "database", "given", "a", "UserRole", "or", "Criteria", "object", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php#L1179-L1215
16,745
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php
BaseUserRolePeer.retrieveByPK
public static function retrieveByPK($user_id, $role_id, PropelPDO $con = null) { $_instancePoolKey = serialize(array((string) $user_id, (string) $role_id)); if (null !== ($obj = UserRolePeer::getInstanceFromPool($_instancePoolKey))) { return $obj; } if ($con === null) { $con = Propel::getConnection(UserRolePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria = new Criteria(UserRolePeer::DATABASE_NAME); $criteria->add(UserRolePeer::USER_ID, $user_id); $criteria->add(UserRolePeer::ROLE_ID, $role_id); $v = UserRolePeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }
php
public static function retrieveByPK($user_id, $role_id, PropelPDO $con = null) { $_instancePoolKey = serialize(array((string) $user_id, (string) $role_id)); if (null !== ($obj = UserRolePeer::getInstanceFromPool($_instancePoolKey))) { return $obj; } if ($con === null) { $con = Propel::getConnection(UserRolePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria = new Criteria(UserRolePeer::DATABASE_NAME); $criteria->add(UserRolePeer::USER_ID, $user_id); $criteria->add(UserRolePeer::ROLE_ID, $role_id); $v = UserRolePeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }
[ "public", "static", "function", "retrieveByPK", "(", "$", "user_id", ",", "$", "role_id", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "$", "_instancePoolKey", "=", "serialize", "(", "array", "(", "(", "string", ")", "$", "user_id", ",", "(", "string", ")", "$", "role_id", ")", ")", ";", "if", "(", "null", "!==", "(", "$", "obj", "=", "UserRolePeer", "::", "getInstanceFromPool", "(", "$", "_instancePoolKey", ")", ")", ")", "{", "return", "$", "obj", ";", "}", "if", "(", "$", "con", "===", "null", ")", "{", "$", "con", "=", "Propel", "::", "getConnection", "(", "UserRolePeer", "::", "DATABASE_NAME", ",", "Propel", "::", "CONNECTION_READ", ")", ";", "}", "$", "criteria", "=", "new", "Criteria", "(", "UserRolePeer", "::", "DATABASE_NAME", ")", ";", "$", "criteria", "->", "add", "(", "UserRolePeer", "::", "USER_ID", ",", "$", "user_id", ")", ";", "$", "criteria", "->", "add", "(", "UserRolePeer", "::", "ROLE_ID", ",", "$", "role_id", ")", ";", "$", "v", "=", "UserRolePeer", "::", "doSelect", "(", "$", "criteria", ",", "$", "con", ")", ";", "return", "!", "empty", "(", "$", "v", ")", "?", "$", "v", "[", "0", "]", ":", "null", ";", "}" ]
Retrieve object using using composite pkey values. @param int $user_id @param int $role_id @param PropelPDO $con @return UserRole
[ "Retrieve", "object", "using", "using", "composite", "pkey", "values", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php#L1360-L1375
16,746
xinix-technology/norm
src/Norm/Connection/SQLServerConnection.php
SqlServerConnection.ddl
public function ddl(Collection $collection) { if (!empty($this->options['autoddl'])) { $sql = $this->dialect->grammarDDL($collection, $this->options['autoddl']); $this->execute($sql); } }
php
public function ddl(Collection $collection) { if (!empty($this->options['autoddl'])) { $sql = $this->dialect->grammarDDL($collection, $this->options['autoddl']); $this->execute($sql); } }
[ "public", "function", "ddl", "(", "Collection", "$", "collection", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "options", "[", "'autoddl'", "]", ")", ")", "{", "$", "sql", "=", "$", "this", "->", "dialect", "->", "grammarDDL", "(", "$", "collection", ",", "$", "this", "->", "options", "[", "'autoddl'", "]", ")", ";", "$", "this", "->", "execute", "(", "$", "sql", ")", ";", "}", "}" ]
DDL runner for collection @param \Norm\Collection $collection @return void
[ "DDL", "runner", "for", "collection" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/SQLServerConnection.php#L181-L188
16,747
t3chnik/flysystem-cloudinary-adapter
src/CloudinaryAdapter.php
CloudinaryAdapter.write
public function write($path, $contents, Config $config) { // 1. Save to temporary local file -- it will be destroyed automatically $tempfile = tmpfile(); fwrite($tempfile, $contents); // 2. Use Cloudinary to send $uploaded_metadata = $this->writeStream($path, $tempfile, $config); return $uploaded_metadata; }
php
public function write($path, $contents, Config $config) { // 1. Save to temporary local file -- it will be destroyed automatically $tempfile = tmpfile(); fwrite($tempfile, $contents); // 2. Use Cloudinary to send $uploaded_metadata = $this->writeStream($path, $tempfile, $config); return $uploaded_metadata; }
[ "public", "function", "write", "(", "$", "path", ",", "$", "contents", ",", "Config", "$", "config", ")", "{", "// 1. Save to temporary local file -- it will be destroyed automatically", "$", "tempfile", "=", "tmpfile", "(", ")", ";", "fwrite", "(", "$", "tempfile", ",", "$", "contents", ")", ";", "// 2. Use Cloudinary to send", "$", "uploaded_metadata", "=", "$", "this", "->", "writeStream", "(", "$", "path", ",", "$", "tempfile", ",", "$", "config", ")", ";", "return", "$", "uploaded_metadata", ";", "}" ]
Write a new file. Create temporary stream with content. Pass to writeStream. @param string $path @param string $contents @param Config $config Config object @return array|false false on failure file meta data on success
[ "Write", "a", "new", "file", ".", "Create", "temporary", "stream", "with", "content", ".", "Pass", "to", "writeStream", "." ]
154109bfb2f43e681528f2d537afd5e078ede4c7
https://github.com/t3chnik/flysystem-cloudinary-adapter/blob/154109bfb2f43e681528f2d537afd5e078ede4c7/src/CloudinaryAdapter.php#L51-L62
16,748
t3chnik/flysystem-cloudinary-adapter
src/CloudinaryAdapter.php
CloudinaryAdapter.rename
public function rename($path, $newpath) { $pathinfo = pathinfo($path); if ($pathinfo['dirname'] != '.') { $path_remote = $pathinfo['dirname'] . '/' . $pathinfo['filename']; } else { $path_remote = $pathinfo['filename']; } $newpathinfo = pathinfo($newpath); if ($newpathinfo['dirname'] != '.') { $newpath_remote = $newpathinfo['dirname'] . '/' . $newpathinfo['filename']; } else { $newpath_remote = $newpathinfo['filename']; } $result = Uploader::rename($path_remote, $newpath_remote); return $result['public_id'] == $newpathinfo['filename']; }
php
public function rename($path, $newpath) { $pathinfo = pathinfo($path); if ($pathinfo['dirname'] != '.') { $path_remote = $pathinfo['dirname'] . '/' . $pathinfo['filename']; } else { $path_remote = $pathinfo['filename']; } $newpathinfo = pathinfo($newpath); if ($newpathinfo['dirname'] != '.') { $newpath_remote = $newpathinfo['dirname'] . '/' . $newpathinfo['filename']; } else { $newpath_remote = $newpathinfo['filename']; } $result = Uploader::rename($path_remote, $newpath_remote); return $result['public_id'] == $newpathinfo['filename']; }
[ "public", "function", "rename", "(", "$", "path", ",", "$", "newpath", ")", "{", "$", "pathinfo", "=", "pathinfo", "(", "$", "path", ")", ";", "if", "(", "$", "pathinfo", "[", "'dirname'", "]", "!=", "'.'", ")", "{", "$", "path_remote", "=", "$", "pathinfo", "[", "'dirname'", "]", ".", "'/'", ".", "$", "pathinfo", "[", "'filename'", "]", ";", "}", "else", "{", "$", "path_remote", "=", "$", "pathinfo", "[", "'filename'", "]", ";", "}", "$", "newpathinfo", "=", "pathinfo", "(", "$", "newpath", ")", ";", "if", "(", "$", "newpathinfo", "[", "'dirname'", "]", "!=", "'.'", ")", "{", "$", "newpath_remote", "=", "$", "newpathinfo", "[", "'dirname'", "]", ".", "'/'", ".", "$", "newpathinfo", "[", "'filename'", "]", ";", "}", "else", "{", "$", "newpath_remote", "=", "$", "newpathinfo", "[", "'filename'", "]", ";", "}", "$", "result", "=", "Uploader", "::", "rename", "(", "$", "path_remote", ",", "$", "newpath_remote", ")", ";", "return", "$", "result", "[", "'public_id'", "]", "==", "$", "newpathinfo", "[", "'filename'", "]", ";", "}" ]
Rename a file. Paths without extensions. @param string $path @param string $newpath @return bool
[ "Rename", "a", "file", ".", "Paths", "without", "extensions", "." ]
154109bfb2f43e681528f2d537afd5e078ede4c7
https://github.com/t3chnik/flysystem-cloudinary-adapter/blob/154109bfb2f43e681528f2d537afd5e078ede4c7/src/CloudinaryAdapter.php#L120-L139
16,749
t3chnik/flysystem-cloudinary-adapter
src/CloudinaryAdapter.php
CloudinaryAdapter.copy
public function copy($path, $newpath) { $url = cloudinary_url_internal($path); $result = Uploader::upload($url, ['public_id' => $newpath]); return is_array($result) ? $result['public_id'] == $newpath : false; }
php
public function copy($path, $newpath) { $url = cloudinary_url_internal($path); $result = Uploader::upload($url, ['public_id' => $newpath]); return is_array($result) ? $result['public_id'] == $newpath : false; }
[ "public", "function", "copy", "(", "$", "path", ",", "$", "newpath", ")", "{", "$", "url", "=", "cloudinary_url_internal", "(", "$", "path", ")", ";", "$", "result", "=", "Uploader", "::", "upload", "(", "$", "url", ",", "[", "'public_id'", "=>", "$", "newpath", "]", ")", ";", "return", "is_array", "(", "$", "result", ")", "?", "$", "result", "[", "'public_id'", "]", "==", "$", "newpath", ":", "false", ";", "}" ]
Copy a file. Copy content from existing url. @param string $path @param string $newpath @return bool
[ "Copy", "a", "file", ".", "Copy", "content", "from", "existing", "url", "." ]
154109bfb2f43e681528f2d537afd5e078ede4c7
https://github.com/t3chnik/flysystem-cloudinary-adapter/blob/154109bfb2f43e681528f2d537afd5e078ede4c7/src/CloudinaryAdapter.php#L150-L156
16,750
t3chnik/flysystem-cloudinary-adapter
src/CloudinaryAdapter.php
CloudinaryAdapter.has
public function has($path) { try { $this->api->resource($path); } catch (Exception $e) { return false; } return true; }
php
public function has($path) { try { $this->api->resource($path); } catch (Exception $e) { return false; } return true; }
[ "public", "function", "has", "(", "$", "path", ")", "{", "try", "{", "$", "this", "->", "api", "->", "resource", "(", "$", "path", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check whether a file exists. Using url to check response headers. Maybe I should use api resource? substr(get_headers(cloudinary_url_internal($path))[0], -6 ) == '200 OK'; need to test that for spead @param string $path @return array|bool|null
[ "Check", "whether", "a", "file", "exists", ".", "Using", "url", "to", "check", "response", "headers", ".", "Maybe", "I", "should", "use", "api", "resource?" ]
154109bfb2f43e681528f2d537afd5e078ede4c7
https://github.com/t3chnik/flysystem-cloudinary-adapter/blob/154109bfb2f43e681528f2d537afd5e078ede4c7/src/CloudinaryAdapter.php#L215-L224
16,751
t3chnik/flysystem-cloudinary-adapter
src/CloudinaryAdapter.php
CloudinaryAdapter.prepareResourceMetadata
protected function prepareResourceMetadata($resource) { $resource['type'] = 'file'; $resource['path'] = $resource['public_id']; $resource = array_merge($resource, $this->prepareSize($resource)); $resource = array_merge($resource, $this->prepareTimestamp($resource)); $resource = array_merge($resource, $this->prepareMimetype($resource)); return $resource; }
php
protected function prepareResourceMetadata($resource) { $resource['type'] = 'file'; $resource['path'] = $resource['public_id']; $resource = array_merge($resource, $this->prepareSize($resource)); $resource = array_merge($resource, $this->prepareTimestamp($resource)); $resource = array_merge($resource, $this->prepareMimetype($resource)); return $resource; }
[ "protected", "function", "prepareResourceMetadata", "(", "$", "resource", ")", "{", "$", "resource", "[", "'type'", "]", "=", "'file'", ";", "$", "resource", "[", "'path'", "]", "=", "$", "resource", "[", "'public_id'", "]", ";", "$", "resource", "=", "array_merge", "(", "$", "resource", ",", "$", "this", "->", "prepareSize", "(", "$", "resource", ")", ")", ";", "$", "resource", "=", "array_merge", "(", "$", "resource", ",", "$", "this", "->", "prepareTimestamp", "(", "$", "resource", ")", ")", ";", "$", "resource", "=", "array_merge", "(", "$", "resource", ",", "$", "this", "->", "prepareMimetype", "(", "$", "resource", ")", ")", ";", "return", "$", "resource", ";", "}" ]
Prepare apropriate metadata for resource metadata given from cloudinary. @param array $resource @return array
[ "Prepare", "apropriate", "metadata", "for", "resource", "metadata", "given", "from", "cloudinary", "." ]
154109bfb2f43e681528f2d537afd5e078ede4c7
https://github.com/t3chnik/flysystem-cloudinary-adapter/blob/154109bfb2f43e681528f2d537afd5e078ede4c7/src/CloudinaryAdapter.php#L348-L357
16,752
2amigos/yiifoundation
widgets/Section.php
Section.init
public function init() { $this->assets = array( 'js' => YII_DEBUG ? 'foundation/foundation.section.js' : 'foundation.min.js' ); Html::addCssClass($this->htmlOptions, Enum::SECTION_CONTAINER); Html::addCssClass($this->htmlOptions, $this->style); ArrayHelper::addValue('data-section', $this->style, $this->htmlOptions); $this->registerClientScript(); parent::init(); }
php
public function init() { $this->assets = array( 'js' => YII_DEBUG ? 'foundation/foundation.section.js' : 'foundation.min.js' ); Html::addCssClass($this->htmlOptions, Enum::SECTION_CONTAINER); Html::addCssClass($this->htmlOptions, $this->style); ArrayHelper::addValue('data-section', $this->style, $this->htmlOptions); $this->registerClientScript(); parent::init(); }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "assets", "=", "array", "(", "'js'", "=>", "YII_DEBUG", "?", "'foundation/foundation.section.js'", ":", "'foundation.min.js'", ")", ";", "Html", "::", "addCssClass", "(", "$", "this", "->", "htmlOptions", ",", "Enum", "::", "SECTION_CONTAINER", ")", ";", "Html", "::", "addCssClass", "(", "$", "this", "->", "htmlOptions", ",", "$", "this", "->", "style", ")", ";", "ArrayHelper", "::", "addValue", "(", "'data-section'", ",", "$", "this", "->", "style", ",", "$", "this", "->", "htmlOptions", ")", ";", "$", "this", "->", "registerClientScript", "(", ")", ";", "parent", "::", "init", "(", ")", ";", "}" ]
Initilizes the widget
[ "Initilizes", "the", "widget" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Section.php#L76-L87
16,753
2amigos/yiifoundation
widgets/Section.php
Section.renderSection
public function renderSection() { $sections = array(); foreach ($this->items as $item) { $sections[] = $this->renderItem($item); } return \CHtml::tag('div', $this->htmlOptions, implode("\n", $sections)); }
php
public function renderSection() { $sections = array(); foreach ($this->items as $item) { $sections[] = $this->renderItem($item); } return \CHtml::tag('div', $this->htmlOptions, implode("\n", $sections)); }
[ "public", "function", "renderSection", "(", ")", "{", "$", "sections", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "$", "sections", "[", "]", "=", "$", "this", "->", "renderItem", "(", "$", "item", ")", ";", "}", "return", "\\", "CHtml", "::", "tag", "(", "'div'", ",", "$", "this", "->", "htmlOptions", ",", "implode", "(", "\"\\n\"", ",", "$", "sections", ")", ")", ";", "}" ]
Renders the section @return string the rendering result
[ "Renders", "the", "section" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Section.php#L101-L108
16,754
2amigos/yiifoundation
widgets/Section.php
Section.renderItem
public function renderItem($item) { $sectionItem = array(); $sectionItem[] = \CHtml::tag( 'p', array('class' => 'title', 'data-section-title' => 'data-section-title'), \CHtml::link(ArrayHelper::getValue($item, 'label', 'Section Title'), '#') ); $options = ArrayHelper::getValue($item, 'options', array()); Html::addCssClass($options, 'content'); ArrayHelper::addValue('data-section-content', 'data-section-content', $options); $sectionOptions = array(); if (ArrayHelper::getValue($item, 'active')) { ArrayHelper::addValue('class', 'active', $sectionOptions); } $sectionItem[] = \CHtml::tag('div', $options, ArrayHelper::getValue($item, 'content', 'Section Content')); return \CHtml::tag('section', $sectionOptions, implode("\n", $sectionItem)); }
php
public function renderItem($item) { $sectionItem = array(); $sectionItem[] = \CHtml::tag( 'p', array('class' => 'title', 'data-section-title' => 'data-section-title'), \CHtml::link(ArrayHelper::getValue($item, 'label', 'Section Title'), '#') ); $options = ArrayHelper::getValue($item, 'options', array()); Html::addCssClass($options, 'content'); ArrayHelper::addValue('data-section-content', 'data-section-content', $options); $sectionOptions = array(); if (ArrayHelper::getValue($item, 'active')) { ArrayHelper::addValue('class', 'active', $sectionOptions); } $sectionItem[] = \CHtml::tag('div', $options, ArrayHelper::getValue($item, 'content', 'Section Content')); return \CHtml::tag('section', $sectionOptions, implode("\n", $sectionItem)); }
[ "public", "function", "renderItem", "(", "$", "item", ")", "{", "$", "sectionItem", "=", "array", "(", ")", ";", "$", "sectionItem", "[", "]", "=", "\\", "CHtml", "::", "tag", "(", "'p'", ",", "array", "(", "'class'", "=>", "'title'", ",", "'data-section-title'", "=>", "'data-section-title'", ")", ",", "\\", "CHtml", "::", "link", "(", "ArrayHelper", "::", "getValue", "(", "$", "item", ",", "'label'", ",", "'Section Title'", ")", ",", "'#'", ")", ")", ";", "$", "options", "=", "ArrayHelper", "::", "getValue", "(", "$", "item", ",", "'options'", ",", "array", "(", ")", ")", ";", "Html", "::", "addCssClass", "(", "$", "options", ",", "'content'", ")", ";", "ArrayHelper", "::", "addValue", "(", "'data-section-content'", ",", "'data-section-content'", ",", "$", "options", ")", ";", "$", "sectionOptions", "=", "array", "(", ")", ";", "if", "(", "ArrayHelper", "::", "getValue", "(", "$", "item", ",", "'active'", ")", ")", "{", "ArrayHelper", "::", "addValue", "(", "'class'", ",", "'active'", ",", "$", "sectionOptions", ")", ";", "}", "$", "sectionItem", "[", "]", "=", "\\", "CHtml", "::", "tag", "(", "'div'", ",", "$", "options", ",", "ArrayHelper", "::", "getValue", "(", "$", "item", ",", "'content'", ",", "'Section Content'", ")", ")", ";", "return", "\\", "CHtml", "::", "tag", "(", "'section'", ",", "$", "sectionOptions", ",", "implode", "(", "\"\\n\"", ",", "$", "sectionItem", ")", ")", ";", "}" ]
Renders a section item @param array $item the section item @return string the section result
[ "Renders", "a", "section", "item" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Section.php#L115-L132
16,755
mattsparks/the-stringler
src/Manipulator.php
Manipulator.camelToSnake
public function camelToSnake() : Manipulator { $modifiedString = ''; foreach (str_split($this->string, 1) as $character) { $modifiedString .= ctype_upper($character) ? '_' . $character : $character; } return new static(mb_strtolower($modifiedString)); }
php
public function camelToSnake() : Manipulator { $modifiedString = ''; foreach (str_split($this->string, 1) as $character) { $modifiedString .= ctype_upper($character) ? '_' . $character : $character; } return new static(mb_strtolower($modifiedString)); }
[ "public", "function", "camelToSnake", "(", ")", ":", "Manipulator", "{", "$", "modifiedString", "=", "''", ";", "foreach", "(", "str_split", "(", "$", "this", "->", "string", ",", "1", ")", "as", "$", "character", ")", "{", "$", "modifiedString", ".=", "ctype_upper", "(", "$", "character", ")", "?", "'_'", ".", "$", "character", ":", "$", "character", ";", "}", "return", "new", "static", "(", "mb_strtolower", "(", "$", "modifiedString", ")", ")", ";", "}" ]
Convert a camel-case string to snake-case. @return object|Manipulator
[ "Convert", "a", "camel", "-", "case", "string", "to", "snake", "-", "case", "." ]
bc11319ae4330b8ee1ed7333934ff180423b5218
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L49-L58
16,756
mattsparks/the-stringler
src/Manipulator.php
Manipulator.eachCharacter
public function eachCharacter(\Closure $closure) : Manipulator { $modifiedString = ''; foreach (str_split($this->string) as $character) { $modifiedString .= $closure($character); } return new static($modifiedString); }
php
public function eachCharacter(\Closure $closure) : Manipulator { $modifiedString = ''; foreach (str_split($this->string) as $character) { $modifiedString .= $closure($character); } return new static($modifiedString); }
[ "public", "function", "eachCharacter", "(", "\\", "Closure", "$", "closure", ")", ":", "Manipulator", "{", "$", "modifiedString", "=", "''", ";", "foreach", "(", "str_split", "(", "$", "this", "->", "string", ")", "as", "$", "character", ")", "{", "$", "modifiedString", ".=", "$", "closure", "(", "$", "character", ")", ";", "}", "return", "new", "static", "(", "$", "modifiedString", ")", ";", "}" ]
Perform an action on each character in the string. @param $closure @return object|Manipulator
[ "Perform", "an", "action", "on", "each", "character", "in", "the", "string", "." ]
bc11319ae4330b8ee1ed7333934ff180423b5218
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L106-L115
16,757
mattsparks/the-stringler
src/Manipulator.php
Manipulator.eachWord
public function eachWord(\Closure $closure, bool $preserveSpaces = false) : Manipulator { $modifiedString = ''; foreach (explode(' ', $this->string) as $word) { $modifiedString .= $closure($word); $modifiedString .= $preserveSpaces ? ' ' : ''; } return new static(trim($modifiedString)); }
php
public function eachWord(\Closure $closure, bool $preserveSpaces = false) : Manipulator { $modifiedString = ''; foreach (explode(' ', $this->string) as $word) { $modifiedString .= $closure($word); $modifiedString .= $preserveSpaces ? ' ' : ''; } return new static(trim($modifiedString)); }
[ "public", "function", "eachWord", "(", "\\", "Closure", "$", "closure", ",", "bool", "$", "preserveSpaces", "=", "false", ")", ":", "Manipulator", "{", "$", "modifiedString", "=", "''", ";", "foreach", "(", "explode", "(", "' '", ",", "$", "this", "->", "string", ")", "as", "$", "word", ")", "{", "$", "modifiedString", ".=", "$", "closure", "(", "$", "word", ")", ";", "$", "modifiedString", ".=", "$", "preserveSpaces", "?", "' '", ":", "''", ";", "}", "return", "new", "static", "(", "trim", "(", "$", "modifiedString", ")", ")", ";", "}" ]
Perform an action on each word in the string. @param $closure @param bool $preserveSpaces @return object|Manipulator
[ "Perform", "an", "action", "on", "each", "word", "in", "the", "string", "." ]
bc11319ae4330b8ee1ed7333934ff180423b5218
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L124-L134
16,758
mattsparks/the-stringler
src/Manipulator.php
Manipulator.getPossessive
public function getPossessive() : Manipulator { $modifiedString = $this->trimEnd(); if (mb_substr($modifiedString, -1) === 's') { $modifiedString .= '\''; } else { $modifiedString .= '\'s'; } return new static($modifiedString); }
php
public function getPossessive() : Manipulator { $modifiedString = $this->trimEnd(); if (mb_substr($modifiedString, -1) === 's') { $modifiedString .= '\''; } else { $modifiedString .= '\'s'; } return new static($modifiedString); }
[ "public", "function", "getPossessive", "(", ")", ":", "Manipulator", "{", "$", "modifiedString", "=", "$", "this", "->", "trimEnd", "(", ")", ";", "if", "(", "mb_substr", "(", "$", "modifiedString", ",", "-", "1", ")", "===", "'s'", ")", "{", "$", "modifiedString", ".=", "'\\''", ";", "}", "else", "{", "$", "modifiedString", ".=", "'\\'s'", ";", "}", "return", "new", "static", "(", "$", "modifiedString", ")", ";", "}" ]
Get Possessive Version of String @return object|Manipulator
[ "Get", "Possessive", "Version", "of", "String" ]
bc11319ae4330b8ee1ed7333934ff180423b5218
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L141-L152
16,759
mattsparks/the-stringler
src/Manipulator.php
Manipulator.htmlEntitiesDecode
public function htmlEntitiesDecode($flags = ENT_HTML5, string $encoding = 'UTF-8') : Manipulator { return new static(html_entity_decode($this->string, $flags, $encoding)); }
php
public function htmlEntitiesDecode($flags = ENT_HTML5, string $encoding = 'UTF-8') : Manipulator { return new static(html_entity_decode($this->string, $flags, $encoding)); }
[ "public", "function", "htmlEntitiesDecode", "(", "$", "flags", "=", "ENT_HTML5", ",", "string", "$", "encoding", "=", "'UTF-8'", ")", ":", "Manipulator", "{", "return", "new", "static", "(", "html_entity_decode", "(", "$", "this", "->", "string", ",", "$", "flags", ",", "$", "encoding", ")", ")", ";", "}" ]
Decode HTML Entities @param constant $flags @param string $encoding @return object|Manipulator
[ "Decode", "HTML", "Entities" ]
bc11319ae4330b8ee1ed7333934ff180423b5218
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L161-L164
16,760
mattsparks/the-stringler
src/Manipulator.php
Manipulator.htmlSpecialCharacters
public function htmlSpecialCharacters($flags = ENT_HTML5, string $encoding = 'UTF-8', bool $doubleEncode = true) : Manipulator { return new static(htmlspecialchars($this->string, $flags, $encoding, $doubleEncode)); }
php
public function htmlSpecialCharacters($flags = ENT_HTML5, string $encoding = 'UTF-8', bool $doubleEncode = true) : Manipulator { return new static(htmlspecialchars($this->string, $flags, $encoding, $doubleEncode)); }
[ "public", "function", "htmlSpecialCharacters", "(", "$", "flags", "=", "ENT_HTML5", ",", "string", "$", "encoding", "=", "'UTF-8'", ",", "bool", "$", "doubleEncode", "=", "true", ")", ":", "Manipulator", "{", "return", "new", "static", "(", "htmlspecialchars", "(", "$", "this", "->", "string", ",", "$", "flags", ",", "$", "encoding", ",", "$", "doubleEncode", ")", ")", ";", "}" ]
HTML Special Characters @param constant $flags @param string $encoding @param boolean $doubleEncode @return object|Manipulator
[ "HTML", "Special", "Characters" ]
bc11319ae4330b8ee1ed7333934ff180423b5218
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L187-L190
16,761
mattsparks/the-stringler
src/Manipulator.php
Manipulator.nthCharacter
public function nthCharacter(int $nth, \Closure $closure) : Manipulator { $count = 1; $modifiedString = ''; foreach (str_split($this->string) as $character) { $modifiedString .= $count === $nth ? $closure($character) : $character; $count++; } return new static($modifiedString); }
php
public function nthCharacter(int $nth, \Closure $closure) : Manipulator { $count = 1; $modifiedString = ''; foreach (str_split($this->string) as $character) { $modifiedString .= $count === $nth ? $closure($character) : $character; $count++; } return new static($modifiedString); }
[ "public", "function", "nthCharacter", "(", "int", "$", "nth", ",", "\\", "Closure", "$", "closure", ")", ":", "Manipulator", "{", "$", "count", "=", "1", ";", "$", "modifiedString", "=", "''", ";", "foreach", "(", "str_split", "(", "$", "this", "->", "string", ")", "as", "$", "character", ")", "{", "$", "modifiedString", ".=", "$", "count", "===", "$", "nth", "?", "$", "closure", "(", "$", "character", ")", ":", "$", "character", ";", "$", "count", "++", ";", "}", "return", "new", "static", "(", "$", "modifiedString", ")", ";", "}" ]
Perfrom an action on the nth character. @param int @param Closure @return object|Manipulator
[ "Perfrom", "an", "action", "on", "the", "nth", "character", "." ]
bc11319ae4330b8ee1ed7333934ff180423b5218
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L269-L280
16,762
mattsparks/the-stringler
src/Manipulator.php
Manipulator.nthWord
public function nthWord(int $nth, \Closure $closure, bool $preserveSpaces = true) : Manipulator { $count = 1; $modifiedString = ''; foreach (explode(' ', $this->string) as $word) { $modifiedString .= $count === $nth ? $closure($word) : $word; $modifiedString .= $preserveSpaces ? ' ' : ''; $count++; } return new static(trim($modifiedString)); }
php
public function nthWord(int $nth, \Closure $closure, bool $preserveSpaces = true) : Manipulator { $count = 1; $modifiedString = ''; foreach (explode(' ', $this->string) as $word) { $modifiedString .= $count === $nth ? $closure($word) : $word; $modifiedString .= $preserveSpaces ? ' ' : ''; $count++; } return new static(trim($modifiedString)); }
[ "public", "function", "nthWord", "(", "int", "$", "nth", ",", "\\", "Closure", "$", "closure", ",", "bool", "$", "preserveSpaces", "=", "true", ")", ":", "Manipulator", "{", "$", "count", "=", "1", ";", "$", "modifiedString", "=", "''", ";", "foreach", "(", "explode", "(", "' '", ",", "$", "this", "->", "string", ")", "as", "$", "word", ")", "{", "$", "modifiedString", ".=", "$", "count", "===", "$", "nth", "?", "$", "closure", "(", "$", "word", ")", ":", "$", "word", ";", "$", "modifiedString", ".=", "$", "preserveSpaces", "?", "' '", ":", "''", ";", "$", "count", "++", ";", "}", "return", "new", "static", "(", "trim", "(", "$", "modifiedString", ")", ")", ";", "}" ]
Perform an action on the nth word. @param int @param Closure @param boolean @return object|Manipulator
[ "Perform", "an", "action", "on", "the", "nth", "word", "." ]
bc11319ae4330b8ee1ed7333934ff180423b5218
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L290-L302
16,763
mattsparks/the-stringler
src/Manipulator.php
Manipulator.remove
public function remove(string $string, bool $caseSensitive = true) : Manipulator { return new static($this->replace($string, '', $caseSensitive)->toString()); }
php
public function remove(string $string, bool $caseSensitive = true) : Manipulator { return new static($this->replace($string, '', $caseSensitive)->toString()); }
[ "public", "function", "remove", "(", "string", "$", "string", ",", "bool", "$", "caseSensitive", "=", "true", ")", ":", "Manipulator", "{", "return", "new", "static", "(", "$", "this", "->", "replace", "(", "$", "string", ",", "''", ",", "$", "caseSensitive", ")", "->", "toString", "(", ")", ")", ";", "}" ]
Remove from string. @param string @param boolean @return object|Manipulator
[ "Remove", "from", "string", "." ]
bc11319ae4330b8ee1ed7333934ff180423b5218
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L311-L314
16,764
mattsparks/the-stringler
src/Manipulator.php
Manipulator.removeSpecialCharacters
public function removeSpecialCharacters(array $exceptions = []) : Manipulator { $regEx = "/"; $regEx .= "[^\w\d"; foreach ($exceptions as $exception) { $regEx .= "\\" . $exception; } $regEx .= "]/"; $modifiedString = preg_replace($regEx, '', $this->string); return new static($modifiedString); }
php
public function removeSpecialCharacters(array $exceptions = []) : Manipulator { $regEx = "/"; $regEx .= "[^\w\d"; foreach ($exceptions as $exception) { $regEx .= "\\" . $exception; } $regEx .= "]/"; $modifiedString = preg_replace($regEx, '', $this->string); return new static($modifiedString); }
[ "public", "function", "removeSpecialCharacters", "(", "array", "$", "exceptions", "=", "[", "]", ")", ":", "Manipulator", "{", "$", "regEx", "=", "\"/\"", ";", "$", "regEx", ".=", "\"[^\\w\\d\"", ";", "foreach", "(", "$", "exceptions", "as", "$", "exception", ")", "{", "$", "regEx", ".=", "\"\\\\\"", ".", "$", "exception", ";", "}", "$", "regEx", ".=", "\"]/\"", ";", "$", "modifiedString", "=", "preg_replace", "(", "$", "regEx", ",", "''", ",", "$", "this", "->", "string", ")", ";", "return", "new", "static", "(", "$", "modifiedString", ")", ";", "}" ]
Remove non-alphanumeric characters. @param array @return object|Manipulator
[ "Remove", "non", "-", "alphanumeric", "characters", "." ]
bc11319ae4330b8ee1ed7333934ff180423b5218
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L322-L336
16,765
mattsparks/the-stringler
src/Manipulator.php
Manipulator.snakeToCamel
public function snakeToCamel() : Manipulator { $modifiedString = $this->replace('_', ' ') ->capitalizeEach() ->lowercaseFirst() ->remove(' ') ->toString(); return new static($modifiedString); }
php
public function snakeToCamel() : Manipulator { $modifiedString = $this->replace('_', ' ') ->capitalizeEach() ->lowercaseFirst() ->remove(' ') ->toString(); return new static($modifiedString); }
[ "public", "function", "snakeToCamel", "(", ")", ":", "Manipulator", "{", "$", "modifiedString", "=", "$", "this", "->", "replace", "(", "'_'", ",", "' '", ")", "->", "capitalizeEach", "(", ")", "->", "lowercaseFirst", "(", ")", "->", "remove", "(", "' '", ")", "->", "toString", "(", ")", ";", "return", "new", "static", "(", "$", "modifiedString", ")", ";", "}" ]
Convert snake-case to camel-case. @return object|Manipulator
[ "Convert", "snake", "-", "case", "to", "camel", "-", "case", "." ]
bc11319ae4330b8ee1ed7333934ff180423b5218
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L380-L389
16,766
mattsparks/the-stringler
src/Manipulator.php
Manipulator.toCamelCase
public function toCamelCase() : Manipulator { $modifiedString = ''; foreach (explode(' ', $this->string) as $word) { $modifiedString .= self::make($word)->toLower()->capitalize()->toString(); } $final = self::make($modifiedString) ->replace(' ', '') ->lowercaseFirst() ->toString(); return new static($final); }
php
public function toCamelCase() : Manipulator { $modifiedString = ''; foreach (explode(' ', $this->string) as $word) { $modifiedString .= self::make($word)->toLower()->capitalize()->toString(); } $final = self::make($modifiedString) ->replace(' ', '') ->lowercaseFirst() ->toString(); return new static($final); }
[ "public", "function", "toCamelCase", "(", ")", ":", "Manipulator", "{", "$", "modifiedString", "=", "''", ";", "foreach", "(", "explode", "(", "' '", ",", "$", "this", "->", "string", ")", "as", "$", "word", ")", "{", "$", "modifiedString", ".=", "self", "::", "make", "(", "$", "word", ")", "->", "toLower", "(", ")", "->", "capitalize", "(", ")", "->", "toString", "(", ")", ";", "}", "$", "final", "=", "self", "::", "make", "(", "$", "modifiedString", ")", "->", "replace", "(", "' '", ",", "''", ")", "->", "lowercaseFirst", "(", ")", "->", "toString", "(", ")", ";", "return", "new", "static", "(", "$", "final", ")", ";", "}" ]
Convert a string to camel-case. @return object|Manipulator
[ "Convert", "a", "string", "to", "camel", "-", "case", "." ]
bc11319ae4330b8ee1ed7333934ff180423b5218
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L423-L437
16,767
yuncms/framework
src/broadcast/BaseMessage.php
BaseMessage.send
public function send(BroadcastInterface $broadcast = null) { if ($broadcast === null && $this->broadcast === null) { $broadcast = Yii::$app->getBroadcast(); } elseif ($broadcast === null) { $broadcast = $this->broadcast; } return $broadcast->send($this); }
php
public function send(BroadcastInterface $broadcast = null) { if ($broadcast === null && $this->broadcast === null) { $broadcast = Yii::$app->getBroadcast(); } elseif ($broadcast === null) { $broadcast = $this->broadcast; } return $broadcast->send($this); }
[ "public", "function", "send", "(", "BroadcastInterface", "$", "broadcast", "=", "null", ")", "{", "if", "(", "$", "broadcast", "===", "null", "&&", "$", "this", "->", "broadcast", "===", "null", ")", "{", "$", "broadcast", "=", "Yii", "::", "$", "app", "->", "getBroadcast", "(", ")", ";", "}", "elseif", "(", "$", "broadcast", "===", "null", ")", "{", "$", "broadcast", "=", "$", "this", "->", "broadcast", ";", "}", "return", "$", "broadcast", "->", "send", "(", "$", "this", ")", ";", "}" ]
Sends this broadcast message. @param BroadcastInterface $broadcast the broadcast that should be used to send this message. If no broadcast is given it will first check if [[broadcast]] is set and if not, the "broadcast" application component will be used instead. @return bool whether this message is sent successfully.
[ "Sends", "this", "broadcast", "message", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/broadcast/BaseMessage.php#L111-L120
16,768
webforge-labs/psc-cms
lib/Psc/Doctrine/Module.php
Module.registerEntityClassesMetadataDriver
public function registerEntityClassesMetadataDriver(Array $classes = array(), $namespace = 'Psc', \Doctrine\Common\Annotations\Reader $reader = NULL) { if (!isset($this->entityClassesMetadataDriver)) { if (!isset($reader)) { $reader = $this->createAnnotationReader(); } $this->entityClassesMetadataDriver = new \Psc\Doctrine\MetadataDriver($reader, NULL, $classes); $this->registerMetadataDriver($this->entityClassesMetadataDriver, $namespace); } return $this; }
php
public function registerEntityClassesMetadataDriver(Array $classes = array(), $namespace = 'Psc', \Doctrine\Common\Annotations\Reader $reader = NULL) { if (!isset($this->entityClassesMetadataDriver)) { if (!isset($reader)) { $reader = $this->createAnnotationReader(); } $this->entityClassesMetadataDriver = new \Psc\Doctrine\MetadataDriver($reader, NULL, $classes); $this->registerMetadataDriver($this->entityClassesMetadataDriver, $namespace); } return $this; }
[ "public", "function", "registerEntityClassesMetadataDriver", "(", "Array", "$", "classes", "=", "array", "(", ")", ",", "$", "namespace", "=", "'Psc'", ",", "\\", "Doctrine", "\\", "Common", "\\", "Annotations", "\\", "Reader", "$", "reader", "=", "NULL", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "entityClassesMetadataDriver", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "reader", ")", ")", "{", "$", "reader", "=", "$", "this", "->", "createAnnotationReader", "(", ")", ";", "}", "$", "this", "->", "entityClassesMetadataDriver", "=", "new", "\\", "Psc", "\\", "Doctrine", "\\", "MetadataDriver", "(", "$", "reader", ",", "NULL", ",", "$", "classes", ")", ";", "$", "this", "->", "registerMetadataDriver", "(", "$", "this", "->", "entityClassesMetadataDriver", ",", "$", "namespace", ")", ";", "}", "return", "$", "this", ";", "}" ]
Erstellt den EntityClassesMetadataDriver mehrmals aufrufen ist nicht tragisch, jedoch wird dann natürlihc $classes und $namspace sowie $reader keinen effect haben @see getEntityClassesMetadataDriver @chainable
[ "Erstellt", "den", "EntityClassesMetadataDriver" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/Module.php#L406-L416
16,769
webforge-labs/psc-cms
lib/Psc/Doctrine/Module.php
Module.useCache
public function useCache($type = self::CACHE_APC) { if ($type === self::CACHE_APC) { $this->setCache(new \Doctrine\Common\Cache\ApcCache); } else { $this->setCache(new \Doctrine\Common\Cache\ArrayCache); } }
php
public function useCache($type = self::CACHE_APC) { if ($type === self::CACHE_APC) { $this->setCache(new \Doctrine\Common\Cache\ApcCache); } else { $this->setCache(new \Doctrine\Common\Cache\ArrayCache); } }
[ "public", "function", "useCache", "(", "$", "type", "=", "self", "::", "CACHE_APC", ")", "{", "if", "(", "$", "type", "===", "self", "::", "CACHE_APC", ")", "{", "$", "this", "->", "setCache", "(", "new", "\\", "Doctrine", "\\", "Common", "\\", "Cache", "\\", "ApcCache", ")", ";", "}", "else", "{", "$", "this", "->", "setCache", "(", "new", "\\", "Doctrine", "\\", "Common", "\\", "Cache", "\\", "ArrayCache", ")", ";", "}", "}" ]
Overwrites the current cache
[ "Overwrites", "the", "current", "cache" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/Module.php#L512-L518
16,770
fkooman/php-cert-parser
src/fkooman/X509/CertParser.php
CertParser.fromEncodedDer
public static function fromEncodedDer($encodedDerCert) { $pemCert = sprintf( '-----BEGIN CERTIFICATE-----%s-----END CERTIFICATE-----', PHP_EOL.wordwrap($encodedDerCert, 64, "\n", true).PHP_EOL ); return new self($pemCert); }
php
public static function fromEncodedDer($encodedDerCert) { $pemCert = sprintf( '-----BEGIN CERTIFICATE-----%s-----END CERTIFICATE-----', PHP_EOL.wordwrap($encodedDerCert, 64, "\n", true).PHP_EOL ); return new self($pemCert); }
[ "public", "static", "function", "fromEncodedDer", "(", "$", "encodedDerCert", ")", "{", "$", "pemCert", "=", "sprintf", "(", "'-----BEGIN CERTIFICATE-----%s-----END CERTIFICATE-----'", ",", "PHP_EOL", ".", "wordwrap", "(", "$", "encodedDerCert", ",", "64", ",", "\"\\n\"", ",", "true", ")", ".", "PHP_EOL", ")", ";", "return", "new", "self", "(", "$", "pemCert", ")", ";", "}" ]
Create a new CertParser object from the Base 64 encoded DER, i.e. a base64_encode of a binary string.
[ "Create", "a", "new", "CertParser", "object", "from", "the", "Base", "64", "encoded", "DER", "i", ".", "e", ".", "a", "base64_encode", "of", "a", "binary", "string", "." ]
29bf69b49ee06011fb1c4f4c40cdd16a7f63e8bc
https://github.com/fkooman/php-cert-parser/blob/29bf69b49ee06011fb1c4f4c40cdd16a7f63e8bc/src/fkooman/X509/CertParser.php#L41-L49
16,771
fkooman/php-cert-parser
src/fkooman/X509/CertParser.php
CertParser.toDer
private function toDer() { $pattern = '/.*-----BEGIN CERTIFICATE-----(.*)-----END CERTIFICATE-----.*/msU'; $replacement = '${1}'; $plainPemData = preg_replace($pattern, $replacement, $this->pemCert); if (null === $plainPemData) { throw new RuntimeException('unable to extract the encoded DER data from the certificate'); } // create one long string of the certificate which turns it into an // encoded DER cert $search = array(' ', "\t", "\n", "\r", "\0" , "\x0B"); $encodedDerCert = str_replace($search, '', $plainPemData); return base64_decode($encodedDerCert); }
php
private function toDer() { $pattern = '/.*-----BEGIN CERTIFICATE-----(.*)-----END CERTIFICATE-----.*/msU'; $replacement = '${1}'; $plainPemData = preg_replace($pattern, $replacement, $this->pemCert); if (null === $plainPemData) { throw new RuntimeException('unable to extract the encoded DER data from the certificate'); } // create one long string of the certificate which turns it into an // encoded DER cert $search = array(' ', "\t", "\n", "\r", "\0" , "\x0B"); $encodedDerCert = str_replace($search, '', $plainPemData); return base64_decode($encodedDerCert); }
[ "private", "function", "toDer", "(", ")", "{", "$", "pattern", "=", "'/.*-----BEGIN CERTIFICATE-----(.*)-----END CERTIFICATE-----.*/msU'", ";", "$", "replacement", "=", "'${1}'", ";", "$", "plainPemData", "=", "preg_replace", "(", "$", "pattern", ",", "$", "replacement", ",", "$", "this", "->", "pemCert", ")", ";", "if", "(", "null", "===", "$", "plainPemData", ")", "{", "throw", "new", "RuntimeException", "(", "'unable to extract the encoded DER data from the certificate'", ")", ";", "}", "// create one long string of the certificate which turns it into an", "// encoded DER cert", "$", "search", "=", "array", "(", "' '", ",", "\"\\t\"", ",", "\"\\n\"", ",", "\"\\r\"", ",", "\"\\0\"", ",", "\"\\x0B\"", ")", ";", "$", "encodedDerCert", "=", "str_replace", "(", "$", "search", ",", "''", ",", "$", "plainPemData", ")", ";", "return", "base64_decode", "(", "$", "encodedDerCert", ")", ";", "}" ]
Get the DER format of the certificate.
[ "Get", "the", "DER", "format", "of", "the", "certificate", "." ]
29bf69b49ee06011fb1c4f4c40cdd16a7f63e8bc
https://github.com/fkooman/php-cert-parser/blob/29bf69b49ee06011fb1c4f4c40cdd16a7f63e8bc/src/fkooman/X509/CertParser.php#L105-L121
16,772
fkooman/php-cert-parser
src/fkooman/X509/CertParser.php
CertParser.getFingerprint
public function getFingerprint($alg = 'sha256') { if (!in_array($alg, hash_algos())) { throw new RuntimeException( sprintf( 'unsupported algorithm "%s"', $alg ) ); } return hash($alg, $this->toDer(), true); }
php
public function getFingerprint($alg = 'sha256') { if (!in_array($alg, hash_algos())) { throw new RuntimeException( sprintf( 'unsupported algorithm "%s"', $alg ) ); } return hash($alg, $this->toDer(), true); }
[ "public", "function", "getFingerprint", "(", "$", "alg", "=", "'sha256'", ")", "{", "if", "(", "!", "in_array", "(", "$", "alg", ",", "hash_algos", "(", ")", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'unsupported algorithm \"%s\"'", ",", "$", "alg", ")", ")", ";", "}", "return", "hash", "(", "$", "alg", ",", "$", "this", "->", "toDer", "(", ")", ",", "true", ")", ";", "}" ]
Get the raw fingerprint of the certificate. @param string $alg the algorithm to use @return string the raw fingerprint of the certificate as binary string @see http://php.net/manual/en/function.hash-algos.php
[ "Get", "the", "raw", "fingerprint", "of", "the", "certificate", "." ]
29bf69b49ee06011fb1c4f4c40cdd16a7f63e8bc
https://github.com/fkooman/php-cert-parser/blob/29bf69b49ee06011fb1c4f4c40cdd16a7f63e8bc/src/fkooman/X509/CertParser.php#L132-L144
16,773
arsengoian/viper-framework
src/Viper/Daemon/Router.php
Router.restart
public function restart(int $sleep) : void { $this -> storage['sentenced'] = 'rewind'; $this -> storage['sleep'] = $sleep; $this -> store($this -> storage); }
php
public function restart(int $sleep) : void { $this -> storage['sentenced'] = 'rewind'; $this -> storage['sleep'] = $sleep; $this -> store($this -> storage); }
[ "public", "function", "restart", "(", "int", "$", "sleep", ")", ":", "void", "{", "$", "this", "->", "storage", "[", "'sentenced'", "]", "=", "'rewind'", ";", "$", "this", "->", "storage", "[", "'sleep'", "]", "=", "$", "sleep", ";", "$", "this", "->", "store", "(", "$", "this", "->", "storage", ")", ";", "}" ]
Gently stops daemon and starts it with new frequency @param int $sleep
[ "Gently", "stops", "daemon", "and", "starts", "it", "with", "new", "frequency" ]
22796c5cc219cae3ca0b4af370a347ba2acab0f2
https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Daemon/Router.php#L76-L81
16,774
arsengoian/viper-framework
src/Viper/Daemon/Router.php
Router.exec
public function exec() : void { $this -> actionLog('Script successfully entered'); $sentence = $this -> storage['sentenced']; $response = NULL; if (method_exists($this, $sentence)) $response = $this -> $sentence(); else $this -> errorLog('Unknown method '.$sentence); if ($response) $this -> actionLog('Received data: '.$response); $this -> setMemory(memory_get_usage(TRUE)); $this -> actionLog('Script successfully completed, action: '.$sentence); }
php
public function exec() : void { $this -> actionLog('Script successfully entered'); $sentence = $this -> storage['sentenced']; $response = NULL; if (method_exists($this, $sentence)) $response = $this -> $sentence(); else $this -> errorLog('Unknown method '.$sentence); if ($response) $this -> actionLog('Received data: '.$response); $this -> setMemory(memory_get_usage(TRUE)); $this -> actionLog('Script successfully completed, action: '.$sentence); }
[ "public", "function", "exec", "(", ")", ":", "void", "{", "$", "this", "->", "actionLog", "(", "'Script successfully entered'", ")", ";", "$", "sentence", "=", "$", "this", "->", "storage", "[", "'sentenced'", "]", ";", "$", "response", "=", "NULL", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "sentence", ")", ")", "$", "response", "=", "$", "this", "->", "$", "sentence", "(", ")", ";", "else", "$", "this", "->", "errorLog", "(", "'Unknown method '", ".", "$", "sentence", ")", ";", "if", "(", "$", "response", ")", "$", "this", "->", "actionLog", "(", "'Received data: '", ".", "$", "response", ")", ";", "$", "this", "->", "setMemory", "(", "memory_get_usage", "(", "TRUE", ")", ")", ";", "$", "this", "->", "actionLog", "(", "'Script successfully completed, action: '", ".", "$", "sentence", ")", ";", "}" ]
Makes preparations for run method Also stores memory used by daemon to be recovered
[ "Makes", "preparations", "for", "run", "method", "Also", "stores", "memory", "used", "by", "daemon", "to", "be", "recovered" ]
22796c5cc219cae3ca0b4af370a347ba2acab0f2
https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Daemon/Router.php#L95-L110
16,775
arsengoian/viper-framework
src/Viper/Daemon/Router.php
Router.route
public static function route(string $command, array $args) : void { $object = new static('test'); echo "\n"; if (method_exists(static::class, $command)) { $response = call_user_func_array([$object, $command], $args); if ($response === NULL) echo "SUCCESS"; else if ($response === FALSE) echo "FALSE"; else if ($response === TRUE) echo "TRUE"; else { if (is_string($response)) echo $response; else print_r($response); } } else echo "No such method available"; echo "\n\n"; }
php
public static function route(string $command, array $args) : void { $object = new static('test'); echo "\n"; if (method_exists(static::class, $command)) { $response = call_user_func_array([$object, $command], $args); if ($response === NULL) echo "SUCCESS"; else if ($response === FALSE) echo "FALSE"; else if ($response === TRUE) echo "TRUE"; else { if (is_string($response)) echo $response; else print_r($response); } } else echo "No such method available"; echo "\n\n"; }
[ "public", "static", "function", "route", "(", "string", "$", "command", ",", "array", "$", "args", ")", ":", "void", "{", "$", "object", "=", "new", "static", "(", "'test'", ")", ";", "echo", "\"\\n\"", ";", "if", "(", "method_exists", "(", "static", "::", "class", ",", "$", "command", ")", ")", "{", "$", "response", "=", "call_user_func_array", "(", "[", "$", "object", ",", "$", "command", "]", ",", "$", "args", ")", ";", "if", "(", "$", "response", "===", "NULL", ")", "echo", "\"SUCCESS\"", ";", "else", "if", "(", "$", "response", "===", "FALSE", ")", "echo", "\"FALSE\"", ";", "else", "if", "(", "$", "response", "===", "TRUE", ")", "echo", "\"TRUE\"", ";", "else", "{", "if", "(", "is_string", "(", "$", "response", ")", ")", "echo", "$", "response", ";", "else", "print_r", "(", "$", "response", ")", ";", "}", "}", "else", "echo", "\"No such method available\"", ";", "echo", "\"\\n\\n\"", ";", "}" ]
Start a command to services @param string $command @param array $args
[ "Start", "a", "command", "to", "services" ]
22796c5cc219cae3ca0b4af370a347ba2acab0f2
https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Daemon/Router.php#L191-L209
16,776
ClanCats/Core
src/bundles/Database/Handler.php
Handler._init
public static function _init() { if ( \ClanCats::in_development() ) { // add a hook to the main resposne \CCEvent::mind( 'response.output', function( $output ) { if ( strpos( $output, '</body>' ) === false ) { return $output; } $table = \UI\Table::create( array( 'style' => array( 'width' => '100%', ), 'cellpadding' => '5', 'class' => 'table debug-table debug-table-db', )); $table->header( array( '#', 'query' ) ); foreach( static::log() as $key => $item ) { $table->row( array( $key+1, $item )); } return str_replace( '</body>', $table."\n</body>", $output ); }); } }
php
public static function _init() { if ( \ClanCats::in_development() ) { // add a hook to the main resposne \CCEvent::mind( 'response.output', function( $output ) { if ( strpos( $output, '</body>' ) === false ) { return $output; } $table = \UI\Table::create( array( 'style' => array( 'width' => '100%', ), 'cellpadding' => '5', 'class' => 'table debug-table debug-table-db', )); $table->header( array( '#', 'query' ) ); foreach( static::log() as $key => $item ) { $table->row( array( $key+1, $item )); } return str_replace( '</body>', $table."\n</body>", $output ); }); } }
[ "public", "static", "function", "_init", "(", ")", "{", "if", "(", "\\", "ClanCats", "::", "in_development", "(", ")", ")", "{", "// add a hook to the main resposne", "\\", "CCEvent", "::", "mind", "(", "'response.output'", ",", "function", "(", "$", "output", ")", "{", "if", "(", "strpos", "(", "$", "output", ",", "'</body>'", ")", "===", "false", ")", "{", "return", "$", "output", ";", "}", "$", "table", "=", "\\", "UI", "\\", "Table", "::", "create", "(", "array", "(", "'style'", "=>", "array", "(", "'width'", "=>", "'100%'", ",", ")", ",", "'cellpadding'", "=>", "'5'", ",", "'class'", "=>", "'table debug-table debug-table-db'", ",", ")", ")", ";", "$", "table", "->", "header", "(", "array", "(", "'#'", ",", "'query'", ")", ")", ";", "foreach", "(", "static", "::", "log", "(", ")", "as", "$", "key", "=>", "$", "item", ")", "{", "$", "table", "->", "row", "(", "array", "(", "$", "key", "+", "1", ",", "$", "item", ")", ")", ";", "}", "return", "str_replace", "(", "'</body>'", ",", "$", "table", ".", "\"\\n</body>\"", ",", "$", "output", ")", ";", "}", ")", ";", "}", "}" ]
Static init When we are in development then we append the qurey log to body @codeCoverageIgnore @return void
[ "Static", "init", "When", "we", "are", "in", "development", "then", "we", "append", "the", "qurey", "log", "to", "body" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Handler.php#L43-L76
16,777
ClanCats/Core
src/bundles/Database/Handler.php
Handler.connect
protected function connect( $name ) { if ( $this->_connected ) { return true; } // check if the name is an array. This way we can // pass the configuration directly. We need this // to create for example an handler without having // the configuration in the database conf file. if ( is_array( $name ) ) { $config = $name; } else { $config = \CCConfig::create( 'database' )->get( $name ); // check for an alias. If you set a string // in your config file we use the config // with the passed key. if ( is_string( $config ) ) { $config = \CCConfig::create( 'database' )->get( $config ); } } // Setup the driver class. We simply use name // from the confif file and make the first letter // capital. example: Handler_Mysql, Handler_Sqlite etc. $driver_class = __NAMESPACE__."\\Handler_".ucfirst( $config['driver'] ); if ( !class_exists( $driver_class ) ) { throw new Exception( "DB\\Handler::connect - The driver (".$driver_class.") is invalid." ); } $this->set_driver( $driver_class ); // setup the builder the same way as the handler. $driver_class = __NAMESPACE__."\\Builder_".ucfirst( $config['driver'] ); if ( !class_exists( $driver_class ) ) { throw new Exception( "DB\\Handler::connect - The builder (".$driver_class.") is invalid." ); } $this->set_builder( $driver_class ); // finally try to connect the driver with the databse if ( $this->driver()->connect( $config ) ) { return $this->_connected = true; } return $this->_connected = false; }
php
protected function connect( $name ) { if ( $this->_connected ) { return true; } // check if the name is an array. This way we can // pass the configuration directly. We need this // to create for example an handler without having // the configuration in the database conf file. if ( is_array( $name ) ) { $config = $name; } else { $config = \CCConfig::create( 'database' )->get( $name ); // check for an alias. If you set a string // in your config file we use the config // with the passed key. if ( is_string( $config ) ) { $config = \CCConfig::create( 'database' )->get( $config ); } } // Setup the driver class. We simply use name // from the confif file and make the first letter // capital. example: Handler_Mysql, Handler_Sqlite etc. $driver_class = __NAMESPACE__."\\Handler_".ucfirst( $config['driver'] ); if ( !class_exists( $driver_class ) ) { throw new Exception( "DB\\Handler::connect - The driver (".$driver_class.") is invalid." ); } $this->set_driver( $driver_class ); // setup the builder the same way as the handler. $driver_class = __NAMESPACE__."\\Builder_".ucfirst( $config['driver'] ); if ( !class_exists( $driver_class ) ) { throw new Exception( "DB\\Handler::connect - The builder (".$driver_class.") is invalid." ); } $this->set_builder( $driver_class ); // finally try to connect the driver with the databse if ( $this->driver()->connect( $config ) ) { return $this->_connected = true; } return $this->_connected = false; }
[ "protected", "function", "connect", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "_connected", ")", "{", "return", "true", ";", "}", "// check if the name is an array. This way we can", "// pass the configuration directly. We need this ", "// to create for example an handler without having", "// the configuration in the database conf file.", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "$", "config", "=", "$", "name", ";", "}", "else", "{", "$", "config", "=", "\\", "CCConfig", "::", "create", "(", "'database'", ")", "->", "get", "(", "$", "name", ")", ";", "// check for an alias. If you set a string ", "// in your config file we use the config ", "// with the passed key.", "if", "(", "is_string", "(", "$", "config", ")", ")", "{", "$", "config", "=", "\\", "CCConfig", "::", "create", "(", "'database'", ")", "->", "get", "(", "$", "config", ")", ";", "}", "}", "// Setup the driver class. We simply use name ", "// from the confif file and make the first letter ", "// capital. example: Handler_Mysql, Handler_Sqlite etc.", "$", "driver_class", "=", "__NAMESPACE__", ".", "\"\\\\Handler_\"", ".", "ucfirst", "(", "$", "config", "[", "'driver'", "]", ")", ";", "if", "(", "!", "class_exists", "(", "$", "driver_class", ")", ")", "{", "throw", "new", "Exception", "(", "\"DB\\\\Handler::connect - The driver (\"", ".", "$", "driver_class", ".", "\") is invalid.\"", ")", ";", "}", "$", "this", "->", "set_driver", "(", "$", "driver_class", ")", ";", "// setup the builder the same way as the handler.", "$", "driver_class", "=", "__NAMESPACE__", ".", "\"\\\\Builder_\"", ".", "ucfirst", "(", "$", "config", "[", "'driver'", "]", ")", ";", "if", "(", "!", "class_exists", "(", "$", "driver_class", ")", ")", "{", "throw", "new", "Exception", "(", "\"DB\\\\Handler::connect - The builder (\"", ".", "$", "driver_class", ".", "\") is invalid.\"", ")", ";", "}", "$", "this", "->", "set_builder", "(", "$", "driver_class", ")", ";", "// finally try to connect the driver with the databse", "if", "(", "$", "this", "->", "driver", "(", ")", "->", "connect", "(", "$", "config", ")", ")", "{", "return", "$", "this", "->", "_connected", "=", "true", ";", "}", "return", "$", "this", "->", "_connected", "=", "false", ";", "}" ]
Try to etablish a connetion to the database. Also assign the connection and query builder to the current DB driver. @param string|array $name When passing an array it will be uesed as configuration. @return void
[ "Try", "to", "etablish", "a", "connetion", "to", "the", "database", ".", "Also", "assign", "the", "connection", "and", "query", "builder", "to", "the", "current", "DB", "driver", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Handler.php#L218-L275
16,778
ClanCats/Core
src/bundles/Database/Handler.php
Handler.statement
public function statement( $query, $params = array() ) { // we alway prepare the query even if we dont have parameters $sth = $this->driver()->connection()->prepare( $query ); // because we set pdo the throw exception on db errors // we catch them here to throw our own exception. try { $sth->execute( $params ); } catch ( \PDOException $e ) { throw new Exception( "DB\\Handler - PDOException: {$e->getMessage()} \n Query: {$query}" ); } // In development we alway log the query into an array. if ( \ClanCats::in_development() ) { $keys = array(); foreach ( $params as $key => $value ) { if ( is_string( $key ) ) { $keys[] = '/:'.$key.'/'; } else { $keys[] = '/[?]/'; } } static::$_query_log[] = preg_replace( $keys, $params, $query, 1 ); } return $sth; }
php
public function statement( $query, $params = array() ) { // we alway prepare the query even if we dont have parameters $sth = $this->driver()->connection()->prepare( $query ); // because we set pdo the throw exception on db errors // we catch them here to throw our own exception. try { $sth->execute( $params ); } catch ( \PDOException $e ) { throw new Exception( "DB\\Handler - PDOException: {$e->getMessage()} \n Query: {$query}" ); } // In development we alway log the query into an array. if ( \ClanCats::in_development() ) { $keys = array(); foreach ( $params as $key => $value ) { if ( is_string( $key ) ) { $keys[] = '/:'.$key.'/'; } else { $keys[] = '/[?]/'; } } static::$_query_log[] = preg_replace( $keys, $params, $query, 1 ); } return $sth; }
[ "public", "function", "statement", "(", "$", "query", ",", "$", "params", "=", "array", "(", ")", ")", "{", "// we alway prepare the query even if we dont have parameters", "$", "sth", "=", "$", "this", "->", "driver", "(", ")", "->", "connection", "(", ")", "->", "prepare", "(", "$", "query", ")", ";", "// because we set pdo the throw exception on db errors", "// we catch them here to throw our own exception.", "try", "{", "$", "sth", "->", "execute", "(", "$", "params", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "throw", "new", "Exception", "(", "\"DB\\\\Handler - PDOException: {$e->getMessage()} \\n Query: {$query}\"", ")", ";", "}", "// In development we alway log the query into an array.", "if", "(", "\\", "ClanCats", "::", "in_development", "(", ")", ")", "{", "$", "keys", "=", "array", "(", ")", ";", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "keys", "[", "]", "=", "'/:'", ".", "$", "key", ".", "'/'", ";", "}", "else", "{", "$", "keys", "[", "]", "=", "'/[?]/'", ";", "}", "}", "static", "::", "$", "_query_log", "[", "]", "=", "preg_replace", "(", "$", "keys", ",", "$", "params", ",", "$", "query", ",", "1", ")", ";", "}", "return", "$", "sth", ";", "}" ]
Run the query and return the PDO statement @param string $query @param array $params @return array
[ "Run", "the", "query", "and", "return", "the", "PDO", "statement" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Handler.php#L294-L329
16,779
ClanCats/Core
src/bundles/Database/Handler.php
Handler.fetch
public function fetch( $query, $params = array(), $arguments = array( 'obj' ) ) { $sth = $this->statement( $query, $params ); $args = null; foreach( $arguments as $argument ) { $args |= constant( "\PDO::FETCH_".strtoupper( $argument ) ); } return $sth->fetchAll( $args ); }
php
public function fetch( $query, $params = array(), $arguments = array( 'obj' ) ) { $sth = $this->statement( $query, $params ); $args = null; foreach( $arguments as $argument ) { $args |= constant( "\PDO::FETCH_".strtoupper( $argument ) ); } return $sth->fetchAll( $args ); }
[ "public", "function", "fetch", "(", "$", "query", ",", "$", "params", "=", "array", "(", ")", ",", "$", "arguments", "=", "array", "(", "'obj'", ")", ")", "{", "$", "sth", "=", "$", "this", "->", "statement", "(", "$", "query", ",", "$", "params", ")", ";", "$", "args", "=", "null", ";", "foreach", "(", "$", "arguments", "as", "$", "argument", ")", "{", "$", "args", "|=", "constant", "(", "\"\\PDO::FETCH_\"", ".", "strtoupper", "(", "$", "argument", ")", ")", ";", "}", "return", "$", "sth", "->", "fetchAll", "(", "$", "args", ")", ";", "}" ]
Run the query and fetch the results You can pass arguments on the third parameter. These parameter are just the normal PDO ones but in short. obj = \PDO::FETCH_OBJ assoc = \PDO::FETCH_ASSOC @param string $query @param array $params @return array
[ "Run", "the", "query", "and", "fetch", "the", "results" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Handler.php#L344-L356
16,780
ClanCats/Core
src/bundles/Database/Handler.php
Handler.run
public function run( $query, $params = array() ) { $sth = $this->statement( $query, $params ); $type = strtolower( substr( $query, 0, strpos( $query, ' ' ) ) ); switch ( $type ) { case 'update': case 'delete': return $sth->rowCount(); break; case 'insert': return $this->driver()->connection()->lastInsertId(); break; } return $sth; }
php
public function run( $query, $params = array() ) { $sth = $this->statement( $query, $params ); $type = strtolower( substr( $query, 0, strpos( $query, ' ' ) ) ); switch ( $type ) { case 'update': case 'delete': return $sth->rowCount(); break; case 'insert': return $this->driver()->connection()->lastInsertId(); break; } return $sth; }
[ "public", "function", "run", "(", "$", "query", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "sth", "=", "$", "this", "->", "statement", "(", "$", "query", ",", "$", "params", ")", ";", "$", "type", "=", "strtolower", "(", "substr", "(", "$", "query", ",", "0", ",", "strpos", "(", "$", "query", ",", "' '", ")", ")", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "'update'", ":", "case", "'delete'", ":", "return", "$", "sth", "->", "rowCount", "(", ")", ";", "break", ";", "case", "'insert'", ":", "return", "$", "this", "->", "driver", "(", ")", "->", "connection", "(", ")", "->", "lastInsertId", "(", ")", ";", "break", ";", "}", "return", "$", "sth", ";", "}" ]
Run the query and get the correct response INSERT -> last id UPDATE -> affected rows DELETE -> affected rows etc... @param string $query @param array $params @return array
[ "Run", "the", "query", "and", "get", "the", "correct", "response" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Handler.php#L370-L389
16,781
vench/venus-fw
src/vsapp/Request.php
Request.get
public function get($name) { $query = $this->queryAll(); return isset($query[$name]) ? $query[$name] : null; }
php
public function get($name) { $query = $this->queryAll(); return isset($query[$name]) ? $query[$name] : null; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "$", "query", "=", "$", "this", "->", "queryAll", "(", ")", ";", "return", "isset", "(", "$", "query", "[", "$", "name", "]", ")", "?", "$", "query", "[", "$", "name", "]", ":", "null", ";", "}" ]
Get value from GET params @param string $name @return mixed
[ "Get", "value", "from", "GET", "params" ]
9075ab6062551c022d145ac20640438074d5cb85
https://github.com/vench/venus-fw/blob/9075ab6062551c022d145ac20640438074d5cb85/src/vsapp/Request.php#L43-L46
16,782
CakeCMS/Core
src/Toolbar/ToolbarItem.php
ToolbarItem.render
public function render(&$node) { $id = call_user_func_array([&$this, 'fetchId'], $node); $output = call_user_func_array([&$this, 'fetchItem'], $node); list ($source) = $node; list ($plugin) = pluginSplit($source); $options = [ 'id' => $id, 'output' => $output, 'class' => $node['class'], ]; $element = 'Toolbar/wrapper'; if ($plugin !== null) { $element = $plugin . '.' . $element; } return $this->_view->element($element, $options); }
php
public function render(&$node) { $id = call_user_func_array([&$this, 'fetchId'], $node); $output = call_user_func_array([&$this, 'fetchItem'], $node); list ($source) = $node; list ($plugin) = pluginSplit($source); $options = [ 'id' => $id, 'output' => $output, 'class' => $node['class'], ]; $element = 'Toolbar/wrapper'; if ($plugin !== null) { $element = $plugin . '.' . $element; } return $this->_view->element($element, $options); }
[ "public", "function", "render", "(", "&", "$", "node", ")", "{", "$", "id", "=", "call_user_func_array", "(", "[", "&", "$", "this", ",", "'fetchId'", "]", ",", "$", "node", ")", ";", "$", "output", "=", "call_user_func_array", "(", "[", "&", "$", "this", ",", "'fetchItem'", "]", ",", "$", "node", ")", ";", "list", "(", "$", "source", ")", "=", "$", "node", ";", "list", "(", "$", "plugin", ")", "=", "pluginSplit", "(", "$", "source", ")", ";", "$", "options", "=", "[", "'id'", "=>", "$", "id", ",", "'output'", "=>", "$", "output", ",", "'class'", "=>", "$", "node", "[", "'class'", "]", ",", "]", ";", "$", "element", "=", "'Toolbar/wrapper'", ";", "if", "(", "$", "plugin", "!==", "null", ")", "{", "$", "element", "=", "$", "plugin", ".", "'.'", ".", "$", "element", ";", "}", "return", "$", "this", "->", "_view", "->", "element", "(", "$", "element", ",", "$", "options", ")", ";", "}" ]
Render toolbar html. @param array $node @return string
[ "Render", "toolbar", "html", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Toolbar/ToolbarItem.php#L82-L101
16,783
helthe/Chronos
Field/AbstractField.php
AbstractField.isInIncrementsOfRange
protected function isInIncrementsOfRange($increments, $value) { $incrementsParts = explode('/', $increments); if ('*' === $incrementsParts[0]) { return (int) $value % $incrementsParts[1] === 0; } if (!$this->isInRange($incrementsParts[0], $value)) { return false; } $rangeParts = explode('-', $incrementsParts[0]); for ($i = $rangeParts[0]; $i <= $rangeParts[1]; $i += $incrementsParts[1]) { if ($i == $value) { return true; } } return false; }
php
protected function isInIncrementsOfRange($increments, $value) { $incrementsParts = explode('/', $increments); if ('*' === $incrementsParts[0]) { return (int) $value % $incrementsParts[1] === 0; } if (!$this->isInRange($incrementsParts[0], $value)) { return false; } $rangeParts = explode('-', $incrementsParts[0]); for ($i = $rangeParts[0]; $i <= $rangeParts[1]; $i += $incrementsParts[1]) { if ($i == $value) { return true; } } return false; }
[ "protected", "function", "isInIncrementsOfRange", "(", "$", "increments", ",", "$", "value", ")", "{", "$", "incrementsParts", "=", "explode", "(", "'/'", ",", "$", "increments", ")", ";", "if", "(", "'*'", "===", "$", "incrementsParts", "[", "0", "]", ")", "{", "return", "(", "int", ")", "$", "value", "%", "$", "incrementsParts", "[", "1", "]", "===", "0", ";", "}", "if", "(", "!", "$", "this", "->", "isInRange", "(", "$", "incrementsParts", "[", "0", "]", ",", "$", "value", ")", ")", "{", "return", "false", ";", "}", "$", "rangeParts", "=", "explode", "(", "'-'", ",", "$", "incrementsParts", "[", "0", "]", ")", ";", "for", "(", "$", "i", "=", "$", "rangeParts", "[", "0", "]", ";", "$", "i", "<=", "$", "rangeParts", "[", "1", "]", ";", "$", "i", "+=", "$", "incrementsParts", "[", "1", "]", ")", "{", "if", "(", "$", "i", "==", "$", "value", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if the given value is in the given increments of range. @param string $increments @param string $value @return Boolean
[ "Checks", "if", "the", "given", "value", "is", "in", "the", "given", "increments", "of", "range", "." ]
6c783c55c32b323550fc6f21cd644c2be82720b0
https://github.com/helthe/Chronos/blob/6c783c55c32b323550fc6f21cd644c2be82720b0/Field/AbstractField.php#L134-L155
16,784
helthe/Chronos
Field/AbstractField.php
AbstractField.isInRange
protected function isInRange($range, $value) { $parts = explode('-', $range); return $value >= $parts[0] && $value <= $parts[1]; }
php
protected function isInRange($range, $value) { $parts = explode('-', $range); return $value >= $parts[0] && $value <= $parts[1]; }
[ "protected", "function", "isInRange", "(", "$", "range", ",", "$", "value", ")", "{", "$", "parts", "=", "explode", "(", "'-'", ",", "$", "range", ")", ";", "return", "$", "value", ">=", "$", "parts", "[", "0", "]", "&&", "$", "value", "<=", "$", "parts", "[", "1", "]", ";", "}" ]
Checks if the given value is in the given range. @param string $range @param string $value @return Boolean
[ "Checks", "if", "the", "given", "value", "is", "in", "the", "given", "range", "." ]
6c783c55c32b323550fc6f21cd644c2be82720b0
https://github.com/helthe/Chronos/blob/6c783c55c32b323550fc6f21cd644c2be82720b0/Field/AbstractField.php#L165-L170
16,785
steeffeen/FancyManiaLinks
FML/Script/Features/PlayerProfile.php
PlayerProfile.setControl
public function setControl(Control $control) { $control->checkId(); if ($control instanceof Scriptable) { $control->setScriptEvents(true); } $this->control = $control; return $this; }
php
public function setControl(Control $control) { $control->checkId(); if ($control instanceof Scriptable) { $control->setScriptEvents(true); } $this->control = $control; return $this; }
[ "public", "function", "setControl", "(", "Control", "$", "control", ")", "{", "$", "control", "->", "checkId", "(", ")", ";", "if", "(", "$", "control", "instanceof", "Scriptable", ")", "{", "$", "control", "->", "setScriptEvents", "(", "true", ")", ";", "}", "$", "this", "->", "control", "=", "$", "control", ";", "return", "$", "this", ";", "}" ]
Set the Profile Control @api @param Control $control Profile Control @return static
[ "Set", "the", "Profile", "Control" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/PlayerProfile.php#L99-L107
16,786
Double-Opt-in/php-client-api
src/Security/SlowAES/cryptoHelpers.php
cryptoHelpers.toHex
public static function toHex($args){ if(func_num_args() != 1 || !is_array($args)){ $args = func_get_args(); } $ret = ''; for($i = 0; $i < count($args) ;$i++) $ret .= sprintf('%02x', $args[$i]); return $ret; }
php
public static function toHex($args){ if(func_num_args() != 1 || !is_array($args)){ $args = func_get_args(); } $ret = ''; for($i = 0; $i < count($args) ;$i++) $ret .= sprintf('%02x', $args[$i]); return $ret; }
[ "public", "static", "function", "toHex", "(", "$", "args", ")", "{", "if", "(", "func_num_args", "(", ")", "!=", "1", "||", "!", "is_array", "(", "$", "args", ")", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "}", "$", "ret", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "args", ")", ";", "$", "i", "++", ")", "$", "ret", ".=", "sprintf", "(", "'%02x'", ",", "$", "args", "[", "$", "i", "]", ")", ";", "return", "$", "ret", ";", "}" ]
convert a number array to a hex string
[ "convert", "a", "number", "array", "to", "a", "hex", "string" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/cryptoHelpers.php#L34-L42
16,787
Double-Opt-in/php-client-api
src/Security/SlowAES/cryptoHelpers.php
cryptoHelpers.toNumbers
public static function toNumbers($s){ $ret = array(); for($i=0; $i<strlen($s); $i+=2){ $ret[] = hexdec(substr($s, $i, 2)); } return $ret; }
php
public static function toNumbers($s){ $ret = array(); for($i=0; $i<strlen($s); $i+=2){ $ret[] = hexdec(substr($s, $i, 2)); } return $ret; }
[ "public", "static", "function", "toNumbers", "(", "$", "s", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "s", ")", ";", "$", "i", "+=", "2", ")", "{", "$", "ret", "[", "]", "=", "hexdec", "(", "substr", "(", "$", "s", ",", "$", "i", ",", "2", ")", ")", ";", "}", "return", "$", "ret", ";", "}" ]
convert a hex string to a number array
[ "convert", "a", "hex", "string", "to", "a", "number", "array" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/cryptoHelpers.php#L45-L51
16,788
yuncms/framework
src/user/models/SettingsForm.php
SettingsForm.insecureEmailChange
protected function insecureEmailChange() { $this->user->email = $this->email; Yii::$app->session->setFlash('success', Yii::t('yuncms', 'Your email address has been changed')); }
php
protected function insecureEmailChange() { $this->user->email = $this->email; Yii::$app->session->setFlash('success', Yii::t('yuncms', 'Your email address has been changed')); }
[ "protected", "function", "insecureEmailChange", "(", ")", "{", "$", "this", "->", "user", "->", "email", "=", "$", "this", "->", "email", ";", "Yii", "::", "$", "app", "->", "session", "->", "setFlash", "(", "'success'", ",", "Yii", "::", "t", "(", "'yuncms'", ",", "'Your email address has been changed'", ")", ")", ";", "}" ]
Changes user's email address to given without any confirmation.
[ "Changes", "user", "s", "email", "address", "to", "given", "without", "any", "confirmation", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/models/SettingsForm.php#L164-L168
16,789
askupasoftware/amarkal
Extensions/WordPress/Options/Section.php
Section.is_current_section
public function is_current_section() { if( !isset( $this->active ) ) { $this->active = filter_input(INPUT_GET, 'section') == $this->get_slug(); } return $this->active; }
php
public function is_current_section() { if( !isset( $this->active ) ) { $this->active = filter_input(INPUT_GET, 'section') == $this->get_slug(); } return $this->active; }
[ "public", "function", "is_current_section", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "active", ")", ")", "{", "$", "this", "->", "active", "=", "filter_input", "(", "INPUT_GET", ",", "'section'", ")", "==", "$", "this", "->", "get_slug", "(", ")", ";", "}", "return", "$", "this", "->", "active", ";", "}" ]
Check if this is the current section. @return boolean True if this is the currently active section.
[ "Check", "if", "this", "is", "the", "current", "section", "." ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Options/Section.php#L95-L102
16,790
askupasoftware/amarkal
Extensions/WordPress/Options/Section.php
Section.get_fields
public function get_fields() { if( !isset( $this->fields ) ) { if( !$this->has_sub_sections() ) { $this->fields = $this->model['fields']; } else { $this->fields = array(); foreach( $this->model['subsections'] as $subsection ) { foreach( $subsection['fields'] as $field ) { $field->subsection = \Amarkal\Common\Tools::strtoslug( $subsection['title'] ); } $this->fields = array_merge( $this->fields, $subsection['fields'] ); } } } return $this->fields; }
php
public function get_fields() { if( !isset( $this->fields ) ) { if( !$this->has_sub_sections() ) { $this->fields = $this->model['fields']; } else { $this->fields = array(); foreach( $this->model['subsections'] as $subsection ) { foreach( $subsection['fields'] as $field ) { $field->subsection = \Amarkal\Common\Tools::strtoslug( $subsection['title'] ); } $this->fields = array_merge( $this->fields, $subsection['fields'] ); } } } return $this->fields; }
[ "public", "function", "get_fields", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "fields", ")", ")", "{", "if", "(", "!", "$", "this", "->", "has_sub_sections", "(", ")", ")", "{", "$", "this", "->", "fields", "=", "$", "this", "->", "model", "[", "'fields'", "]", ";", "}", "else", "{", "$", "this", "->", "fields", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "model", "[", "'subsections'", "]", "as", "$", "subsection", ")", "{", "foreach", "(", "$", "subsection", "[", "'fields'", "]", "as", "$", "field", ")", "{", "$", "field", "->", "subsection", "=", "\\", "Amarkal", "\\", "Common", "\\", "Tools", "::", "strtoslug", "(", "$", "subsection", "[", "'title'", "]", ")", ";", "}", "$", "this", "->", "fields", "=", "array_merge", "(", "$", "this", "->", "fields", ",", "$", "subsection", "[", "'fields'", "]", ")", ";", "}", "}", "}", "return", "$", "this", "->", "fields", ";", "}" ]
Get the array of fields for this section. If this section has subsections, the returning array will consist of all fields from all subsections. @return array
[ "Get", "the", "array", "of", "fields", "for", "this", "section", ".", "If", "this", "section", "has", "subsections", "the", "returning", "array", "will", "consist", "of", "all", "fields", "from", "all", "subsections", "." ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Options/Section.php#L121-L143
16,791
MinecraftJP/minecraftjp-php-sdk
src/MinecraftJP.php
MinecraftJP.getUser
public function getUser() { $this->user = $this->sessionStorage->read('user'); if (!empty($this->user)) { return $this->user; } $this->exchangeToken(); return $this->user; }
php
public function getUser() { $this->user = $this->sessionStorage->read('user'); if (!empty($this->user)) { return $this->user; } $this->exchangeToken(); return $this->user; }
[ "public", "function", "getUser", "(", ")", "{", "$", "this", "->", "user", "=", "$", "this", "->", "sessionStorage", "->", "read", "(", "'user'", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "user", ")", ")", "{", "return", "$", "this", "->", "user", ";", "}", "$", "this", "->", "exchangeToken", "(", ")", ";", "return", "$", "this", "->", "user", ";", "}" ]
Get User object @return mixed
[ "Get", "User", "object" ]
ecc592c9b6d33eb0c896210f7c9948672db54728
https://github.com/MinecraftJP/minecraftjp-php-sdk/blob/ecc592c9b6d33eb0c896210f7c9948672db54728/src/MinecraftJP.php#L75-L84
16,792
MinecraftJP/minecraftjp-php-sdk
src/MinecraftJP.php
MinecraftJP.getAccessToken
public function getAccessToken() { if (!empty($this->accessToken)) { return $this->accessToken; } $accessToken = $this->sessionStorage->read('access_token'); if (!empty($accessToken)) { $this->accessToken = $accssToken; return $this->accessToken; } $this->exchangeToken(); return $this->accessToken; }
php
public function getAccessToken() { if (!empty($this->accessToken)) { return $this->accessToken; } $accessToken = $this->sessionStorage->read('access_token'); if (!empty($accessToken)) { $this->accessToken = $accssToken; return $this->accessToken; } $this->exchangeToken(); return $this->accessToken; }
[ "public", "function", "getAccessToken", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "accessToken", ")", ")", "{", "return", "$", "this", "->", "accessToken", ";", "}", "$", "accessToken", "=", "$", "this", "->", "sessionStorage", "->", "read", "(", "'access_token'", ")", ";", "if", "(", "!", "empty", "(", "$", "accessToken", ")", ")", "{", "$", "this", "->", "accessToken", "=", "$", "accssToken", ";", "return", "$", "this", "->", "accessToken", ";", "}", "$", "this", "->", "exchangeToken", "(", ")", ";", "return", "$", "this", "->", "accessToken", ";", "}" ]
Get Access token. @return mixed
[ "Get", "Access", "token", "." ]
ecc592c9b6d33eb0c896210f7c9948672db54728
https://github.com/MinecraftJP/minecraftjp-php-sdk/blob/ecc592c9b6d33eb0c896210f7c9948672db54728/src/MinecraftJP.php#L91-L104
16,793
MinecraftJP/minecraftjp-php-sdk
src/MinecraftJP.php
MinecraftJP.getRefreshToken
public function getRefreshToken() { if (empty($this->refreshToken)) { $this->refreshToken = $this->sessionStorage->read('refresh_token'); return $this->refreshToken; } return $this->refreshToken; }
php
public function getRefreshToken() { if (empty($this->refreshToken)) { $this->refreshToken = $this->sessionStorage->read('refresh_token'); return $this->refreshToken; } return $this->refreshToken; }
[ "public", "function", "getRefreshToken", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "refreshToken", ")", ")", "{", "$", "this", "->", "refreshToken", "=", "$", "this", "->", "sessionStorage", "->", "read", "(", "'refresh_token'", ")", ";", "return", "$", "this", "->", "refreshToken", ";", "}", "return", "$", "this", "->", "refreshToken", ";", "}" ]
Get Refresh token. @return mixed
[ "Get", "Refresh", "token", "." ]
ecc592c9b6d33eb0c896210f7c9948672db54728
https://github.com/MinecraftJP/minecraftjp-php-sdk/blob/ecc592c9b6d33eb0c896210f7c9948672db54728/src/MinecraftJP.php#L111-L117
16,794
MinecraftJP/minecraftjp-php-sdk
src/MinecraftJP.php
MinecraftJP.requestClientCredentials
public function requestClientCredentials($options = array()) { $options = array_merge(array( 'scope' => '', ), $options); $res = $this->sendRequest('POST', $this->getUrl('oauth', 'token'), array( 'client_id' => $this->getClientId(), 'client_secret' => $this->getClientSecret(), 'grant_type' => 'client_credentials', 'scope' => $options['scope'], )); $result = $res->getBody(); $token = null; if ($result && $result = json_decode($result, true)) { if (!empty($result['error'])) { throw new Exception($result['error_description']); } if (!empty($result['access_token'])) { $this->accessToken = $token = $result['access_token']; } } if (empty($token)) { throw new InvalidTokenException('token not available.'); } return $token; }
php
public function requestClientCredentials($options = array()) { $options = array_merge(array( 'scope' => '', ), $options); $res = $this->sendRequest('POST', $this->getUrl('oauth', 'token'), array( 'client_id' => $this->getClientId(), 'client_secret' => $this->getClientSecret(), 'grant_type' => 'client_credentials', 'scope' => $options['scope'], )); $result = $res->getBody(); $token = null; if ($result && $result = json_decode($result, true)) { if (!empty($result['error'])) { throw new Exception($result['error_description']); } if (!empty($result['access_token'])) { $this->accessToken = $token = $result['access_token']; } } if (empty($token)) { throw new InvalidTokenException('token not available.'); } return $token; }
[ "public", "function", "requestClientCredentials", "(", "$", "options", "=", "array", "(", ")", ")", "{", "$", "options", "=", "array_merge", "(", "array", "(", "'scope'", "=>", "''", ",", ")", ",", "$", "options", ")", ";", "$", "res", "=", "$", "this", "->", "sendRequest", "(", "'POST'", ",", "$", "this", "->", "getUrl", "(", "'oauth'", ",", "'token'", ")", ",", "array", "(", "'client_id'", "=>", "$", "this", "->", "getClientId", "(", ")", ",", "'client_secret'", "=>", "$", "this", "->", "getClientSecret", "(", ")", ",", "'grant_type'", "=>", "'client_credentials'", ",", "'scope'", "=>", "$", "options", "[", "'scope'", "]", ",", ")", ")", ";", "$", "result", "=", "$", "res", "->", "getBody", "(", ")", ";", "$", "token", "=", "null", ";", "if", "(", "$", "result", "&&", "$", "result", "=", "json_decode", "(", "$", "result", ",", "true", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "result", "[", "'error'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "$", "result", "[", "'error_description'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "result", "[", "'access_token'", "]", ")", ")", "{", "$", "this", "->", "accessToken", "=", "$", "token", "=", "$", "result", "[", "'access_token'", "]", ";", "}", "}", "if", "(", "empty", "(", "$", "token", ")", ")", "{", "throw", "new", "InvalidTokenException", "(", "'token not available.'", ")", ";", "}", "return", "$", "token", ";", "}" ]
Request Client Credentials token
[ "Request", "Client", "Credentials", "token" ]
ecc592c9b6d33eb0c896210f7c9948672db54728
https://github.com/MinecraftJP/minecraftjp-php-sdk/blob/ecc592c9b6d33eb0c896210f7c9948672db54728/src/MinecraftJP.php#L122-L151
16,795
MinecraftJP/minecraftjp-php-sdk
src/MinecraftJP.php
MinecraftJP.getLoginUrl
public function getLoginUrl($options = array()) { $options = array_merge(array( 'scope' => 'openid profile', ), $options); if (isset($options['scope']) && is_array($options['scope'])) { $options['scope'] = join(' ', $options['scope']); } // Generate nonce if (function_exists('openssl_random_pseudo_bytes')) { $nonce = sha1(openssl_random_pseudo_bytes(24)); } else { $nonce = sha1(uniqid(mt_rand(), true)); } $this->sessionStorage->write('nonce', $nonce); return $this->getUrl('oauth', 'authorize', array( 'client_id' => $this->getClientId(), 'response_type' => 'code', 'scope' => $options['scope'], 'redirect_uri' => isset($options['redirect_uri']) ? $options['redirect_uri'] : $this->redirectUri, 'nonce' => $nonce, )); }
php
public function getLoginUrl($options = array()) { $options = array_merge(array( 'scope' => 'openid profile', ), $options); if (isset($options['scope']) && is_array($options['scope'])) { $options['scope'] = join(' ', $options['scope']); } // Generate nonce if (function_exists('openssl_random_pseudo_bytes')) { $nonce = sha1(openssl_random_pseudo_bytes(24)); } else { $nonce = sha1(uniqid(mt_rand(), true)); } $this->sessionStorage->write('nonce', $nonce); return $this->getUrl('oauth', 'authorize', array( 'client_id' => $this->getClientId(), 'response_type' => 'code', 'scope' => $options['scope'], 'redirect_uri' => isset($options['redirect_uri']) ? $options['redirect_uri'] : $this->redirectUri, 'nonce' => $nonce, )); }
[ "public", "function", "getLoginUrl", "(", "$", "options", "=", "array", "(", ")", ")", "{", "$", "options", "=", "array_merge", "(", "array", "(", "'scope'", "=>", "'openid profile'", ",", ")", ",", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'scope'", "]", ")", "&&", "is_array", "(", "$", "options", "[", "'scope'", "]", ")", ")", "{", "$", "options", "[", "'scope'", "]", "=", "join", "(", "' '", ",", "$", "options", "[", "'scope'", "]", ")", ";", "}", "// Generate nonce", "if", "(", "function_exists", "(", "'openssl_random_pseudo_bytes'", ")", ")", "{", "$", "nonce", "=", "sha1", "(", "openssl_random_pseudo_bytes", "(", "24", ")", ")", ";", "}", "else", "{", "$", "nonce", "=", "sha1", "(", "uniqid", "(", "mt_rand", "(", ")", ",", "true", ")", ")", ";", "}", "$", "this", "->", "sessionStorage", "->", "write", "(", "'nonce'", ",", "$", "nonce", ")", ";", "return", "$", "this", "->", "getUrl", "(", "'oauth'", ",", "'authorize'", ",", "array", "(", "'client_id'", "=>", "$", "this", "->", "getClientId", "(", ")", ",", "'response_type'", "=>", "'code'", ",", "'scope'", "=>", "$", "options", "[", "'scope'", "]", ",", "'redirect_uri'", "=>", "isset", "(", "$", "options", "[", "'redirect_uri'", "]", ")", "?", "$", "options", "[", "'redirect_uri'", "]", ":", "$", "this", "->", "redirectUri", ",", "'nonce'", "=>", "$", "nonce", ",", ")", ")", ";", "}" ]
Get login url for redirect. @param array $options @return string
[ "Get", "login", "url", "for", "redirect", "." ]
ecc592c9b6d33eb0c896210f7c9948672db54728
https://github.com/MinecraftJP/minecraftjp-php-sdk/blob/ecc592c9b6d33eb0c896210f7c9948672db54728/src/MinecraftJP.php#L159-L183
16,796
MinecraftJP/minecraftjp-php-sdk
src/MinecraftJP.php
MinecraftJP.exchangeToken
protected function exchangeToken() { $result = $this->requestAccessToken(); if ($result && !empty($result['access_token'])) { $this->accessToken = $result['access_token']; $this->sessionStorage->write('access_token', $result['access_token']); if (!empty($result['refresh_token'])) { $this->refreshToken = $result['refresh_token']; $this->sessionStorage->write('refresh_token', $result['refresh_token']); } if (!empty($result['id_token'])) { $this->validateIdToken($result['id_token']); $this->user = $this->requestUserInfo(); if ($this->user) { $this->sessionStorage->write('user', $this->user); } } } }
php
protected function exchangeToken() { $result = $this->requestAccessToken(); if ($result && !empty($result['access_token'])) { $this->accessToken = $result['access_token']; $this->sessionStorage->write('access_token', $result['access_token']); if (!empty($result['refresh_token'])) { $this->refreshToken = $result['refresh_token']; $this->sessionStorage->write('refresh_token', $result['refresh_token']); } if (!empty($result['id_token'])) { $this->validateIdToken($result['id_token']); $this->user = $this->requestUserInfo(); if ($this->user) { $this->sessionStorage->write('user', $this->user); } } } }
[ "protected", "function", "exchangeToken", "(", ")", "{", "$", "result", "=", "$", "this", "->", "requestAccessToken", "(", ")", ";", "if", "(", "$", "result", "&&", "!", "empty", "(", "$", "result", "[", "'access_token'", "]", ")", ")", "{", "$", "this", "->", "accessToken", "=", "$", "result", "[", "'access_token'", "]", ";", "$", "this", "->", "sessionStorage", "->", "write", "(", "'access_token'", ",", "$", "result", "[", "'access_token'", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "result", "[", "'refresh_token'", "]", ")", ")", "{", "$", "this", "->", "refreshToken", "=", "$", "result", "[", "'refresh_token'", "]", ";", "$", "this", "->", "sessionStorage", "->", "write", "(", "'refresh_token'", ",", "$", "result", "[", "'refresh_token'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "result", "[", "'id_token'", "]", ")", ")", "{", "$", "this", "->", "validateIdToken", "(", "$", "result", "[", "'id_token'", "]", ")", ";", "$", "this", "->", "user", "=", "$", "this", "->", "requestUserInfo", "(", ")", ";", "if", "(", "$", "this", "->", "user", ")", "{", "$", "this", "->", "sessionStorage", "->", "write", "(", "'user'", ",", "$", "this", "->", "user", ")", ";", "}", "}", "}", "}" ]
Exchange code to access_token
[ "Exchange", "code", "to", "access_token" ]
ecc592c9b6d33eb0c896210f7c9948672db54728
https://github.com/MinecraftJP/minecraftjp-php-sdk/blob/ecc592c9b6d33eb0c896210f7c9948672db54728/src/MinecraftJP.php#L222-L240
16,797
MinecraftJP/minecraftjp-php-sdk
src/MinecraftJP.php
MinecraftJP.requestUserInfo
protected function requestUserInfo() { $res = $this->sendRequest('GET', $this->getUrl('oauth', 'userinfo'), array(), array( 'Authorization' => 'Bearer ' . $this->sessionStorage->read('access_token'), )); $result = $res->getBody(); return json_decode($result, true); }
php
protected function requestUserInfo() { $res = $this->sendRequest('GET', $this->getUrl('oauth', 'userinfo'), array(), array( 'Authorization' => 'Bearer ' . $this->sessionStorage->read('access_token'), )); $result = $res->getBody(); return json_decode($result, true); }
[ "protected", "function", "requestUserInfo", "(", ")", "{", "$", "res", "=", "$", "this", "->", "sendRequest", "(", "'GET'", ",", "$", "this", "->", "getUrl", "(", "'oauth'", ",", "'userinfo'", ")", ",", "array", "(", ")", ",", "array", "(", "'Authorization'", "=>", "'Bearer '", ".", "$", "this", "->", "sessionStorage", "->", "read", "(", "'access_token'", ")", ",", ")", ")", ";", "$", "result", "=", "$", "res", "->", "getBody", "(", ")", ";", "return", "json_decode", "(", "$", "result", ",", "true", ")", ";", "}" ]
Request User Info @return mixed
[ "Request", "User", "Info" ]
ecc592c9b6d33eb0c896210f7c9948672db54728
https://github.com/MinecraftJP/minecraftjp-php-sdk/blob/ecc592c9b6d33eb0c896210f7c9948672db54728/src/MinecraftJP.php#L274-L281
16,798
MinecraftJP/minecraftjp-php-sdk
src/MinecraftJP.php
MinecraftJP.requestAccessToken
protected function requestAccessToken() { $code = $this->getRequestVar('code'); if (!empty($code)) { $res = $this->sendRequest('POST', $this->getUrl('oauth', 'token'), array( 'code' => $code, 'client_id' => $this->getClientId(), 'client_secret' => $this->getClientSecret(), 'grant_type' => 'authorization_code', 'redirect_uri' => $this->redirectUri, )); $result = $res->getBody(); if ($result && $result = json_decode($result, true)) { if (!empty($result['error'])) { throw new Exception($result['error_description']); } return $result; } } return null; }
php
protected function requestAccessToken() { $code = $this->getRequestVar('code'); if (!empty($code)) { $res = $this->sendRequest('POST', $this->getUrl('oauth', 'token'), array( 'code' => $code, 'client_id' => $this->getClientId(), 'client_secret' => $this->getClientSecret(), 'grant_type' => 'authorization_code', 'redirect_uri' => $this->redirectUri, )); $result = $res->getBody(); if ($result && $result = json_decode($result, true)) { if (!empty($result['error'])) { throw new Exception($result['error_description']); } return $result; } } return null; }
[ "protected", "function", "requestAccessToken", "(", ")", "{", "$", "code", "=", "$", "this", "->", "getRequestVar", "(", "'code'", ")", ";", "if", "(", "!", "empty", "(", "$", "code", ")", ")", "{", "$", "res", "=", "$", "this", "->", "sendRequest", "(", "'POST'", ",", "$", "this", "->", "getUrl", "(", "'oauth'", ",", "'token'", ")", ",", "array", "(", "'code'", "=>", "$", "code", ",", "'client_id'", "=>", "$", "this", "->", "getClientId", "(", ")", ",", "'client_secret'", "=>", "$", "this", "->", "getClientSecret", "(", ")", ",", "'grant_type'", "=>", "'authorization_code'", ",", "'redirect_uri'", "=>", "$", "this", "->", "redirectUri", ",", ")", ")", ";", "$", "result", "=", "$", "res", "->", "getBody", "(", ")", ";", "if", "(", "$", "result", "&&", "$", "result", "=", "json_decode", "(", "$", "result", ",", "true", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "result", "[", "'error'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "$", "result", "[", "'error_description'", "]", ")", ";", "}", "return", "$", "result", ";", "}", "}", "return", "null", ";", "}" ]
Request Access Token @return mixed|null @throws Exception
[ "Request", "Access", "Token" ]
ecc592c9b6d33eb0c896210f7c9948672db54728
https://github.com/MinecraftJP/minecraftjp-php-sdk/blob/ecc592c9b6d33eb0c896210f7c9948672db54728/src/MinecraftJP.php#L289-L309
16,799
MinecraftJP/minecraftjp-php-sdk
src/MinecraftJP.php
MinecraftJP.getUrl
public function getUrl($type, $path, $params = array()) { $url = self::$URL_TABLE[$type] . $path; if (!empty($params)) { $url .= '?' . http_build_query($params); } return $url; }
php
public function getUrl($type, $path, $params = array()) { $url = self::$URL_TABLE[$type] . $path; if (!empty($params)) { $url .= '?' . http_build_query($params); } return $url; }
[ "public", "function", "getUrl", "(", "$", "type", ",", "$", "path", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "url", "=", "self", "::", "$", "URL_TABLE", "[", "$", "type", "]", ".", "$", "path", ";", "if", "(", "!", "empty", "(", "$", "params", ")", ")", "{", "$", "url", ".=", "'?'", ".", "http_build_query", "(", "$", "params", ")", ";", "}", "return", "$", "url", ";", "}" ]
Build API Url @param $type @param $path @param array $params @return string
[ "Build", "API", "Url" ]
ecc592c9b6d33eb0c896210f7c9948672db54728
https://github.com/MinecraftJP/minecraftjp-php-sdk/blob/ecc592c9b6d33eb0c896210f7c9948672db54728/src/MinecraftJP.php#L319-L325