_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q28200
PageComponent.doFormAction
train
protected function doFormAction () { // if (count ($_POST) == 0 && count ($_FILES) == 0) // throw new FileException(FileException::FILE_TOO_BIG, ini_get ('upload_max_filesize')); $this->getActionAndParam ($action, $param); $class = new ReflectionObject ($this); try { $method = $class->getMet...
php
{ "resource": "" }
q28201
OpauthLoginForm.defineStrategyHandlers
train
protected function defineStrategyHandlers() { if(!$this->_strategiesDefined) { foreach($this->getStrategies() as $strategyClass) { $strategyMethod = 'handleStrategy' . $strategyClass; $this->addWrapperMethod($strategyMethod, 'handleStrategy'); } $this->_strategiesDefined = true; } }
php
{ "resource": "" }
q28202
OpauthLoginForm.getActions
train
protected function getActions() { $actions = new FieldList(); foreach($this->getStrategies() as $strategyClass) { $strategyMethod = 'handleStrategy' . $strategyClass; $fa = new FormAction($strategyMethod, $strategyClass); $fa->setUseButtonTag(true); $actions->push($fa); } return $actions; }
php
{ "resource": "" }
q28203
OpauthLoginForm.handleStrategy
train
public function handleStrategy($funcName, $data, $form, $request) { if(func_num_args() < 4) { throw new LogicException('Must be called with a strategy handler'); } // Trim handleStrategy from the function name: $strategy = substr($funcName, strlen('handleStrategy')) . 'Strategy'; // Check the strategy is ...
php
{ "resource": "" }
q28204
ResponseContextAbstract.setContent
train
public function setContent(string $content = null): ResponseContextAbstract { if (is_null($content)) { return $this; } $this->assertIsValid($content); $this->content = $content; return $this; }
php
{ "resource": "" }
q28205
ResponseContextAbstract.hasHttpError
train
public function hasHttpError(): bool { $httpStatus = new NanoHttpStatus(); return $httpStatus->isClientError($this->httpStatusCode) || $httpStatus->isServerError($this->httpStatusCode); }
php
{ "resource": "" }
q28206
ResponseContextAbstract.getByType
train
public static function getByType(string $type, string $content = null): ResponseContextAbstract { switch ($type) { case self::RESPONSE_TYPE_JSON: return new JsonResponseContext($content); default: return new DummyResponseContext($content); } ...
php
{ "resource": "" }
q28207
Collection.getUniqueReference
train
public function getUniqueReference() { if ($this->uniqueReference === null) { $modelName = basename(str_replace("\\", "/", $this->getModelClassName())); if (!isset(self::$uniqueReferencesUsed[$modelName])) { self::$uniqueReferencesUsed[$modelName] = 0; } ...
php
{ "resource": "" }
q28208
Collection.getRepository
train
public function getRepository() { $emptyObject = SolutionSchema::getModel($this->modelClassName); $repository = $emptyObject->getRepository(); return $repository; }
php
{ "resource": "" }
q28209
Collection.addSort
train
final public function addSort($columnName, $ascending = true) { $parts = explode(".", $columnName); $sort = new Sort(); if (count($parts) > 1) { $columnName = $parts[count($parts) - 1]; $relationships = array_slice($parts, 0, count($parts) - 1); $newCol...
php
{ "resource": "" }
q28210
Collection.replaceSort
train
final public function replaceSort($columnName, $ascending = true) { if (!is_array($columnName)) { $sorts = [$columnName => $ascending]; } else { $sorts = $columnName; } $this->sorts = []; foreach ($sorts as $index => $value) { $this->addS...
php
{ "resource": "" }
q28211
Collection.append
train
public function append(Model $model) { $result = null; // If the list was filtered make sure that value is set on the model. if ($this->filter !== null) { $result = $this->filter->setFilterValuesOnModel($model); } $model->save(); // Make sure the list is ...
php
{ "resource": "" }
q28212
Collection.intersectWith
train
final public function intersectWith(Collection $collection, $sourceColumnName, $targetColumnName, $columnsToPullUp = [], $autoHydrate = false) { $collection->isIntersection = true; $collectionJoin = new CollectionJoin($collection, $sourceColumnName, $targetColumnName, $columnsToPullUp, $autoHydrate,...
php
{ "resource": "" }
q28213
Collection.joinWith
train
public function joinWith(Collection $collection, $sourceColumnName, $targetColumnName, $columnsToPullUp = [], $autoHydrate = false) { $collectionJoin = new CollectionJoin($collection, $sourceColumnName, $targetColumnName, $columnsToPullUp, $autoHydrate, CollectionJoin::JOIN_TYPE_ATTACH); $this->inte...
php
{ "resource": "" }
q28214
Collection.addAggregateColumn
train
final public function addAggregateColumn(Aggregate $aggregate) { $parts = explode(".", $aggregate->getAggregateColumnName()); if (count($parts) > 1) { $columnName = $parts[count($parts) - 1]; $relationships = array_slice($parts, 0, count($parts) - 1); $aggregat...
php
{ "resource": "" }
q28215
Collection.batchUpdate
train
public function batchUpdate($propertyPairs, $fallBackToIteration = false) { try { if ($this instanceof RepositoryCollection) { $this->getRepository()->batchCommitUpdatesFromCollection($this, $propertyPairs); } else { throw new BatchUpdateNotPossibleExc...
php
{ "resource": "" }
q28216
Collection.filter
train
public function filter(...$filters) { if (sizeof($filters) == 0) { return $this; } $andGroup = new AndGroup(); if (is_array($filters[0])) { $filters = $filters[0]; } foreach ($filters as $filter) { if (!($filter instanceof Filter...
php
{ "resource": "" }
q28217
Collection.setRange
train
public function setRange($startIndex, $maxItems) { $changed = false; if (sizeof($this->sorts) == 0) { $this->addSort(SolutionSchema::getModelSchema($this->getModelClassName())->uniqueIdentifierColumnName); } if ($this->rangeStartIndex != $startIndex) { $this-...
php
{ "resource": "" }
q28218
Collection.getGroupKeyForModel
train
private function getGroupKeyForModel(Model $model) { $key = ""; foreach ($this->groups as $group) { $key .= $model[$group] . "|"; } return $key; }
php
{ "resource": "" }
q28219
Collection.processAggregates
train
private function processAggregates($aggregates) { // Step 1. Calculate the aggregate group values. foreach ($this->collectionCursor as $model) { foreach ($aggregates as $aggregate) { $aggregate->calculateByIteration($model, $this->getGroupKeyForModel($model)); ...
php
{ "resource": "" }
q28220
Collection.findModelByUniqueIdentifier
train
public function findModelByUniqueIdentifier($identifier) { $this->filter(new Equals($this->getModelSchema()->uniqueIdentifierColumnName, $identifier)); return $this[0]; }
php
{ "resource": "" }
q28221
Collection.filterCursor
train
private function filterCursor($postAggregates = false) { $filter = $this->getFilter(); if ($filter) { if ($filter->requiresAggregation($this) && !$postAggregates) { return; } if (!$filter->requiresAggregation($this) && $postAggregates) { ...
php
{ "resource": "" }
q28222
Collection.reduceCursorForGroups
train
private function reduceCursorForGroups() { $reduceForGroups = $groupKeys = []; $index = 0; foreach ($this->collectionCursor as $model) { $groupKey = $this->getGroupKeyForModel($model); if ($groupKey != '') { if (!in_array($groupKey, $groupKeys)) { ...
php
{ "resource": "" }
q28223
SqlStatement.addWhereExpression
train
public function addWhereExpression(WhereExpression $where) { if (!($this->whereExpression instanceof AndExpression)){ $this->whereExpression = new AndExpression($this->whereExpression); } /** * @var AndExpression $andExpression */ $andExpression = $this...
php
{ "resource": "" }
q28224
SqlStatement.implodeSqlClauses
train
public function implodeSqlClauses($clauses, $glue = ',') { $statements = []; foreach($clauses as $clause){ $statements[] = $clause->getSql($this); } return implode($statements, $glue); }
php
{ "resource": "" }
q28225
SqlStatement.getUpdateSql
train
public function getUpdateSql($fieldsToUpdate) { $sql = "UPDATE `".$this->schemaName."` AS `".$this->getAlias()."`"; foreach($this->joins as $join){ $sql .= " ".$join->joinType." (".$join->getSql($this).") AS `".$join->statement->getAlias()."` ON `".$this->getAlias()."`.`". ...
php
{ "resource": "" }
q28226
SqlStatement.getSelectSql
train
public function getSelectSql() { $sql = "SELECT "; $sql .= $this->implodeSqlClauses($this->columns, ", "). " FROM `".$this->schemaName."` AS `".$this->getAlias()."`"; foreach($this->joins as $join){ $joinsSql = $join->getSql($this); if (strpos($joinsSql,...
php
{ "resource": "" }
q28227
FeedController.generateAction
train
public function generateAction($context, $lang, $id) { /** @var Request $request */ $request = $this->getRequest(); // context if ("" === $context){ $context = "catalog"; } else if (! in_array($context, array("catalog", "content", "brand")) ){ $this-...
php
{ "resource": "" }
q28228
FeedController.getCacheDir
train
protected function getCacheDir() { $cacheDir = $this->container->getParameter("kernel.cache_dir"); $cacheDir = rtrim($cacheDir, '/'); $cacheDir .= '/' . self::FEED_CACHE_DIR . '/'; return $cacheDir; }
php
{ "resource": "" }
q28229
FeedController.checkId
train
private function checkId($context, $id) { $ret = false; if (is_numeric($id)){ if ("catalog" === $context){ $cat = CategoryQuery::create()->findPk($id); $ret = (null !== $cat && $cat->getVisible()); } elseif ("brand" === $context) { ...
php
{ "resource": "" }
q28230
CustomFieldsValuesTrait.customFieldValue
train
public function customFieldValue($key) { $value = null; if($this->hasCustomField($key)) { //if translate is enabled in a specific language if(isset($this->customFields->$key->{$this->getTranslateLanguage()})) { $value = $this->customFields->$key->{$this->getTr...
php
{ "resource": "" }
q28231
CustomFieldsValuesTrait.hasCustomField
train
public function hasCustomField($key) { if($key !== 'customFields' && !array_key_exists($key, $this->getAttributes())) { if(isset($this->customFields->$key)) { return true; } } return false; }
php
{ "resource": "" }
q28232
CustomFieldsValuesTrait.getMediaFromCustomFields
train
public function getMediaFromCustomFields($customFields, ...$slugs) { $mediaIDs = []; foreach($customFields as $fields){ foreach($fields as $field => $value){ if(in_array($field, $slugs)) { if(!is_array($value)) { $mediaIDs[] = $...
php
{ "resource": "" }
q28233
Primary.interpolate
train
protected function interpolate(array $variables = array()) { $template = $this->logFormat; if (!isset($variables['context'])) { $variables['context'] = ''; } $this->reverseJsonInContext($variables['context']); if (!$variables['context']) { $t...
php
{ "resource": "" }
q28234
Primary.normalizeLevel
train
protected function normalizeLevel($level) { if (is_int($level) && array_search($level, self::$levels) !== false) { return $level; } if (is_string($level) && isset(self::$levels[$level])) { return self::$levels[$level]; } throw new Exception...
php
{ "resource": "" }
q28235
Registry.addClass
train
protected function addClass(string $class) { if ($this->initialized) { throw new RuntimeException("You can't register provider class as registry as been initialized."); } if (!class_exists($class)) { throw new InvalidArgumentException("Class $class does not exist.");...
php
{ "resource": "" }
q28236
Registry.initialize
train
protected function initialize() { if ($this->initialized) { return; } foreach ($this->classes as $class) { $this->providers[] = new $class; } foreach ($this->providers as $provider) { if ($provider instanceof BuilderAwareInterface) { ...
php
{ "resource": "" }
q28237
UriParameters.replace
train
public static function replace($uri, $parameters = []) { $parameters = (array) $parameters; $uri = static::replaceRouteParameters($uri, $parameters); $uri = str_replace('//', '/', $uri); return $uri; }
php
{ "resource": "" }
q28238
BootEventsTrait.bootBootEventsTrait
train
protected static function bootBootEventsTrait() { $explode = explode('\\', get_class()); $modelName = lcfirst(str_replace('Model', '', end($explode))); self::saving( function ($album) use ($modelName) { Event::fire($modelName.':saving', [$album]); } ...
php
{ "resource": "" }
q28239
FileSystem.createFolderIfNotExists
train
private function createFolderIfNotExists($cache_path) { if (!is_dir($cache_path)) { if (false === @mkdir($cache_path, 0777 & (~$this->umask), true) && !is_dir($cache_path)) { return false; } } return true; }
php
{ "resource": "" }
q28240
FileSystem.deleteCacheSubfoldersIfEmpty
train
private function deleteCacheSubfoldersIfEmpty($filepath) { if ($this->cache_path == $filepath) { // Do not delete main cache folder itself. return true; } $filepath_exp = explode(DIRECTORY_SEPARATOR, $filepath); if (is_array($filepath_exp)) { for ...
php
{ "resource": "" }
q28241
FileSystem.deleteCacheSubfolderRecursively
train
private function deleteCacheSubfolderRecursively($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($dir . DIRECTORY_SEPARATOR . $object == $this->cache_path) { return false; } elseif ($object ...
php
{ "resource": "" }
q28242
SyncCommand.getPath
train
private function getPath() { if (($path = $this->config['path']) instanceof \Closure) { $this->line('Generating dynamic download path.'); $this->line(''); if (is_numeric($path = $path($this))) { exit($path); } $this->line(''); ...
php
{ "resource": "" }
q28243
SyncCommand.downloadPath
train
private function downloadPath($path) { $this->info(sprintf('Downloading \'%s\'...', $path)); $this->line(''); // Get the file from FTP path if (stripos($path, 'ftp://') !== false) { return file_get_contents($path); } $client = new GuzzleClient(); ...
php
{ "resource": "" }
q28244
SyncCommand.readData
train
private function readData($data) { $this->line('Processing...'); $this->line(''); $reader = Reader::createFromString($data); // Apply any filters. if (array_has($this->config, 'filter')) { $reader = $this->config['filter']($reader); } if (!array...
php
{ "resource": "" }
q28245
SyncCommand.translateRow
train
private function translateRow(&$row) { $new_row = []; // Translate incoming data via mapping array. foreach ($row as $key => $value) { if (array_has($this->config['mapping'], $key)) { $new_row[array_get($this->config['mapping'], $key)] = $value; } ...
php
{ "resource": "" }
q28246
SyncCommand.transformRow
train
private function transformRow(&$row) { // Check modify for any specific key manipulations. if (array_has($this->config, 'modify')) { foreach ($row as $key => &$value) { if (array_has($this->config['modify'], $key)) { $this->config['modify'][$key]($valu...
php
{ "resource": "" }
q28247
SyncCommand.importData
train
private function importData($data) { $this->line(sprintf('Importing %s records...', count($data))); $this->line(''); $this->progress_bar = $this->output->createProgressBar(count($data)); foreach ($data as $row) { $this->processImportRow($row); } $this->...
php
{ "resource": "" }
q28248
SyncCommand.processImportRow
train
private function processImportRow(&$row) { // Get the model to represent this row. $model = $this->lookupModel($row); // Assign values to the model. foreach ($row as $key => $value) { if (empty($model->getKey()) || $model->$key !== $value) { $model->$key ...
php
{ "resource": "" }
q28249
SyncCommand.lookupModel
train
private function lookupModel(&$row) { $query = new ImportModel(); // Set the connection and table. $query->setConnection($this->connection($this->argument('dataset'))); $query->setTable(sprintf('data_%s', array_get($this->config, 'table'))); $count_keys = 0; foreac...
php
{ "resource": "" }
q28250
OutputStyles.block
train
public function block($messages, $type = 'error') { $output = []; if (!is_array($messages)) { $messages = (array) $messages; } foreach ($messages as $message) { $output[] = trim($message); } $formatter = new FormatterHelper(); $this->li...
php
{ "resource": "" }
q28251
Socket.connect
train
public function connect($addr = null, $port = null, $timeout = null) { if ($port == null && $timeout == null) { if ($addr !== null) { $timeout = $addr; } else { $timeout = 0; } if ($this->addr == null || $this->port == null) { ...
php
{ "resource": "" }
q28252
Socket.setBlocking
train
public function setBlocking($blocking) { if ($this->blocking == $blocking) { return; } if ($blocking) { if (@socket_set_block($this->socket) === false) { $this->throwSocketError(); } $this->blocking = true; } else { ...
php
{ "resource": "" }
q28253
ViewableTrait.render
train
public function render($templateIdent = null) { if ($templateIdent === null) { $templateIdent = $this->templateIdent(); } return $this->view()->render($templateIdent, $this->viewController()); }
php
{ "resource": "" }
q28254
ViewableTrait.setViewController
train
public function setViewController($controller) { if (is_scalar($controller) || is_resource($controller)) { throw new InvalidArgumentException( 'View controller must be an object, null or an array' ); } $this->viewController = $controller; ret...
php
{ "resource": "" }
q28255
Browser.createTemporaryFiles
train
protected function createTemporaryFiles($files) { foreach($files as $file) { if(is_array($file)) $this->createTemporaryFiles($file); else { do { $dst = sys_get_temp_dir().uniqid().'.tmp'; if(!file_exists($dst)) break; } while(true); copy($file->src(), $dst); $file->setSrc($ds...
php
{ "resource": "" }
q28256
Block.setPlaceHolder
train
public function setPlaceHolder(PlaceHolder $placeHolder) { $this->placeHolder = $placeHolder; $this->placeHolder->addBlock($this); }
php
{ "resource": "" }
q28257
Block.factory
train
public static function factory(Localization $base, Block $source = null) { $block = null; switch ($base::DISCRIMINATOR) { case self::TEMPLATE_DISCR: $block = new TemplateBlock(); break; case self::PAGE_DISCR: case self::APPLICATION_DISCR: $block = new PageBlock(); break; default: t...
php
{ "resource": "" }
q28258
ModelLoginProvider.forceLogin
train
public function forceLogin(Model $user = null) { // The model parameter must be optional to comply with PHP Strict Mode method override rules and as the model // is actually required, this ensures that it is provided if ($user === null) { throw new ImplementationException('A mode...
php
{ "resource": "" }
q28259
ModelLoginProvider.getModel
train
public function getModel() { if (!$this->isLoggedIn()) { throw new NotLoggedInException(); } if (isset($this->loggedInUserIdentifier)) { try { return SolutionSchema::getModel($this->modelClassName, $this->loggedInUserIdentifier); } catch (...
php
{ "resource": "" }
q28260
MinistryPlatformTableAPI.getSingle
train
public function getSingle() { // Set the endpoint $endpoint = $this->buildEndpoint(); // Set the header $this->buildHttpHeader(); // Send the request $client = new Client(); //GuzzleHttp\Client try { $response = $client->request('GET', $endpoint...
php
{ "resource": "" }
q28261
MinistryPlatformTableAPI.put
train
public function put() { $parameters = [ 'headers' => $this->buildHttpHeader(), 'query' => ['$select' => $this->select], 'body' => $this->postFields, 'curl' => $this->setPostCurlopts(), ]; $results = $this->sendData('PUT', $parameters); ...
php
{ "resource": "" }
q28262
MinistryPlatformTableAPI.delete
train
public function delete($id) { // Set the endpoint $endpoint = $this->buildEndpoint(); $endpoint .= '/' . $id; // Set the header $this->buildHttpHeader(); // Send the request $client = new Client(); //GuzzleHttp\Client try { $response =...
php
{ "resource": "" }
q28263
MinistryPlatformTableAPI.buildEndpoint
train
protected function buildEndpoint() { $endpoint = $this->authorization->apiEndpoint . '/tables/' . $this->tableName . '/'; // If there is a specific record ID, append that to the endpoint if ($this->recordID) { $endpoint .= $this->recordID; } return $endpoint; }
php
{ "resource": "" }
q28264
MinistryPlatformTableAPI.reset
train
private function reset() { $this->tableName = null; $this->select = '*'; $this->filter = null; $this->orderby = null; $this->skip = 0; $this->groupby = null; $this->having = null; $this->top = null; $this->distinct = null; $this->recor...
php
{ "resource": "" }
q28265
File.close
train
protected function close() { if (is_resource($this->stream)) { $this->flush(); fclose($this->stream); } $this->stream = false; }
php
{ "resource": "" }
q28266
DoctrineSelectOrder.applyToQueryBuilder
train
public function applyToQueryBuilder(QueryBuilder $qb, &$parameterOffset = 0) { $orderRules = $this->orderRules; foreach ($orderRules as $orderRule) { $field = $orderRule[self::FIELD_POS]; switch ($field) { case self::LEFT_FIELD: case self::RIGHT_FIELD: case self::LEVEL_FIELD: break; defa...
php
{ "resource": "" }
q28267
Renderer.renderContainer
train
public function renderContainer($container, $type = null, array $data = []) { if (is_string($container)) { if (null === $element = $this->editor->getRepository()->findContainerByName($container)) { $this->persist($element = $this->editor->getContainerManager()->create($container,...
php
{ "resource": "" }
q28268
Renderer.renderRow
train
public function renderRow($row, array $data = []) { if (is_string($row)) { if (null === $element = $this->editor->getRepository()->findRowByName($row)) { $this->persist($element = $this->editor->getRowManager()->create($row, $data)); } $row = $element; ...
php
{ "resource": "" }
q28269
Renderer.renderBlock
train
public function renderBlock($block, $type = null, array $data = []) { if (is_string($block)) { if (null === $element = $this->editor->getRepository()->findBlockByName($block)) { $this->persist($element = $this->editor->getBlockManager()->create($block, $type, $data)); ...
php
{ "resource": "" }
q28270
Renderer.persist
train
private function persist($element) { $this->manager->persist($element); /** @noinspection PhpMethodParametersCountMismatchInspection */ $this->manager->flush($element); }
php
{ "resource": "" }
q28271
LocaleUtils.formatLocale
train
public static function formatLocale($locale) { if (\is_string($locale)) { $locale = strtolower($locale); $locale = str_replace('-', '_', $locale); } return $locale; }
php
{ "resource": "" }
q28272
ScopeCollection.findByKey
train
private function findByKey(string $scopeKey): Scope { $locales = $this->config->get('locales'); $locales = array_merge($locales['*'], $locales[$scopeKey]); // We flip our values so in case of duplicate locales, the default one // is omitted and the one from the specific scope is pr...
php
{ "resource": "" }
q28273
BlackWhiteListCheck.checkList
train
protected function checkList($item) { $inList = in_array($item, $this->list); $allow = null; if ($this->mode == self::MODE_BLACKLIST) { $allow = ! $inList; } else { $allow = $inList; } return $allow; }
php
{ "resource": "" }
q28274
HttpKernel.processRaw
train
protected function processRaw(Request $request) { $resolver = $this->getResolver(); $resolver->sortRoutes(); $route = $resolver->getRoute($request); if($route) { $request->setRoute($route); $controllerClass = $route->getController(); $action = $route->getAction(); $controller = new $controllerCla...
php
{ "resource": "" }
q28275
HttpKernel.getExceptionResponse
train
protected function getExceptionResponse($e) { while(ob_get_level() > $this->startObLevel) ob_end_clean(); $this->errorHandler->exceptionHandler($e); $trace = $this->errorHandler->getBacktraceFromException($e); if($e instanceof \Asgard\Debug\PSRException) $msg = $e->getMessage(); elseif($e instanceof ...
php
{ "resource": "" }
q28276
HttpKernel.executeStart
train
protected function executeStart(Request $request, Controller $controller=null) { if($this->start === null) return; $container = $this->container; if(($response = include $this->start) !== 1) return $response; }
php
{ "resource": "" }
q28277
ImageResizer.calculateDimensions
train
protected function calculateDimensions($originalWidth, $originalHeight) { // check if target size is set and valid if (empty($this->targetWidth) || ($this->targetWidth <= 0)) { throw new ImageProcessorException('Target width is not set or is invalid'); } if (empty($this->targetHeight) || ($this->targetHeigh...
php
{ "resource": "" }
q28278
ImageResizer.getExpectedSize
train
public function getExpectedSize($round = true) { if (empty($this->sourceFilename)) { throw new ImageProcessorException('Source image is not set'); } if (empty($this->targetWidth) || ($this->targetWidth <= 0)) { throw new ImageProcessorException('Target width is not set or is invalid'); } if (empty($thi...
php
{ "resource": "" }
q28279
GroupPage.getLocalization
train
public function getLocalization($locale) { $localization = parent::getLocalization($locale); // Create fake localization if not persisted if (is_null($localization)) { $localization = $this->createLocalization($locale); } return $localization; }
php
{ "resource": "" }
q28280
GroupPage.persistLocalization
train
public function persistLocalization(GroupLocalization $localization) { if ( ! $localization->isPersistent()) { // Reset ID because for not persisted object it is equal with master ID $localization->regenerateId(); $this->setLocalization($localization); $localization->setPersistent(); } }
php
{ "resource": "" }
q28281
MenuRepository.findForProvider
train
public function findForProvider() { $qb = $this->createQueryBuilder('m'); $qb ->select( 'm.id, IDENTITY(m.parent) as parent, m.name, m.route, m.parameters, m.root, '. 'm.attributes, m.options, t.title, t.path' ) ->leftJoin('m.transl...
php
{ "resource": "" }
q28282
Repository.findSiblingContainer
train
public function findSiblingContainer(EM\ContainerInterface $container, $next = false) { if (null === $content = $container->getContent()) { return null; } return $this->findSibling($content->getContainers(), $container, $next); }
php
{ "resource": "" }
q28283
Repository.findSiblingRow
train
public function findSiblingRow(EM\RowInterface $row, $next = false) { if (null === $container = $row->getContainer()) { return null; } return $this->findSibling($container->getRows(), $row, $next); }
php
{ "resource": "" }
q28284
Repository.findSiblingBlock
train
public function findSiblingBlock(EM\BlockInterface $block, $next = false) { if (null === $row = $block->getRow()) { return null; } return $this->findSibling($row->getBlocks(), $block, $next); }
php
{ "resource": "" }
q28285
Repository.findSibling
train
private function findSibling(Collection $elements, SortableInterface $current, $next = false) { if ($next) { $sibling = $elements->filter(function (SortableInterface $s) use ($current) { return $s->getPosition() > $current->getPosition(); })->first(); } else {...
php
{ "resource": "" }
q28286
DOMUtil.addClass
train
static public function addClass(\DOMElement $element, $classes) { if (!is_array($classes)) { $classes = [$classes]; } $c = explode(' ', (string)$element->getAttribute('class')); foreach ($classes as $n) { if (empty($n)) { continue; ...
php
{ "resource": "" }
q28287
DOMUtil.addStyle
train
static public function addStyle(\DOMElement $element, $property, $value) { $s = static::explodeStyles((string)$element->getAttribute('style')); $s[$property] = $value; $element->setAttribute('style', static::implodeStyles($s)); }
php
{ "resource": "" }
q28288
DOMUtil.explodeStyles
train
static public function explodeStyles($styles) { $a = []; $s = explode(';', $styles); foreach ($s as $c) { if (empty($c)) continue; list($p, $v) = explode(':', $c); $a[$p] = $v; } return $a; }
php
{ "resource": "" }
q28289
DOMUtil.implodeStyles
train
static public function implodeStyles(array $styles) { $a = []; foreach ($styles as $p => $v) { $a[] = "$p:$v"; } return implode(';', $a); }
php
{ "resource": "" }
q28290
LocaleUrl.to
train
public function to($url, $locale = null, $parameters = [], $secure = null) { if (is_bool($secure)) { $this->urlparser->secure($secure); } elseif ($this->forceSecure) { $this->urlparser->secure(); } return $this->urlparser->set($url) ->localize($th...
php
{ "resource": "" }
q28291
PermissionTrait.exists
train
public static function exists($app = 'global', $key) { return ((new static())->where('app', $app)->where('key', $key)->where('value', true)->count() ? true : false); }
php
{ "resource": "" }
q28292
PermissionTrait.createGlobalPermissions
train
public static function createGlobalPermissions($globalPermissions, $id) { $query = []; if ($globalPermissions) { // Create global permissions foreach ($globalPermissions as $globalPermissionKey => $globalPermissionValue){ if($globalPermissionValue) { ...
php
{ "resource": "" }
q28293
PermissionTrait.createPermissions
train
public static function createPermissions($permissions, $id) { $query = []; if($permissions) { // create other permissions foreach($permissions as $appName => $app){ foreach ($app as $permissionType => $permission){ if($permissionType == 'd...
php
{ "resource": "" }
q28294
BlockProperty.checkScope
train
private function checkScope(Entity &$object) { if ( ! empty($this->localization) && ! empty($this->block)) { try { // do not-strict match (allows page data with template block) $this->localization->matchDiscriminator($this->block); } catch (\Exception $e) { $object = null; throw $e; } } }
php
{ "resource": "" }
q28295
DatabaseHandler.finish
train
public function finish(array $items = []): bool { $changed = false; foreach ($items as $key => $value) { $serialized = \serialize($value); if (! $this->check($key, $serialized)) { $changed = true; try { $this->saving($key...
php
{ "resource": "" }
q28296
DatabaseHandler.saving
train
protected function saving(string $key, $value, bool $isNew): void { if ($value === 'N;') { $this->delete($key); } else { $this->save($key, $value, $isNew); } }
php
{ "resource": "" }
q28297
DatabaseHandler.asArray
train
protected function asArray($data = []): array { if ($data instanceof Collection) { $data = $data->all(); } elseif ($data instanceof Arrayable) { $data = $data->toArray(); } return $data; }
php
{ "resource": "" }
q28298
Entity.getLocale
train
public function getLocale() { if($this->locale === null) $this->locale = $this->getDefinition()->getEntityManager()->getDefaultLocale(); return $this->locale; }
php
{ "resource": "" }
q28299
Entity.loadDefault
train
public function loadDefault() { foreach($this->getDefinition()->properties() as $name=>$property) $this->_set($name, $property->getDefault($this, $name), null, false); return $this; }
php
{ "resource": "" }