_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q28100
LanguageTrait.getLabels
train
public static function getLabels() { if(!file_exists(accioPath('resources/lang/'.App::getLocale()))) { return json_encode([]); } // Load Project translation files $translationFiles = File::files(accioPath('resources/lang/'.App::getLocale())); //@TODO check if it produces...
php
{ "resource": "" }
q28101
LanguageTrait.checkBySlug
train
public static function checkBySlug(string $slug) { if(Language::all()->where('slug', $slug)->count()) { return true; } return false; }
php
{ "resource": "" }
q28102
LanguageTrait.filterRows
train
public static function filterRows($rows, $withPagination = true, $justForInTable = false, $filterColumns = array()) { $filteredList = array(); $temporaryList = array(); $language = App::getLocale(); if($withPagination) { if(!is_array($rows)) { $rows = $ro...
php
{ "resource": "" }
q28103
LanguageTrait.translateList
train
public static function translateList($items, $languageSlug = '') { if($items) { if(is_a($items, 'Illuminate\Database\Eloquent\Collection')) { $translatedItems = $items->map( function ($post) use ($languageSlug) { foreach ($post->getAttr...
php
{ "resource": "" }
q28104
LanguageTrait.detectLanguageFromRequest
train
public static function detectLanguageFromRequest(Request $request) { $splitURL = explode("/", $request->path()); if(isset($splitURL[0])) { // validate language if(self::findBySlug($splitURL[0])) { return $splitURL[0]; } } return fal...
php
{ "resource": "" }
q28105
LanguageTrait.setLangAttribute
train
public static function setLangAttribute($request) { // language may be present in url without {param} defined $languageSlug= self::setFromURL($request); if(!$languageSlug) { $languageSlug = App::getLocale(); } //add lang parameter to every route/action request if...
php
{ "resource": "" }
q28106
LanguageTrait.getISOBySlug
train
public static function getISOBySlug($slug) { $data = collect(self::ISOlist()); return $data->where('slug', $slug)->first(); }
php
{ "resource": "" }
q28107
LanguageTrait.getISOByName
train
public static function getISOByName($name) { $data = collect(self::ISOlist()); return $data->where('name', $name)->first(); }
php
{ "resource": "" }
q28108
PresenterMappingExtension.getNettePresenterFactory
train
private function getNettePresenterFactory(): Nette\DI\Definitions\ServiceDefinition { $applicationExtension = $this->compiler->getExtensions(Nette\Bridges\ApplicationDI\ApplicationExtension::class); if ($applicationExtension === []) { throw new \LogicException('ApplicationExtension not f...
php
{ "resource": "" }
q28109
Internal.isValidResult
train
private function isValidResult($number, $min, $max) { return is_int($number) && $number >= $min && $number <= $max; }
php
{ "resource": "" }
q28110
AbstractTokenParser.getTagAttributes
train
protected function getTagAttributes() { $stream = $this->parser->getStream(); $attributes = []; $lineno = $stream->getCurrent()->getLine(); $name = $stream->getSourceContext()->getName(); if (!$stream->test(Token::BLOCK_END_TYPE)) { do { $this->va...
php
{ "resource": "" }
q28111
AbstractTokenParser.validateAttributeType
train
protected function validateAttributeType(TokenStream $stream, $type, array $allowed): void { $valid = false; foreach ($allowed as $aType) { if ($stream->test(\constant(Token::class.'::'.$aType.'_TYPE'))) { $valid = true; break; } } ...
php
{ "resource": "" }
q28112
AbstractTokenParser.validateAttributeOperator
train
protected function validateAttributeOperator(TokenStream $stream, $attr): void { if (!$stream->test(Token::OPERATOR_TYPE, '=')) { throw new SyntaxError(sprintf('The attribute "%s" must be followed by "=" operator', $attr), $stream->getCurrent()->getLine(), $stream->getSourceContext()); }...
php
{ "resource": "" }
q28113
AbstractTokenParser.formatAttributes
train
protected function formatAttributes(array $attributes, $lineno, $name) { try { $processor = new Processor(); return $processor->process($this->getAttributeNodeConfig(), [$attributes]); } catch (\Exception $e) { throw new SyntaxError($this->getFormattedMessageExce...
php
{ "resource": "" }
q28114
AbstractTokenParser.getFormattedMessageException
train
protected function getFormattedMessageException(\Exception $exception) { if ($exception instanceof InvalidTypeException) { $attribute = $this->getExceptionAttribute($exception->getMessage()); $attribute = substr($attribute, strrpos($attribute, '.') + 1); $message = sprint...
php
{ "resource": "" }
q28115
AbstractTokenParser.getExceptionAttribute
train
protected function getExceptionAttribute($message) { $message = substr($message, strpos($message, '"') + 1); return substr($message, 0, strpos($message, '"')); }
php
{ "resource": "" }
q28116
CalendarExport.sendCalendar
train
public function sendCalendar($externalCoverageId, $location) { $client = $this->httpClient; $request = $client->post( [self::ENTRY_POINT.'/{coverage}/'.self::EXPORT_API, ['coverage' => $externalCoverageId]], ['Content-Type => multipart/form-data'], null, ...
php
{ "resource": "" }
q28117
LocaleManager.setCurrent
train
public function setCurrent($locale) { $localeIdentifier = null; if ($locale instanceof LocaleInterface) { $localeIdentifier = $locale->getId(); } else { $localeIdentifier = $locale; } $this->current = $this->getLocale($localeIdentifier); }
php
{ "resource": "" }
q28118
LocaleManager.getActiveLocales
train
public function getActiveLocales() { $activeLocales = array(); $locales = $this->getLocales(); foreach ($locales as $id => $locale) { if ($locale->isActive()) { $activeLocales[$id] = $locale; } } return $activeLocales; }
php
{ "resource": "" }
q28119
LocaleManager.detect
train
public function detect(Request $request, Response $response = null) { $localeId = null; /* @var $detector Detector\DetectorInterface */ foreach ($this->detectors as $detector) { $localeId = $detector->detect($request); if ( ! empty($localeId)) { if ($this->hasLocale($localeId) && ($this->...
php
{ "resource": "" }
q28120
LocaleManager.isActive
train
public function isActive($localeId) { $locale = $this->getLocale($localeId, false); if ($locale instanceof LocaleInterface) { return $locale->isActive(); } return false; }
php
{ "resource": "" }
q28121
SeekingLimitStream.getSize
train
public function getSize() { $size = $this->stream->getSize(); if ($size === null) { // this shouldn't happen on a seekable stream I don't think... $pos = $this->stream->tell(); $this->stream->seek(0, SEEK_END); $size = $this->stream->tell(); ...
php
{ "resource": "" }
q28122
SeekingLimitStream.eof
train
public function eof() { $size = $this->limit; if ($size === -1) { $size = $this->getSize(); } return ($this->position >= $size); }
php
{ "resource": "" }
q28123
SeekingLimitStream.seek
train
public function seek($offset, $whence = SEEK_SET) { $pos = $offset; switch ($whence) { case SEEK_CUR: $pos = $this->position + $offset; break; case SEEK_END: $pos = $this->limit + $offset; break; defa...
php
{ "resource": "" }
q28124
BlockRepository.findOneByName
train
public function findOneByName($name) { $qb = $this->getQueryBuilder(); return $qb ->andWhere($qb->expr()->eq('b.name', ':name')) ->andWhere($qb->expr()->isNull('b.row')) ->getQuery() ->useQueryCache(true) // TODO ->useResultCache(true, 360...
php
{ "resource": "" }
q28125
DoctrineNodeTrait.setRightValue
train
public function setRightValue($right) { $this->right = $right; if (isset($this->nestedSetNode)) { $this->nestedSetNode->setRightValue($right); } return $this; }
php
{ "resource": "" }
q28126
DoctrineNodeTrait.setLevel
train
public function setLevel($level) { $this->level = $level; if (isset($this->nestedSetNode)) { $this->nestedSetNode->setLevel($level); } return $this; }
php
{ "resource": "" }
q28127
DoctrineNodeTrait.moveLeftValue
train
public function moveLeftValue($diff) { $this->left += $diff; if (isset($this->nestedSetNode)) { $this->nestedSetNode->moveLeftValue($diff); } return $this; }
php
{ "resource": "" }
q28128
DoctrineNodeTrait.moveRightValue
train
public function moveRightValue($diff) { $this->right += $diff; if (isset($this->nestedSetNode)) { $this->nestedSetNode->moveRightValue($diff); } return $this; }
php
{ "resource": "" }
q28129
DoctrineNodeTrait.moveLevel
train
public function moveLevel($diff) { $this->level += $diff; if (isset($this->nestedSetNode)) { $this->nestedSetNode->moveLevel($diff); } return $this; }
php
{ "resource": "" }
q28130
Publisher.publish
train
public function publish($src, $dstDir) { $r = true; foreach(glob($src.'/*') as $file) { $dst = $dstDir.'/'.basename($file); if(!$this->copy($file, $dst)) $r = false; } return $r; }
php
{ "resource": "" }
q28131
Publisher.publishMigrations
train
public function publishMigrations($src, $dstDir, $migrate) { $r = true; foreach(glob($src.'/*') as $file) { if(basename($file) === 'migrations.json') continue; $dst = $dstDir.'/'.basename($file); $this->copy($file, $dst); } if(!$r) { $this->output->writeln('<warning>The migrations could not be ...
php
{ "resource": "" }
q28132
RequestContext.getRequestHeaders
train
public function getRequestHeaders(): array { $headers = clone $this->headers(); if (!$headers->headerExists('Content-type')) { if ($contentType = $this->getContentType()) { if (($charset = $this->getCharset()) && (stripos($contentType, 'charset=') === false)) { ...
php
{ "resource": "" }
q28133
RequestContext.getRequestData
train
public function getRequestData(): string { $requestData = $this->getData(); $requestData = is_array($requestData) ? $this->httpBuildQuery($requestData) : (string)$requestData; return $requestData; }
php
{ "resource": "" }
q28134
RequestContext.setMethod
train
public function setMethod(string $method): RequestContext { $method = strtoupper($method); if (!in_array($method, self::$availableMethods)) { throw new RequestContextException('Supplied HTTP method is not supported'); } $this->method = $method; return $this; ...
php
{ "resource": "" }
q28135
RequestContext.setUrl
train
public function setUrl(string $url): RequestContext { $this->assertValidUrl($url); $this->url = $url; return $this; }
php
{ "resource": "" }
q28136
RequestContext.getRequestUrl
train
public function getRequestUrl(): string { $url = $this->getUrl(); if ($this->getRequestParameters()) { $url = $this->attachQueryToUrl($url, $this->httpBuildQuery($this->getRequestParameters())); } return $url; }
php
{ "resource": "" }
q28137
RequestContext.setCurlOption
train
public function setCurlOption(int $optionName, $optionValue): RequestContext { if (@curl_setopt(curl_init(), $optionName, $optionValue)) { $this->curlOptions[$optionName] = $optionValue; } else { throw new RequestContextException( "Curl option is invalid: '$op...
php
{ "resource": "" }
q28138
RequestContext.setCurlOptions
train
public function setCurlOptions(array $curlOptions = []): RequestContext { $this->curlOptions = []; foreach ($curlOptions as $name => $value) { $this->setCurlOption($name, $value); } return $this; }
php
{ "resource": "" }
q28139
RequestContext.setResponseContextClass
train
public function setResponseContextClass(string $responseContextClass): RequestContext { if (!is_a($responseContextClass, ResponseContextAbstract::class, true)) { throw new RequestContextException( sprintf( "Class %s must have %s as one of its parents", ...
php
{ "resource": "" }
q28140
RequestContext.assertValidUrl
train
private function assertValidUrl(string $url): void { if (!(filter_var($url, FILTER_VALIDATE_URL) || filter_var($url, FILTER_VALIDATE_IP))) { throw new RequestContextException("Failed to set invalid URL: $url"); } }
php
{ "resource": "" }
q28141
Client.commit
train
public function commit(string $container, string $repo, string $tag, string $comment, string $author, bool $pause, string $changes, ...
php
{ "resource": "" }
q28142
Client.export
train
public function export(string $name) { $url = self::$base_url.'/'.$name.'/get'; return self::$curl->get($url); }
php
{ "resource": "" }
q28143
Client.exports
train
public function exports(array $names) { $url = self::$base_url.'/get?'.http_build_query(['names' => $names]); return self::$curl->get($url); }
php
{ "resource": "" }
q28144
Client.load
train
public function load(bool $quiet = false, string $tar) { $url = self::$base_url.'/load?'.http_build_query(['quiet' => $quiet]); return self::$curl->post($url, $tar); }
php
{ "resource": "" }
q28145
RenderingTrait.attachAndRenderSet
train
function attachAndRenderSet (array $components) { $this->attach ($components); foreach ($components as $c) $c->run (); }
php
{ "resource": "" }
q28146
RenderingTrait.preRun
train
function preRun () { $firstRendering = !$this->renderCount++; if ($this->isVisible ()) { if ($firstRendering) { $this->applyPresetsOnSelf (); $this->setupFirstRun (); } else $this->setupRepeatedRun (); $this->databind (); // This is done on the data binding contex...
php
{ "resource": "" }
q28147
RenderingTrait.run
train
final function run ($onlyContent = false) { if (!$this->context) throw new ComponentException($this, self::ERR_NO_CONTEXT); if ($this->isVisible ()) { $this->preRun (); //---- Rendering code ---- $this->preRender (); if ($onlyContent) $this->runChildren (); else $t...
php
{ "resource": "" }
q28148
Application.getDefaultInputDefinition
train
protected function getDefaultInputDefinition() { $definition = parent::getDefaultInputDefinition(); $definition->addOption(new InputOption('--env', null, InputOption::VALUE_OPTIONAL, 'The environment the console should run under.')); return $definition; }
php
{ "resource": "" }
q28149
Rule.setGroups
train
public function setGroups($groups=null) { if(!is_array($groups) && $groups !== null) $groups = [$groups]; $this->groups = $groups; return $this; }
php
{ "resource": "" }
q28150
Rule.belongsToGroups
train
public function belongsToGroups(array $groups, Validator $validator) { if($this->groups === null) return $validator->belongsToGroups($groups); else { foreach($groups as $group) { if(in_array($group, $this->groups)) return true; } return false; } }
php
{ "resource": "" }
q28151
PagePathGeneratorListener.pageChange
train
private function pageChange(Page $master, $force = false) { // Run for all children $pageLocalizationEntity = PageLocalization::CN(); $dql = "SELECT l FROM $pageLocalizationEntity l JOIN l.master m WHERE m.left >= :left AND m.right <= :right ORDER BY l.locale, m.left"; $pageLocalizations = $this-...
php
{ "resource": "" }
q28152
PagePathGeneratorListener.pageLocalizationChange
train
private function pageLocalizationChange(PageLocalization $localization, $force = false) { $master = $localization->getMaster(); $pageLocalizationEntity = PageLocalization::CN(); $dql = "SELECT l FROM $pageLocalizationEntity l JOIN l.master m WHERE m.left >= :left AND m.right <= :right AND l.locale =...
php
{ "resource": "" }
q28153
PagePathGeneratorListener.checkForDuplicates
train
protected function checkForDuplicates(PageLocalization $pageData, Path $newPath) { $page = $pageData->getMaster(); $locale = $pageData->getLocale(); $repo = $this->em->getRepository(PageLocalizationPath::CN()); $newPathString = $newPath->getFullPath(); // Duplicate path validation $criteria = array( '...
php
{ "resource": "" }
q28154
PagePathGeneratorListener.findPagePath
train
protected function findPagePath(PageLocalization $pageData) { $active = true; $limited = false; $inSitemap = true; $path = new Path(); // Inactive page children have no path if ( ! $pageData->isActive()) { $active = false; } if ( ! $pageData->isVisibleInSitemap()) { $inSitemap = false; } ...
php
{ "resource": "" }
q28155
Search.printSearchForm
train
public function printSearchForm($customView ='', $formClass="") { return new HtmlString( view()->make( ($customView ? $customView : "vendor.search.default"), [ 'keyword' => $this->getKeyword(), 'formClass' => $formClass ] ...
php
{ "resource": "" }
q28156
Search.searchByTerm
train
public function searchByTerm($table, $searchTerm, $limit, $searchInAllColumns = true, $columns = array(), $excludeColumns = array(), $orderBy = 'created_at', $orderType = 'DESC', $joins = array(), $conditions = array()) { $langSlug = App::getLocale(); if($searchInAllColumns && !$columns) { ...
php
{ "resource": "" }
q28157
Search.media
train
public function media($searchTerm, $fromDate = '', $toDate = '', $mediaType = '', $orderBy = "created_at", $orderType = 'DESC', $page = 1) { $queryObject = DB::table("media"); if($searchTerm != "") { $queryObject->where( function ($query) use ($searchTerm) { ...
php
{ "resource": "" }
q28158
ImageSize.getFolderName
train
public function getFolderName() { $return = array($this->getWidth(), 'x', $this->getHeight()); if ($this->isCropped()) { if ($this->isCropVariant()) { $return[] = 'c'; $return[] = intval($this->getCropSourceWidth()); $return[] = 'x'; $return[] = intval($this->getCropSourceHeight()); } ...
php
{ "resource": "" }
q28159
GroupsController.update
train
public function update(UpdateGroupPost $request, $id) { $model = (new Services\GroupsService)->dataUpdate($id, $request->all()); return back()->with('success', 'Grupo atualizado com sucesso'); }
php
{ "resource": "" }
q28160
GroupsController.destroy
train
public function destroy(Request $request, $id) { $deleted = (new Services\GroupsService)->dataDelete($id, $request->all()); return response()->json(['deleted' => $deleted]); }
php
{ "resource": "" }
q28161
GroupsController.restore
train
public function restore(Request $request, $id) { $restored = (new Services\GroupsService)->dataRestore($id, $request->all()); return response()->json(['restored' => $restored]); }
php
{ "resource": "" }
q28162
Templates.unregister
train
public function unregister(array $page_templates) { $unregisterConfig = $this->config->getSubConfig(self::UNREGISTER); return array_diff_key( $page_templates, array_flip( $unregisterConfig->getArrayCopy() ) ); }
php
{ "resource": "" }
q28163
Input.parseAmountDecimalSeparator
train
protected function parseAmountDecimalSeparator($amount) { $decimal_separator_counts = []; foreach ($this->decimalSeparators as $decimal_separator) { $decimal_separator_counts[$decimal_separator] = \mb_substr_count($amount, $decimal_separator); } $decimal_separator_counts_filtered = array_filter($d...
php
{ "resource": "" }
q28164
Input.parseAmountNegativeFormat
train
protected function parseAmountNegativeFormat($amount) { // An amount wrapped in parentheses. $amount = preg_replace('/^\((.*?)\)$/', '-\\1', $amount); // An amount suffixed by a minus sign. $amount = preg_replace('/^(.*?)-$/', '-\\1', $amount); // Double minus signs. $amount = preg_replace('/--/...
php
{ "resource": "" }
q28165
FontIconDataSource.getData
train
public function getData(NodeInterface $node = null, array $arguments) { $data = []; foreach ($this->parseListOfIcons() as $iconName) { $data['fa-' . $iconName] = [ 'label' => $iconName, 'icon' => 'fa fa-' . $iconName, ]; } ret...
php
{ "resource": "" }
q28166
FontIconDataSource.parseListOfIcons
train
protected function parseListOfIcons() { $cache = $this->cacheManager->getCache('Default'); $cacheId = 'FontIconDataSource_parseListOfIcons'; if (!($icons = $cache->get($cacheId))) { $icons = []; foreach (file(self::$iconsListFilePath) as $content) { i...
php
{ "resource": "" }
q28167
PdfManager.getTimetableHtml
train
public function getTimetableHtml($args) { $args['_controller'] = 'CanalTPMttBundle:Timetable:view'; $subRequest = $this->co->get('request')->duplicate(array(), null, $args); $subRequest->headers->remove('X-Requested-With'); return $this->co->get('http_kernel')->handle($subRequest, H...
php
{ "resource": "" }
q28168
Widgets.apply
train
public function apply() { if ($this->config->hasKey(self::UNREGISTER)) { add_action('widgets_init', [$this, 'unregister'], 15); } if ($this->config->hasKey(self::REGISTER)) { add_action('widgets_init', [$this, 'register'], 15); } }
php
{ "resource": "" }
q28169
Widgets.unregister
train
public function unregister() { $unregisterConfig = $this->config->getSubConfig(self::UNREGISTER); array_map('unregister_widget', $unregisterConfig->getArrayCopy()); }
php
{ "resource": "" }
q28170
Psr3Logger.log
train
public function log($level, $message, array $context = array()) { /*** * \note * There are several contexts in which the follow code * may not work as expected. * * Using threads (https://github.com/krakjoe/pthreads) * with this metho...
php
{ "resource": "" }
q28171
RequireAssetExtension.requireAsset
train
public function requireAsset($asset, $type = null) { return null !== $this->manager && $this->manager->has($asset, $type) ? $this->manager->getPath($asset, $type) : $asset; }
php
{ "resource": "" }
q28172
PagesSitemapController.applicationsListAction
train
public function applicationsListAction() { $manager = $this->getPageApplicationManager(); $responseData = array(); foreach ($manager->getAllApplications() as $application) { $responseData[] = array( 'id' => $application->getId(), 'title' => $application->getTitle(), 'icon' => $application->ge...
php
{ "resource": "" }
q28173
PagesSitemapController.moveAction
train
public function moveAction() { $this->isPostRequest(); $localization = $this->getPageLocalization(); $page = $localization->getMaster(); $input = $this->getRequestInput(); $this->lockNestedSet($page); try { if ($input->has('reference_id')) { $sibling = $this->getPageByRequestKey('reference_...
php
{ "resource": "" }
q28174
PagesSitemapController.loadSitemapTree
train
private function loadSitemapTree($entity) { $em = $this->getEntityManager(); $input = $this->getRequestInput(); $localeId = $this->getCurrentLocale()->getId(); // Parent ID and level $levels = null; $parentId = null; if ($input->has('parent_id')) { $parentId = $input->get('parent_id'); // S...
php
{ "resource": "" }
q28175
Product.getParentCategory
train
public function getParentCategory() { $parentCategory = null; $currentCategory = $this->getCurrentCategory(); if (null !== $currentCategory) { $parentCategoryId = $currentCategory->getParentId(); $parentCategory = $this->_categoryRepository->get( $pare...
php
{ "resource": "" }
q28176
Product.isProductNew
train
public function isProductNew($product) { $newsFromDate = $product->getNewsFromDate(); $newsToDate = $product->getNewsToDate(); if (!$newsFromDate && !$newsToDate) { return false; } return $this->localeDate->isScopeDateInInterval( $product->getStore(),...
php
{ "resource": "" }
q28177
Product.getSalePercentage
train
private function getSalePercentage($product) { $specialPrice = $product->getSpecialPrice(); $originalPrice = $product->getPrice(); $specialfromdate = $product->getSpecialFromDate(); $specialtodate = $product->getSpecialToDate(); $today = time(); $salePercent = 0; ...
php
{ "resource": "" }
q28178
Product.getProductLabels
train
public function getProductLabels($product) { $html = ''; if ($this->isProductOnSale($product)) { if ($this->isShowPercentage() && $this->getSalePercentage($product) > 0) { $html .= '<span class="sale-label sale-value">'.$this->getSalePercentage($product).'%</span>'; ...
php
{ "resource": "" }
q28179
MediaTrait.createDefaultThumbs
train
public function createDefaultThumbs($image = null, $app = 'default') { if(!$image) { $image = $this; } if($image->hasImageExtension()) { foreach (config('media.default_thumb_size') as $thumKey => $thumValue) { if ($thumKey == "default" || $thumKey == ...
php
{ "resource": "" }
q28180
MediaTrait.thumb
train
public function thumb($width, $height=null, $imageObj = null, array $options = []) { // get current object's image in case there is no specific image given if(!$imageObj) { $imageObj = $this; } $thumbDirectory = $width.($height ? 'x'.$height : ""); $thumbPath = ...
php
{ "resource": "" }
q28181
MediaTrait.hasImageExtension
train
public function hasImageExtension($extension = null) { if(!$extension && $this->extension) { $extension = $this->extension; } if(!$extension) { throw new \Exception("No extension given"); } if(array_intersect([strtolower($extension),strtoupper($exten...
php
{ "resource": "" }
q28182
MediaTrait.isAllowedExtension
train
private function isAllowedExtension($extension = null) { if(!$extension && $this->extension) { $extension = $this->extension; } if(!$extension) { throw new \Exception("No extension given"); } if(array_intersect([strtolower($extension),strtoupper($ext...
php
{ "resource": "" }
q28183
MediaTrait.optimize
train
public function optimize(string $pathToImage, string $pathToOutput = null) { if(config('media.optimize_image')) { ImageOptimizer::optimize($pathToImage, $pathToOutput); } return $this; }
php
{ "resource": "" }
q28184
Primary.getHttpResponseHeaders
train
public function getHttpResponseHeaders($rawHeaders) { if (is_array($rawHeaders)) { return $this->parseArrayHeaders($rawHeaders); } return $this->parseStringHeaders($rawHeaders); }
php
{ "resource": "" }
q28185
BasePermissionController.getUserGroups
train
public function getUserGroups($lang = "") { // check if user has permissions to access this link if(!User::hasAccess('Permissions', 'read')) { return $this->noPermission(); } return array('data' => \App\Models\UserGroup::all()); }
php
{ "resource": "" }
q28186
BasePermissionController.delete
train
public function delete($lang, $id) { // check if user has permissions to access this link if(!User::hasAccess('Permissions', 'delete')) { return $this->noPermission(); } DB::statement('SET FOREIGN_KEY_CHECKS=0'); $group = \App\Models\UserGroup::find($id)->delete(...
php
{ "resource": "" }
q28187
BasePermissionController.store
train
public function store(Request $request) { // check if user has permissions to access this link if(!User::hasAccess('Permissions', 'create')) { return $this->noPermission(); } // custom messages for validation $messages = array( 'id.required' => 'ID is ...
php
{ "resource": "" }
q28188
BasePermissionController.bulkDelete
train
public function bulkDelete(Request $request) { // check if user has permissions to access this link if(!User::hasAccess('Permissions', 'delete')) { return $this->noPermission(); } $data = $request->all(); if(isset($data['postTypes'])) { unset($data['po...
php
{ "resource": "" }
q28189
BasePermissionController.getList
train
public function getList(Request $request) { // check if user has permissions to access this link if(!User::hasAccess('permissions', 'read')) { return $this->noPermission(); } $className = 'App\\Models\\'.$request->customPermissions['model']; $class = new $classNam...
php
{ "resource": "" }
q28190
ItemList.getAllowedMethods
train
protected function getAllowedMethods($item) { $cls = get_class($item); $allowed = isset($this->allowedMethods[$cls]) ? $this->allowedMethods[$cls] : null; if (!$allowed) { $conf = Config::inst()->get(get_class($item), 'allowed_template_methods'); if ($conf) { $allowed = $conf; } else { $methodsFr...
php
{ "resource": "" }
q28191
PageEventListener.onInitialize
train
public function onInitialize(ResourceEventInterface $event) { $page = $this->getPageFromEvent($event); $parent = $page->getParent(); if ($parent && $parent->isLocked()) { throw new RuntimeException("Cannot create child page under a locked parent page."); } }
php
{ "resource": "" }
q28192
PageEventListener.deletePageCache
train
private function deletePageCache(PageInterface $page) { if (null !== $this->cache) { $this->cache->delete('ekyna_cms.page[route:' . $page->getRoute() . ']'); } }
php
{ "resource": "" }
q28193
PageEventListener.disablePageChildren
train
private function disablePageChildren(PageInterface $page) { $childrenDisabled = false; if (!$page->isEnabled()) { if (0 < $page->getChildren()->count()) { foreach ($page->getChildren() as $child) { if ($child->isEnabled()) { $ch...
php
{ "resource": "" }
q28194
PageEventListener.disablePageRelativeMenus
train
private function disablePageRelativeMenus(PageInterface $page) { $disabledMenus = false; if (!$page->isEnabled()) { // Disable menu children query $disableChildrenQuery = $this->em->createQuery(sprintf( 'UPDATE %s m SET m.enabled = 0 WHERE m.root = :root AND ...
php
{ "resource": "" }
q28195
PageEventListener.getPageFromEvent
train
private function getPageFromEvent(ResourceEventInterface $event) { $resource = $event->getResource(); if (!$resource instanceof PageInterface) { throw new InvalidArgumentException("Expected instance of PageInterface"); } return $resource; }
php
{ "resource": "" }
q28196
ErrorController.statusCodeAction
train
public function statusCodeAction($code = null, $message = null) { $codes = [ 403 => "403 Forbidden", 404 => "404 Not Found", 500 => "500 Internal Server Error", ]; // Key being integer also (unintentionally) prevents this action from direct url usage ...
php
{ "resource": "" }
q28197
ErrorController.displayValidRoutesAction
train
public function displayValidRoutesAction() { $this->di->views->add('default/error-routes', [ 'route' => $this->di->request->getRoute(), 'routes' => $this->di->router->getAll(), 'internalRoutes' => $this->di->router->getInternal(), 'controllers' ...
php
{ "resource": "" }
q28198
PageComponent.action_delete
train
function action_delete ($param = null) { if (!isset($this->model)) throw new FlashMessageException('Can\'t delete a NULL model.', FlashType::ERROR); throw new FlashMessageException(sprintf ('Can\'t automatically delete object of type <kbd>%s</kbd>', gettype ($this->model)), FlashType::ERROR); }
php
{ "resource": "" }
q28199
PageComponent.action_submit
train
function action_submit ($param = null) { if (!isset($this->model)) throw new FlashMessageException('Can\'t insert/update a NULL model.', FlashType::ERROR); throw new FlashMessageException('Can\'t automatically insert/update an object of type ' . gettype ($this->model), FlashType::ERROR); }
php
{ "resource": "" }