_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q5500
CategoryModel._buildTree
train
private function _buildTree(array &$tree, array $parents, array $orderedCategories, CmsCategoryRecord $parentCategory = null) { //uzupełnienie rodziców if ($parentCategory !== null) { $parents[$parentCategory->id] = $parentCategory; } else { $parentCategory = new CmsCategoryRecord; $parentCategory->id = null; } /* @var $categoryRecord CmsCategoryRecord */ foreach ($orderedCategories as $key => $categoryRecord) { //niezgodny
php
{ "resource": "" }
q5501
User.getRoles
train
public function getRoles() { $roles = array(); foreach ($this->groups as $group) { $roles[] = $group->getAsRole();
php
{ "resource": "" }
q5502
CmsFileRecord.getHashName
train
public function getHashName() { //brak pliku if ($this->id === null) {
php
{ "resource": "" }
q5503
CmsFileRecord.getPosterUrl
train
public function getPosterUrl($scaleType = 'default', $scale = null, $https = null) { //brak pliku if (null === $this->id || !$this->data->posterFileName) { return; } //ścieżka CDN $cdnPath = rtrim(\Mmi\App\FrontController::getInstance()->getView()->cdn ? \Mmi\App\FrontController::getInstance()->getView()->cdn : \Mmi\App\FrontController::getInstance()->getView()->url([],
php
{ "resource": "" }
q5504
CmsFileRecord.delete
train
public function delete() { //usuwanie meta if (!parent::delete()) { return false; } //plik jest ciągle potrzebny (ma linki) if (0 != (new CmsFileQuery)->whereName()->equals($this->name)->count()) { return true; }
php
{ "resource": "" }
q5505
Query.limit
train
public function limit($limit, $offset = null) { $this->_limit = $limit >
php
{ "resource": "" }
q5506
GridRequestHandler._retrievePostFilter
train
protected function _retrievePostFilter(\Mmi\Http\RequestPost $post) { //brak filtracji dla tego grida if (false === strpos($post->filter, $this->_grid->getClass())) { return; } $columnName = substr($post->filter, strpos($post->filter, '[') + 1, -1); $tableName = null; $fieldName = $columnName; //obsługa joinowanych if (strpos($columnName, '.')) { $fieldTable = explode('.', $columnName); $tableName = $fieldTable[0]; $fieldName = $fieldTable[1]; } //paginator if ($fieldName == '_paginator_') { //ustawianie filtra return (new GridStateFilter()) ->setField($fieldName) ->setValue($post->value); } //iteracja po kolumnach foreach
php
{ "resource": "" }
q5507
RepositoryCreator.create
train
public function create( ReflectionClass $modelReflection, $classFileName, $shortClassName, $classNamespace, $contractFileName, $shortContractName, $contractNamespace, array $methods ) { $createdFiles = [$this->createRepository( $modelReflection, $classFileName, $shortClassName, $classNamespace, $shortContractName, $contractNamespace,
php
{ "resource": "" }
q5508
RepositoryCreator.createRepository
train
protected function createRepository( ReflectionClass $model, $fileName, $shortName, $namespace, $contractName, $contractNamespace, array $methods ) { $path = app_path($fileName); $stub = $this->compileStub('repository.stub', [ 'namespace' => $namespace, 'class' => $shortName, 'model.fullname' => $model->getName(), 'model' => $model->getShortName(), 'implementation'
php
{ "resource": "" }
q5509
RepositoryCreator.createContract
train
protected function createContract(ReflectionClass $model, $fileName, $shortName, $namespace, array $methods) { $path = app_path($fileName); $stub = $this->compileStub('contract.stub', [ 'namespace' => $namespace, 'class' => $shortName, 'model.fullname' => $model->getName(), 'model' => $model->getShortName(), ]);
php
{ "resource": "" }
q5510
RepositoryCreator.compileMethods
train
protected function compileMethods($stub, array $methods) { foreach ($methods as $method) { $stub = str_replace(['{{' . $method . '}}', '{{/' . $method . '}}'], '', $stub); } foreach ($this->methods as $method) {
php
{ "resource": "" }
q5511
RepositoryCreator.compileStub
train
protected function compileStub($stub, array $data) { $stub = $this->files->get(__DIR__ . '/../stub/' . $stub);
php
{ "resource": "" }
q5512
MenuNodeDefinition.menuNodeHierarchy
train
public function menuNodeHierarchy($depth = 10) { if ($depth == 0) { return $this; } return $this ->prototype('array') ->children() ->scalarNode('route')->end() ->arrayNode('routeParameters') ->prototype('variable') ->end() ->end() ->scalarNode('uri')->end() ->scalarNode('label')->end() ->booleanNode('display')->defaultTrue()->end() ->booleanNode('displayChildren')->defaultTrue()->end() ->integerNode('order')->end() ->arrayNode('attributes') ->prototype('variable') ->end() ->end() ->arrayNode('linkAttributes') ->prototype('variable') ->end() ->end() ->arrayNode('childrenAttributes') ->prototype('variable') ->end() ->end()
php
{ "resource": "" }
q5513
AclController.deleteRoleAction
train
public function deleteRoleAction() { //wyszukiwanie i usuwanie roli if ((null !== $role = (new \Cms\Orm\CmsRoleQuery)->findPk($this->id))) { $this->getMessenger()->addMessage(($deleteResult
php
{ "resource": "" }
q5514
UploadController.pluploadAction
train
public function pluploadAction() { set_time_limit(5 * 60); //obiekt handlera plupload $pluploadHandler = new Model\PluploadHandler(); //jeśli wystąpił błąd if (!$pluploadHandler->handle()) { return $this->_jsonError($pluploadHandler->getErrorCode(), $pluploadHandler->getErrorMessage()); } //jeśli wykonać operację po przesłaniu całego pliku i zapisaniu rekordu
php
{ "resource": "" }
q5515
UploadController.deleteAction
train
public function deleteAction() { //szukamy rekordu pliku if (!$this->getPost()->cmsFileId || null === $record = (new CmsFileQuery)->findPk($this->getPost()->cmsFileId)) { return $this->_jsonError(178); } //sprawdzenie zgodności z obiektem formularza if ($record->object === $this->getPost()->object && $record->objectId == $this->getPost()->objectId) { //usuwanie if ($record->delete()) { //jeśli wykonać operację po usunięciu if
php
{ "resource": "" }
q5516
UploadController.downloadAction
train
public function downloadAction() { if (null === $file = (new CmsFileQuery)->byObject($this->object, $this->objectId) ->findPk($this->id)) {
php
{ "resource": "" }
q5517
UploadController._savePoster
train
protected function _savePoster($blob, \Cms\Orm\CmsFileRecord $file) { //brak danych if (!\preg_match('/^data:(image\/[a-z]+);base64,(.*)/i', $blob, $match)) { return; } //nazwa postera $posterFileName = substr($file->name, 0, strpos($file->name, '.')) . '-' . $file->id . '.' . \Mmi\Http\ResponseTypes::getExtensionByType($match[1]); //próba utworzenia katalogu try { //tworzenie katalogu mkdir(dirname($file->getRealPath()), 0777, true); } catch (\Exception $e) {
php
{ "resource": "" }
q5518
GeneratorFinderCache.getAllClasses
train
public function getAllClasses(MetaDataInterface $metadata = null) { $cacheFilename = $this->directories['Cache'] . DIRECTORY_SEPARATOR; $cacheFilename .= md5('genrator_getAllClasses' . ($metadata !== null) ? get_class($metadata) : ''); if ($this->fileManager->isFile($cacheFilename) === true && $this->noCache === false) { $data = unserialize($this->fileManager->fileGetContent($cacheFilename));
php
{ "resource": "" }
q5519
Manager.fireEvent
train
public function fireEvent($event, $source, $data = []) { if ($this->_listeners) { list($p1, $p2) = explode(':', $event, 2); if (isset($this->_listeners[$p1])) { foreach ($this->_listeners[$p1] as $k => $v) { /**@var \ManaPHP\Event\Listener $listener */ if (is_int($v)) { $this->_listeners[$p1][$k] = $listener = $this->_di->getShared($k); } else { $listener = $v; } $listener->process($p2, $source, $data); } } } foreach ($this->_peekers as $handler) { if ($handler instanceof \Closure) { $handler($event, $source, $data);
php
{ "resource": "" }
q5520
ACLType.getStandardPermissions
train
protected function getStandardPermissions(array $options, $master, $owner) { switch ($options['permissions']) { case 'standard::object': $disable = array (); // if not owner or master, disable all permissions if (!$master && !$owner) { $disable = array (1, 3, 4, 6, 7, 8); } // if not master, disable // 5 -> undelete is not used return array ( 'show' => array ( 1 => 'View', 3 => 'Edit', 4 => 'Delete', 6 => 'Operator', 7 => 'Master', 8 => 'Owner' ), 'disable' => $disable); break; case 'standard::class': return array ( 'show' => array ( 1 => 'View',
php
{ "resource": "" }
q5521
PharController.manacliCommand
train
public function manacliCommand() { $this->alias->set('@phar', '@data/manacli_phar'); $pharFile = $this->alias->resolve('@root/manacli.phar'); $this->console->writeLn(['cleaning `:dir` dir', 'dir' => $this->alias->resolve('@phar')]); $this->filesystem->dirReCreate('@phar'); $this->console->writeLn('copying manaphp framework files.'); $this->filesystem->dirCopy('@root/ManaPHP', '@phar/ManaPHP'); //$di->filesystem->dirCopy('@root/Application', '@phar/Application'); $this->filesystem->fileCopy('@root/manacli.php', '@phar/manacli.php'); $phar = new \Phar($pharFile, \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::KEY_AS_FILENAME,
php
{ "resource": "" }
q5522
FileConflictManager.handle
train
public function handle($filePath, $results) { $responseCollection = new PredefinedResponseCollection(); $responseCollection->append( new PredefinedResponse('postpone', 'postpone', self::POSTPONE) ); $responseCollection->append( new PredefinedResponse('show diff', 'show diff', self::SHOW_DIFF) ); $responseCollection->append( new PredefinedResponse('erase', 'erase', self::ERASE) ); $responseCollection->append( new PredefinedResponse('cancel', 'cancel', self::CANCEL) ); $question = new QuestionWithPredefinedResponse( sprintf('File "%s" already exist, erase it with the new', $filePath), 'conflict' . $filePath, $responseCollection ); $question->setShutdownWithoutResponse(true, sprintf('Conflict with file "%s" not resolved', $filePath)); while (($response = $this->context->askCollection($question)) !== null) { $response = intval($response); if ($response === self::SHOW_DIFF) { // write to output the diff $this->context->log( '<info>' . $this->diffPHP->diff($results, $this->fileManager->fileGetContent($filePath)) . '</info>' );
php
{ "resource": "" }
q5523
GeneratorParser.analyzeDependencies
train
private function analyzeDependencies(array $process, PhpStringParser $phpParser, GeneratorDataObject $generator) { $generator = clone $generator; if (isset($process['dependencies']) === true && is_array($process['dependencies']) === true) { foreach ($process['dependencies'] as $dependencieName) { $generator->addDependency(
php
{ "resource": "" }
q5524
GeneratorParser.analyzePreParser
train
private function analyzePreParser( array $process, PhpStringParser $phpParser, GeneratorDataObject $generator, $firstIteration ) { $generator = clone $generator; if ($this->parserCollection->getPreParse()->count() > 0) { foreach ($this->parserCollection->getPreParse() as $parser) {
php
{ "resource": "" }
q5525
GeneratorParser.analyzePostParser
train
private function analyzePostParser( array $process, PhpStringParser $phpParser, GeneratorDataObject $generator, $firstIteration ) { $generator = clone $generator;
php
{ "resource": "" }
q5526
PasswordController.setContainer
train
public function setContainer(ContainerInterface $container = null) { parent::setContainer($container);
php
{ "resource": "" }
q5527
MetaDataConfigDAO.retrieveAll
train
public function retrieveAll() { $adapterCollection = new MetaDataSourceCollection(); foreach ($this->fileManager->glob(Installer::BASE_PATH . self::SOURCE_PATH . '*' . self::EXTENSION) as $file) { // Decode $config = $this->transtyper->decode($this->fileManager->fileGetContent($file)); // Validate try { $this->arrayValidator->isValid('CrudGenerator\Metadata\MetaDataSource', $config); } catch (ValidationException $e) { continue; // Do nothing } // Hydrate $adapter = $this->metaDataSourceHydrator->adapterNameToMetaDataSource(
php
{ "resource": "" }
q5528
MySQLMetaDataDAOFactory.getInstance
train
public static function getInstance(DriverConfig $config) { $pdoDriver = PdoDriverFactory::getInstance(); return new MySQLMetaDataDAO(
php
{ "resource": "" }
q5529
CategoryWidgetController.deleteAttributeRelationAction
train
public function deleteAttributeRelationAction() { //usuwanie relacji (new AttributeController($this->getRequest(), $this->view))->deleteAttributeRelationAction();
php
{ "resource": "" }
q5530
PostgreSQLMetaDataDAOFactory.getInstance
train
public static function getInstance(DriverConfig $config) { $pdoDriver = PdoDriverFactory::getInstance(); return new PostgreSQLMetaDataDAO(
php
{ "resource": "" }
q5531
Project.addGuest
train
public function addGuest($id,$guest) { if(is_string($guest)) { $params = array('email'=>$guest); } elseif(is_numeric($guest)) { $params = array('user_id'=>$guest); }else {
php
{ "resource": "" }
q5532
Category.afterSave
train
public function afterSave() { //jeśli czegoś nie uddało się zapisać wcześniej if (!parent::afterSave()) { return false; } //jeśli nie udało się zapisać powiązań z rolami if (!$this->_saveRoles()) { return false; } //commit wersji
php
{ "resource": "" }
q5533
ReplacePlaceholdersInTemplateFiles.getPlaceholderArray
train
protected function getPlaceholderArray() { $placeholderArray = []; foreach ($this->getConfigKey('Placeholders') as
php
{ "resource": "" }
q5534
TagRelation.beforeSave
train
public function beforeSave() { $tag = $this->getElement('tag')->getValue(); //wyszukanie tagu if (null === $tagRecord = (new \Cms\Orm\CmsTagQuery) ->whereTag()->equals($tag) ->findFirst()) { //utworzenie tagu
php
{ "resource": "" }
q5535
Di.set
train
public function set($name, $definition) { if (is_string($definition)) { if (strpos($definition, '/') !== false || preg_match('#^[\w\\\\]+$#', $definition) !== 1) { $definition = ['class' => $this->_interClassName($name), $definition, 'shared' => false]; } else { if (strpos($definition, '\\') === false) { $definition = $this->_completeClassName($name, $definition); } $definition = ['class' => $definition, 'shared' => false]; } } elseif (is_array($definition)) { if (isset($definition['class'])) { if (strpos($definition['class'], '\\') === false) { $definition['class'] = $this->_completeClassName($name, $definition['class']); } } elseif (isset($definition[0]) && count($definition) !== 1) { if (strpos($definition[0], '\\') === false) { $definition[0] = $this->_completeClassName($name, $definition[0]);
php
{ "resource": "" }
q5536
Di.setShared
train
public function setShared($name, $definition) { if (isset($this->_instances[$name])) { throw new MisuseException(['it\'s too late to setShared(): `:name` instance has been created', 'name' => $name]); } if (is_string($definition)) { if (strpos($definition, '/') !== false || preg_match('#^[\w\\\\]+$#', $definition) !== 1) { $definition = ['class' => $this->_interClassName($name), $definition]; } elseif (strpos($definition, '\\') === false) { $definition = $this->_completeClassName($name, $definition); } } elseif (is_array($definition)) { if (isset($definition['class'])) { if (strpos($definition['class'], '\\') === false) { $definition['class'] = $this->_completeClassName($name, $definition['class']); } } elseif (isset($definition[0]) && count($definition) !== 1) { if (strpos($definition[0], '\\') === false) {
php
{ "resource": "" }
q5537
Di.remove
train
public function remove($name) { unset($this->_definitions[$name],
php
{ "resource": "" }
q5538
Di.get
train
public function get($name, $parameters = null) { if (isset($this->_instances[$name])) { return $this->_instances[$name]; } if (isset($this->_definitions[$name])) { $definition = $this->_definitions[$name]; } else { return $this->getInstance($name, $parameters, $name); }
php
{ "resource": "" }
q5539
Di.getShared
train
public function getShared($name) { if (isset($this->_instances[$name])) { return $this->_instances[$name]; } if (isset($this->_definitions[$name])) { return $this->_instances[$name] = $this->getInstance($this->_definitions[$name], null, $name); } elseif (strpos($name, '\\') !== false)
php
{ "resource": "" }
q5540
Timer.reset
train
function reset(){ $tmp = $this->milliseconds(); $this->started = microtime( false );
php
{ "resource": "" }
q5541
Timer.stop
train
function stop(){ if( $this->is_running() ){ $this->stopped = microtime( false ); return $this->milliseconds(); }
php
{ "resource": "" }
q5542
Timer.is_running
train
function is_running(){ if( isset( $this->stopped ) ){ return false; } if( ! isset( $this->started ) ){ trigger_error("Timer has been stopped
php
{ "resource": "" }
q5543
Timer.milliseconds
train
function milliseconds( $dp = null ){ if( $this->is_running() ){ $now = microtime( false ); } else { $now = $this->stopped; } $started =
php
{ "resource": "" }
q5544
Timer.seconds
train
function seconds( $dp = 2 ){ $secs = $this->milliseconds() / 1000; if( !
php
{ "resource": "" }
q5545
Timer.parse_microtime
train
static function parse_microtime( $microtime ){ list($usec, $sec) = explode( ' ', $microtime ); $ms1 =
php
{ "resource": "" }
q5546
Doctrine2MetaDataDAO.getMetadataFor
train
public function getMetadataFor($entityName, array $parentName = array()) { return $this->hydrateDataObject(
php
{ "resource": "" }
q5547
PLUGCli.init
train
static function init() { switch( PHP_SAPI ) { // Ideally we want to be runnning as CLI case 'cli': break; // Special conditions to ensure CGI runs as CLI case 'cgi': // Ensure resource constants are defined if( ! defined('STDERR') ){ define( 'STDERR', fopen('php://stderr', 'w') ); } if( ! defined('STDOUT') ){ define( 'STDOUT', fopen('php://stdout', 'w') ); } break; default: echo "Command line only\n"; exit(1); } // Default error logger function PLUG::set_error_logger( array(__CLASS__,'format_logline') ); // parse command line arguments from argv global global $argv, $argc; // first cli arg is always current script. second arg will be script arg passed to shell wrapper for( $i = 1; $i < $argc; $i++ ){ $arg = $argv[ $i ]; // Each command line argument may take following forms: // 1. "Any single argument", no point parsing this unless it follows #2 below // 2. "-aBCD", one or more switches, parse into 'a'=>true, 'B'=>true, and so on // 3. "-a value", flag used with following value, parsed to 'a'=>'value' // 4. "--longoption", GNU style long option, parse into 'longoption'=>true // 5. "--longoption=value", as above, but parse into 'longoption'=>'value' // 6."any variable name = any value" $pair = explode( '=', $arg, 2 ); if( isset($pair[1]) ){ $name = trim( $pair[0] ); if( strpos($name,'--') === 0 ){ // #5. trimming "--" from option, tough luck if you only used one "-" $name = trim( $name, '-' );
php
{ "resource": "" }
q5548
PLUGCli.arg
train
final static function arg( $a, $default = null ){ if( is_int($a) ){ global $argv; // note: arg(0) will always
php
{ "resource": "" }
q5549
PLUGCli.stderr
train
final static function stderr( $s ){ if( func_num_args() > 1 ){ $args
php
{ "resource": "" }
q5550
PLUGCli.format_logline
train
static function format_logline( PLUGError $Err ){ if( PLUG::is_compiled() ){ return sprintf( '%s: %s: %s', basename(self::arg(0)), $Err->getTypeString(), $Err->getMessage() ); } else { return sprintf( '%s: %s: %s in %s#%u',
php
{ "resource": "" }
q5551
GlideServer.getLeagueGlideServer
train
public function getLeagueGlideServer() { if (null === $this->server) { $config = $this->config + [
php
{ "resource": "" }
q5552
GlideServer.url
train
public function url($path, array $params = []) { $urlBuilder = UrlBuilderFactory::create($this->config['base_url'],
php
{ "resource": "" }
q5553
InvalidLength.rise
train
public function rise(array $params, $line, $filename) { $this->message = "The length of \"" .
php
{ "resource": "" }
q5554
Issue.buildLabels
train
private function buildLabels($labels) { $collection = []; foreach ($labels as $label) { $collection[] =
php
{ "resource": "" }
q5555
Doctrine2MetaDataDAOFactory.getInstance
train
public static function getInstance() { $fileManager = new FileManager(); $serviceManager = ZendFramework2Environnement::getDependence($fileManager); $entityManager = $serviceManager->get('doctrine.entitymanager.orm_default'); if (($entityManager instanceof EntityManager) === false) { throw new \Exception( sprintf( 'Service manager return instanceof "%s" instead of "%s"',
php
{ "resource": "" }
q5556
Client.getUploadResult
train
public function getUploadResult($token) { $jwt = new Jwt(); $claims = $jwt->decode($token, false); if (!isset($claims['scope'])) { throw new AuthenticationException('scope is not exists'); } if ($claims['scope'] !== 'bos.object.create.response') { throw new AuthenticationException(['`:scope` scope is not valid',
php
{ "resource": "" }
q5557
GridExporter.passCsv
train
public function passCsv() { $csv = fopen('php://output', 'w'); //nagłówek CSV fputcsv($csv, $this->_getHeader()); //iteracja po danych
php
{ "resource": "" }
q5558
GridExporter._getHeader
train
protected function _getHeader() { $header = []; foreach ($this->_grid->getColumns() as $column) { if ($column instanceof Column\IndexColumn || $column instanceof Column\OperationColumn) { continue; }
php
{ "resource": "" }
q5559
ApplicationServiceIterator.accept
train
public function accept() { /* @var $serviceId string|object */ $serviceId = $this->current(); if (in_array($serviceId, $this->getIdsOfServicesThatAreDefinedInApplication())) {
php
{ "resource": "" }
q5560
ApplicationServiceIterator.getIdsOfServicesThatAreDefinedInApplication
train
protected function getIdsOfServicesThatAreDefinedInApplication() { if ($this->serviceIdWhitelist === null) { $builder = $this->createContainerBuilder(); $this->applyToExtensions(function (ExtensionInterface $extension) use ($builder) {
php
{ "resource": "" }
q5561
ApplicationServiceIterator.getPrefixesOfApplicationServices
train
protected function getPrefixesOfApplicationServices() { if ($this->allowedServicePrefixes === null) { $this->allowedServicePrefixes = $this->applyToExtensions(function (ExtensionInterface $extension) {
php
{ "resource": "" }
q5562
ApplicationServiceIterator.applyToExtensions
train
protected function applyToExtensions($callback) { $results = array(); foreach (new ApplicationBundleIterator($this->kernel) as $bundle) { /* @var $bundle
php
{ "resource": "" }
q5563
ApplicationServiceIterator.startsWithPrefix
train
protected function startsWithPrefix($serviceId, $allowedPrefixes) { foreach ($allowedPrefixes as $prefix) {
php
{ "resource": "" }
q5564
ApplicationServiceIterator.createContainerBuilder
train
protected function createContainerBuilder() { $builder = new ContainerBuilder(); $this->kernel->boot(); foreach ($this->kernel->getBundles() as $bundle) { // Register all extensions, otherwise there might be config parts that cannot be processed. $extension = $bundle->getContainerExtension(); if ($extension !== null) { $builder->registerExtension($extension); } } // Load the application configuration, which might affect the loaded services. /* @var $locator FileLocatorInterface */ $locator = $this->kernel->getContainer()->get('file_locator'); $loaders = array( new XmlFileLoader($builder, $locator), new YamlFileLoader($builder, $locator),
php
{ "resource": "" }
q5565
PullRequest.getCommits
train
public function getCommits() { if ('' === ini_get('user_agent')) { throw new UserAgentNotFoundException(); } if (!ini_get('allow_url_fopen')) { throw new AllowUrlFileOpenException(); } $jsonResponse = $this->getFileContent($this->getCommitsUrl(), ini_get('user_agent')); $response = json_decode($jsonResponse, true); foreach ($response as $commitArray) {
php
{ "resource": "" }
q5566
PullRequest.getFileContent
train
private function getFileContent($url, $userAgent) { $opts = [ 'http' => [ 'method' => 'GET', 'header' =>
php
{ "resource": "" }
q5567
Helper.downloadRemoteFile
train
static function downloadRemoteFile($url, $destinationFilename) { if (!ini_get('allow_url_fopen')) { throw new \Exception('allow_url_fopen is disable', 501); } $message = "File was not loaded"; if (function_exists('curl_init')) { try { $raw = file_get_contents($url); } catch (\Exception $e) { throw new \Exception($message, Consts::ERROR_CODE_BAD_REQUEST); } } else { $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
php
{ "resource": "" }
q5568
LRParseTable.lookup
train
function lookup( $state, $la ){ if( ! isset($this->table[$state][$la]) ){ return null; }
php
{ "resource": "" }
q5569
GridState._applyFilters
train
private function _applyFilters(\Mmi\Orm\Query $query) { //iteracja po filtrach foreach ($this->getFilters() as $filter) { //filtr nie jest prawidłowy if (!($filter instanceof GridStateFilter)) { throw new GridException('Invalid state filter object'); } //operator równości if ($filter->getMethod() == 'equals') { $query->andField($filter->getField(), $filter->getTableName())->equals($filter->getValue()); continue; } //podobieństwo if ($filter->getMethod() == 'like') { $query->andField($filter->getField(), $filter->getTableName())->like($filter->getValue() . '%'); continue; } //większość if ($filter->getMethod() == 'null') { if ($filter->getValue()) { $query->andField($filter->getField(), $filter->getTableName())->notEquals(null); continue; } $query->andField($filter->getField(), $filter->getTableName())->equals(null);
php
{ "resource": "" }
q5570
GridState._applyOrder
train
private function _applyOrder(\Mmi\Orm\Query $query) { $orders = $this->getOrder(); //resetowanie domyślnego orderu jeśli podany if (!empty($orders)) { $query->resetOrder(); } //iteracja po orderze
php
{ "resource": "" }
q5571
File.isGoodFile
train
public function isGoodFile(Config $source) { $info = pathinfo($this->path); if (!isset($info['extension']) or (!in_array(strtolower($info['extension']), $source->extensions))) { return false;
php
{ "resource": "" }
q5572
File.isImage
train
public function isImage() { try { if (!function_exists('exif_imagetype') && !function_exists('Jodit\exif_imagetype')) { function exif_imagetype($filename) { if ((list(, , $type) = getimagesize($filename)) !== false) { return $type; } return false; } }
php
{ "resource": "" }
q5573
DbController.listCommand
train
public function listCommand($services = [], $table_pattern = '') { foreach ($services ?: $this->_getDbServices() as $service) { /** @var \ManaPHP\DbInterface $db */ $db = $this->_di->getShared($service); $this->console->writeLn(['service: `:service`', 'service' => $service], Console::FC_CYAN); foreach ($this->_getTables($service, $table_pattern) as $row => $table) { $columns = (array)$db->getMetadata($table)[Db::METADATA_ATTRIBUTES]; $primaryKey = $db->getMetadata($table)[Db::METADATA_PRIMARY_KEY]; foreach ($columns as $i => $column) { if (in_array($column, $primaryKey, true)) {
php
{ "resource": "" }
q5574
DbController.modelCommand
train
public function modelCommand($table, $service = '', $namespace = 'App\Models', $optimized = false) { if (strpos($namespace, '\\') === false) { $namespace = 'App\\' . ucfirst($namespace) . '\\Models'; } /** @var \ManaPHP\DbInterface $db */ if ($service) { $db = $this->_di->getShared($service); if (!in_array($table, $db->getTables(), true)) { throw new Exception(['`:table` is not exists', 'table' => $table]); } } else { foreach ($this->_getDbServices() as $s) { $db = $this->_di->getShared($s); if (in_array($table, $db->getTables(), true)) { $service = $s; break; } } if (!$service) {
php
{ "resource": "" }
q5575
DbController.modelsCommand
train
public function modelsCommand($services = [], $table_pattern = '', $namespace = 'App\Models', $optimized = false) { if (strpos($namespace, '\\') === false) { $namespace = 'App\\' . ucfirst($namespace) . '\\Models'; } foreach ($services ?: $this->_getDbServices() as $service) { foreach ($this->_getTables($service, $table_pattern) as $table) { $this->console->progress(['`:table` processing...', 'table' => $table], ''); $plainClass = Text::camelize($table); $fileName = "@tmp/db_models/$plainClass.php";
php
{ "resource": "" }
q5576
AnnotationDriver.isMetadataFullyLoaded
train
private function isMetadataFullyLoaded(array $metadata) { return $metadata[ClassMetadata::LOGIN_PROPERTY] && $metadata[ClassMetadata::PASSWORD_PROPERTY]
php
{ "resource": "" }
q5577
Navigation.decorateConfiguration
train
public function decorateConfiguration(\Mmi\Navigation\NavigationConfig $config) { $objectArray = (new CmsCategoryQuery) ->lang() ->andFieldStatus()->equals(\Cms\Orm\CmsCategoryRecord::STATUS_ACTIVE) ->orderAscParentId() ->orderAscOrder() ->find() ->toObjectArray(); foreach ($objectArray as $key => $record) {/* @var $record CmsCategoryRecord */ if ($record->parentId != 0) { continue; }
php
{ "resource": "" }
q5578
Navigation._setNavigationElementFromRecord
train
protected function _setNavigationElementFromRecord(CmsCategoryRecord $record, \Mmi\Navigation\NavigationConfigElement $element) { $params = []; parse_str($record->mvcParams, $params); $params['uri'] = $record->customUri ? $record->customUri : $record->uri; $config = $record->getConfig(); $config->typeId = $record->cmsCategoryTypeId; $config->categoryId = $record->id; $element ->setModule('cms') ->setController('category')
php
{ "resource": "" }
q5579
Tube.render
train
public function render(array $options = array()) { $url = $this->service->generateEmbedUrl($this); $options = array_replace(array( 'width' => 560, 'height' => 315, 'frameborder' => 0, 'allowfullscreen' => ''
php
{ "resource": "" }
q5580
Cron.run
train
public static function run() { foreach (Orm\CmsCronQuery::active()->find() as $cron) { if (!self::_getToExecute($cron)) { continue; } $output = ''; try { $start = microtime(true); $output = \Mmi\Mvc\ActionHelper::getInstance()->action(new \Mmi\Http\Request(['module' => $cron->module, 'controller' => $cron->controller, 'action' => $cron->action])); $elapsed = round(microtime(true) - $start, 2);
php
{ "resource": "" }
q5581
Cron._getToExecute
train
protected static function _getToExecute($record) { return self::_valueMatch(date('i'), $record->minute) && self::_valueMatch(date('H'), $record->hour) && self::_valueMatch(date('d'), $record->dayOfMonth) &&
php
{ "resource": "" }
q5582
GroupController.indexAction
train
public function indexAction() { $oid = new ObjectIdentity('class', 'FOM\UserBundle\Entity\Group'); $query = $this->getDoctrine()->getManager()->createQuery('SELECT g FROM FOMUserBundle:Group g'); $groups = $query->getResult(); $allowed_groups = array(); // ACL access check foreach($groups as $index => $group) {
php
{ "resource": "" }
q5583
OracleMetaDataDAOFactory.getInstance
train
public static function getInstance(DriverConfig $config) { $pdoDriver = PdoDriverFactory::getInstance();
php
{ "resource": "" }
q5584
Config.getSource
train
public function getSource($sourceName = null) { if ($sourceName === 'default') { $sourceName = null; } foreach ($this->sources as $key => $item) { if ((!$sourceName || $sourceName === $key)) { return $item; }
php
{ "resource": "" }
q5585
SetupHelper.getRootFolder
train
public static function getRootFolder() { $filesystem = new Filesystem(); $folder = $filesystem->normalizePath(__DIR__ . '/../'); if (! is_dir($folder)) { throw new RuntimeException( sprintf(
php
{ "resource": "" }
q5586
SetupHelper.getFile
train
public static function getFile($fileName) { $filesystem = new Filesystem(); $file = $filesystem->normalizePath(__DIR__ . '/../' . $fileName); if (! file_exists($file)) { throw new RuntimeException( sprintf(
php
{ "resource": "" }
q5587
ServiceCreator.create
train
public function create($serviceId) { try { return $this->container->get($serviceId, Container::NULL_ON_INVALID_REFERENCE); } catch (\Exception $e) { if ($this->isCausedBySyntheticServiceRequest($e)) { // Ignore errors that are caused by synthetic services. It is simply not
php
{ "resource": "" }
q5588
ServiceCreator.isCausedBySyntheticServiceRequest
train
protected function isCausedBySyntheticServiceRequest(\Exception $exception) { if (!($exception instanceof RuntimeException)) {
php
{ "resource": "" }
q5589
Router._addRoute
train
protected function _addRoute($pattern, $paths = null, $method = null) { $route = new Route($pattern, $paths, $method); if ($method !== 'REST' && strpos($pattern, '{') === false) {
php
{ "resource": "" }
q5590
Router.add
train
public function add($pattern, $paths = null, $method =
php
{ "resource": "" }
q5591
ApiKeyAuthenticator.authenticateToken
train
public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey) { $apiKey = $token->getCredentials(); $user = $this ->om ->getRepository($this->modelName) ->findOneBy(array($this->metadata->getPropertyName(ClassMetadata::API_KEY_PROPERTY) => (string) $apiKey)); if (!$user) { $this->dispatcher->dispatch(Ma27ApiKeyAuthenticationEvents::FIREWALL_FAILURE, new OnFirewallFailureEvent()); throw new AuthenticationException( sprintf('API key %s does not exist!', $apiKey) ); } $token
php
{ "resource": "" }
q5592
ApiKeyAuthenticator.createToken
train
public function createToken(Request $request, $providerKey) { $apiKey = $request->headers->get($this->header); if (!$apiKey) { throw new BadCredentialsException('No ApiKey found in request!'); }
php
{ "resource": "" }
q5593
ViewFactory.getInstance
train
public static function getInstance() { $classAwake = new ClassAwake(); $viewHelpers = $classAwake->wakeByInterfaces( array( __DIR__,
php
{ "resource": "" }
q5594
AttributeController.deleteAttributeRelationAction
train
public function deleteAttributeRelationAction() { //wyszukiwanie rekordu relacji $record = (new \Cms\Orm\CmsAttributeRelationQuery) ->whereObjectId()->equals($this->id) ->findPk($this->relationId); //jeśli znaleziono rekord if ($record && $record->delete()) { //wyszukiwanie stron w zmienionym szablonie foreach ((new \Cms\Orm\CmsCategoryQuery)->whereCmsCategoryTypeId() ->equals($this->id) ->findPairs('id', 'id') as $categoryId) { //usuwanie wartości usuniętych
php
{ "resource": "" }
q5595
Validator.verify
train
public function verify($data, array $callbacks = [], $cast = '') { if (empty($callbacks) === true) { return $this->fields[$cast] = $data; } // Create a Closure $isValid = function ($data) use
php
{ "resource": "" }
q5596
Validator.setLength
train
public function setLength(array $condition) { if (is_array($condition) === true) { $this->{key($condition)} =
php
{ "resource": "" }
q5597
Validator.isNotNull
train
protected function isNotNull($value) { if (is_null($value) === true || empty($value) ===
php
{ "resource": "" }
q5598
Validator.isAcceptLength
train
protected function isAcceptLength($value) { $value = strlen(utf8_decode($value)); if ($value < $this->min) { throw new ExceptionFactory('InvalidLength', [$value, 'greater',
php
{ "resource": "" }
q5599
Validator.isExists
train
protected function isExists(array $value) { // validate fields by exist in tables foreach ($value as $table => $fields) { // load model metaData if ($this->isModel($table) === true) { $model = (new Manager())->load($table, new $table); // check fields of table $this->validColumns($model->getModelsMetaData(), $fields, $table, $model); // setup clear used tables $columnDefines = (new $table)->getReadConnection()->describeColumns($model->getSource()); // add using tables with model alias $this->fields['tables'][$model->getSource()] = $table;
php
{ "resource": "" }