_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q27600
CatalogueProduct.getTaxString
train
public function getTaxString() { $string = ""; $rate = $this->getTaxFromCategory(); $config = SiteConfig::current_site_config(); if ($config->ShowPriceTaxString) { if ($rate && $this->IncludesTax) { $string = _t( "CatalogueFrontend.Tax...
php
{ "resource": "" }
q27601
CatalogueProduct.getAncestors
train
public function getAncestors($include_parent = false) { $ancestors = ArrayList::create(); $object = $this->Categories()->first(); if($object) { if($include_parent) $ancestors->push($object); while ($object = $object->getParent()) { $ancestors->pus...
php
{ "resource": "" }
q27602
CatalogueProduct.SortedImages
train
public function SortedImages() { // If this product has images, display them if ($this->Images()->exists()) { return $this->Images()->Sort('SortOrder'); } $config = SiteConfig::current_site_config(); $default_image = $config->DefaultProductImage(); $image...
php
{ "resource": "" }
q27603
CatalogueProduct.getCategoriesList
train
public function getCategoriesList() { $list = []; foreach($this->Categories() as $cat) { $list[] = $cat->FullHierarchy; } return implode(", ", $list); }
php
{ "resource": "" }
q27604
CatalogueProduct.generateStockID
train
protected function generateStockID() { $title = ""; foreach (explode(" ", $this->Title) as $string) { $string = substr($string, 0, 1); $title .= $string; } return $title . "-" . $this->ID; }
php
{ "resource": "" }
q27605
CatalogueProduct.canCreateTags
train
public function canCreateTags($member = null) { if (empty($member)) { $member = Security::getCurrentUser(); } return Permission::checkMember( $member, ["ADMIN", "CATALOGUE_ADD_TAGS"] ); }
php
{ "resource": "" }
q27606
LinkGeneratorExtension.pathObject
train
function pathObject($entity, $type = LinkGeneratorService::TYPE_LINK_DEFAULT, array $parameters = array()) { if($entity === null){ return ""; } return $this->linkGeneratorService->generate($entity, $type, $parameters); }
php
{ "resource": "" }
q27607
LinkGeneratorExtension.pathObjectUrl
train
function pathObjectUrl($entity, $type = LinkGeneratorService::TYPE_LINK_DEFAULT, array $parameters = array()) { if($entity === null){ return ""; } return $this->linkGeneratorService->generateOnlyUrl($entity, $type, $parameters); }
php
{ "resource": "" }
q27608
EasyMailer.send
train
public function send(string $templatePath, array $context = [], array $to = [], array $cc = [], array $bcc = []) { if (!$this->isDeliveryEnabled) { return; } $message = $this->templateEngineAdapter->createMessage($templatePath, $context); $this->mailerAdapter->sendMessag...
php
{ "resource": "" }
q27609
PostageArea.Total
train
public function Total($decimal_size = null) { if ($this->Cost && $this->Tax) { $cost = $this->Cost + (($this->Cost / 100) * $this->Tax); } else { $cost = $this->Cost; } if($decimal_size) { $cost = number_format($cost, $decimal_size); ...
php
{ "resource": "" }
q27610
GRPHPAPIClient.getWebClient
train
public function getWebClient() { if ($this->objClient == null) { $this->objClient = new Client(); $objWssePlugin = $this->generateWSSEHeader($this->strUsername, $this->strApiToken); $this->objClient->addSubscriber($objWssePlugin); $this->objClient->setSslVerifica...
php
{ "resource": "" }
q27611
GRPHPAPIClient.getRoot
train
public function getRoot() { $objWebClient = $this->getWebClient(); $strUri = $this->getApiUrl() . '/'; $arrHeaders = $this->getHeaders(); $objRequest = $objWebClient->get($strUri, $arrHeaders); $this->objResponse = $objRequest->send(); $strResponse = $this->objResponse...
php
{ "resource": "" }
q27612
GRPHPAPIClient.putAdvocatePaymentMethod
train
public function putAdvocatePaymentMethod($strAccountSlug, $strAdvocateToken, $intAdvocatePaymentMethodId, array $arrParams) { $objWebClient = $this->getWebClient(); $strUri = $this->getApiUrl() . '/accounts/' . $strAccountSlug . '/advocates/' . $strAdvocateToken . '/payment-methods/' . $intAdvocatePaym...
php
{ "resource": "" }
q27613
GRPHPAPIClient.deleteReferral
train
public function deleteReferral($strAccountSlug, $strAdvocateToken, $intReferralId) { $objWebClient = $this->getWebClient(); $strUri = $this->getApiUrl() . '/accounts/' . $strAccountSlug . '/advocates/' . $strAdvocateToken . '/referrals/' . $intReferralId; $arrHeaders = $this->getHeaders(); ...
php
{ "resource": "" }
q27614
GRPHPAPIClient.getCampaigns
train
public function getCampaigns($strAccountSlug, $intPage = 1, $intLimit = 10, $strFilter = null, $strSort = null) { $objWebClient = $this->getWebClient(); $strUri = $this->getApiUrl() . '/accounts/' . $strAccountSlug . '/campaigns'; $arrHeaders = $this->getHeaders(); $strFilter = array('q...
php
{ "resource": "" }
q27615
GRPHPAPIClient.postRedemptionRequest
train
public function postRedemptionRequest($strAccountSlug, array $arrParams) { $objWebClient = $this->getWebClient(); $strUri = $this->getApiUrl() . '/accounts/' . $strAccountSlug . '/redemption-requests'; $arrHeaders = $this->getHeaders(); $objRequest = $objWebClient->post($strUri, $arrHe...
php
{ "resource": "" }
q27616
GRPHPAPIClient.patchRedemptionRequestRedemption
train
public function patchRedemptionRequestRedemption($strAccountSlug, $intRedemptionRequestId) { $objWebClient = $this->getWebClient(); $strUri = $this->getApiUrl() . '/accounts/' . $strAccountSlug . '/redemption-requests/' . $intRedemptionRequestId . '/redemption'; $arrHeaders = $this->getHeaders(...
php
{ "resource": "" }
q27617
GRPHPAPIClient.getReportsBonusesDailyGiven
train
public function getReportsBonusesDailyGiven($strAccountSlug = '', $strCampaignSlug = '', $strAdvocateToken = '', $strFrom = '', $strTo = '') { $objWebClient = $this->getWebClient(); $strUri = $this->getApiUrl() . '/reports/bonuses-daily-given'; $arrHeaders = $this->getHeaders(); $objRe...
php
{ "resource": "" }
q27618
TableMaker.hasAtLeastOneFilter
train
private function hasAtLeastOneFilter() { $columns = $this->options[self::GRID_PARAM_COLUMNS]; foreach ($columns as $column) { if (isset($column[self::GRID_PARAM_FILTER]) && $column[self::GRID_PARAM_FILTER] == true) { return true; } } return f...
php
{ "resource": "" }
q27619
TableMaker.render
train
public function render() { $columns = $this->options[self::GRID_PARAM_COLUMNS]; if ($this->hasAtLeastOneFilter()) { $head = $this->createTableHeader(array( $this->createTopHeadingRow($columns), $this->createBottomHeadingRow($columns) )); ...
php
{ "resource": "" }
q27620
TableMaker.hasColumnConfiguration
train
private function hasColumnConfiguration($column) { $columns = $this->options[self::GRID_PARAM_COLUMNS]; foreach ($columns as $configuration) { // By default a column is considered as visible if (!isset($configuration[self::GRID_PARAM_HIDDEN])) { $configuratio...
php
{ "resource": "" }
q27621
TableMaker.createTopHeadingRow
train
private function createTopHeadingRow(array $rows) { $elements = array(); if ($this->options[self::GRID_PARAM_BATCH] === true) { $checkbox = Element::checkbox(null, false, array(), false); $elements[] = $this->createColumn(null, $checkbox); } foreach ($rows a...
php
{ "resource": "" }
q27622
TableMaker.createBottomHeadingRow
train
private function createBottomHeadingRow(array $rows) { $elements = array(); if ($this->options[self::GRID_PARAM_BATCH] === true) { $elements[] = $this->createColumn(null, null); } foreach ($rows as $row) { // Ignore if configuration for current column isn't ...
php
{ "resource": "" }
q27623
TableMaker.createBodyRows
train
private function createBodyRows($columns, array $data) { $rows = array(); foreach ($data as $row) { $rows[] = $this->createBodyRow($columns, $row); } return $rows; }
php
{ "resource": "" }
q27624
TableMaker.findOptionByColumn
train
private function findOptionByColumn($column, $key) { $options = $this->findOptionsByColumn($column); return isset($options[$key]) ? $options[$key] : null; }
php
{ "resource": "" }
q27625
TableMaker.findOptionsByColumn
train
private function findOptionsByColumn($column) { // Run a basic linear search foreach ($this->options as $collection) { // Make sure $collection is array if (is_array($collection)) { foreach ($collection as $row) { if (is_array($row) && $row...
php
{ "resource": "" }
q27626
TableMaker.getPkColumn
train
private function getPkColumn() { if (isset($this->options[self::GRID_PARAM_PK])) { return $this->options[self::GRID_PARAM_PK]; } else { return false; } }
php
{ "resource": "" }
q27627
TableMaker.createInput
train
private function createInput($method, $column, $name, $value, array $extra = array()) { $options = $this->findOptionsByColumn($column); // Input type. If not provided explicitly, use text $type = isset($options[self::GRID_PARAM_TYPE]) ? $options[self::GRID_PARAM_TYPE] : 'text'; $te...
php
{ "resource": "" }
q27628
TableMaker.createElement
train
private function createElement($type, $children = array(), array $attributes = array(), $text = null) { $element = new NodeElement(); $element->openTag($type); if (!empty($attributes)) { $element->addAttributes($attributes); } if (!empty($children)) { ...
php
{ "resource": "" }
q27629
TableMaker.createHeader
train
private function createHeader($children = array(), $text = null) { return $this->createElement('th', $children, array('class' => $this->options['tableHeaderClass']), $text); }
php
{ "resource": "" }
q27630
TableMaker.createColumn
train
private function createColumn($children = array(), $text = null, array $attributes = array()) { $attributes = array_merge( array('class' => $this->options['tableDataClass']), $attributes ); return $this->createElement('td', $children, $attributes, $text); }
php
{ "resource": "" }
q27631
TableMaker.createHeaderLink
train
private function createHeaderLink($column, $text) { $a = new NodeElement(); $a->openTag('a'); if ($this->filter->isSortedBy($column)) { $a->setClass('text-info'); } $a->addAttribute('href', $this->filter->getColumnSortingUrl($column)) ->appendChildWith...
php
{ "resource": "" }
q27632
TableMaker.createHeaderLinkIcon
train
private function createHeaderLinkIcon($column) { $class = $this->filter->isSortedByDesc($column) ? $this->options['arrowDownIcon'] : $this->options['arrowUpIcon']; return $this->createIcon($class); }
php
{ "resource": "" }
q27633
ResourceController.findResources
train
public function findResources ($resourceName) { $request = get_request(); $resource = Resources::get($resourceName); if ($request->has("rawQuery")) { $query = unserialize($request->get("rawQuery")); $resource->limit($query->getLimit()); $resource->offset($quer...
php
{ "resource": "" }
q27634
ResourceController.insertResource
train
public function insertResource ($resourceName) { $request = get_request(); $resource = Resources::get($resourceName); if ($request->has("rawQuery")) { $query = unserialize($request->get("rawQuery")); $resource->fields($query->getFields()); } return $resour...
php
{ "resource": "" }
q27635
QueryWorker.paginate
train
public function paginate($limit = 25, $page = 0) { if ($limit > 0) { $this->queryBuilder->setMaxResults($limit); } if ($page > 0) { $this->queryBuilder->setFirstResult($page * $limit); } return $this; }
php
{ "resource": "" }
q27636
QueryWorker.andWhere
train
public function andWhere($field, $operation, $value = null, $alias = self::DEFAULT_TABLE_ALIAS) { if (strpos($field, '.') > 0) { //monta os joins $this->fieldValue = [ 'value' => $value, 'operation' => $operation, ]; $newAli...
php
{ "resource": "" }
q27637
QueryWorker.makeExpressions
train
private function makeExpressions($conditions, $alias = self::DEFAULT_TABLE_ALIAS) { $expressions = []; foreach ($conditions as $attr) { $field = $attr['field']; if (strpos($field, '.') > 0) { //monta os joins $newAliasField = $this->association...
php
{ "resource": "" }
q27638
QueryWorker.addGroupBy
train
public function addGroupBy($field) { $alias = self::DEFAULT_TABLE_ALIAS; if (strpos($field, '.') > 0) { //monta os joins $newAliasField = $this->associationQueryFields($field); } if (count($this->queryFields) > 0) { foreach ($this->queryFields as $...
php
{ "resource": "" }
q27639
QueryWorker.select
train
public function select($fields) { foreach ($fields as $key => $value) { if (is_int($key)) { $this->associationQueryFields($value); } elseif (is_array($value)) { $alias = $this->tableAlias(); $this->queryBuilder->join($this->getFullField...
php
{ "resource": "" }
q27640
QueryWorker.getMetaAndAliases
train
private function getMetaAndAliases() { $arr = explode('.', $this->field); $meta = $this->getClassMetadata(); $metaAnterior = []; $parent = ''; $alias = ''; for ($i = 0; $i <= $this->position; $i++) { $metaAnterior = $meta; if ($meta->hasAssoc...
php
{ "resource": "" }
q27641
QueryWorker.setJoin
train
private function setJoin($table, $field, $parentField, $alias, $parentAlias) { if (!in_array($alias, $this->tables)) { $condition = $this->getFullFieldName($field, $alias).' = '.$this->getFullFieldName($parentField, $parentAlias); $this->queryBuilder->join($table, $alias, 'WITH', $co...
php
{ "resource": "" }
q27642
QueryWorker.setLeftJoin
train
private function setLeftJoin($table, $field, $parentField, $alias, $parentAlias, $withWhere = false) { if (!in_array($alias, $this->tables)) { $condition = $this->getFullFieldName($field, $alias).' = '.$this->getFullFieldName($parentField, $parentAlias); $this->queryBuilder->leftJoin...
php
{ "resource": "" }
q27643
QueryWorker.setManyToManyValuedCondition
train
private function setManyToManyValuedCondition($association, $alias, $arr) { if (empty($this->fieldValue['value']) || $this->position < count($arr) - 2) { return null; } $targetField = $this->position == count($arr) - 1 ? $association['joinTable']['joinColumns'][0]['referencedColu...
php
{ "resource": "" }
q27644
QueryWorker.setManyToManyJoin
train
private function setManyToManyJoin($table, $alias, $condition = null) { if (!in_array($alias, $this->tables)) { if ($condition) { $this->queryBuilder->join($table, $alias, 'WITH', $condition); } else { $this->queryBuilder->join($table, $alias); ...
php
{ "resource": "" }
q27645
QueryWorker.setQueryField
train
private function setQueryField($meta, $value, $alias) { $campo = $this->getFullFieldName($value, $alias); if ($meta->isSingleValuedAssociation($value) && $value != $alias) { $targetField = $meta->getAssociationMapping($value)['joinColumns'][0]['referencedColumnName']; $alias...
php
{ "resource": "" }
q27646
QueryWorker.getSubClassFields
train
private function getSubClassFields($meta, $value) { foreach ($meta->subClasses as $subClass) { $delimiter = strpos($subClass, '/') > 0 ? '/' : '\\'; $temp = explode($delimiter, $subClass); $tempMeta = $this->em->getClassMetadata($subClass); if (end($temp) == $...
php
{ "resource": "" }
q27647
QueryWorker.getTargetField
train
private function getTargetField($meta, $parentMeta, $value) { if (count($parentMeta->parentClasses) > 0) { foreach ($parentMeta->parentClasses as $classe) { $associationsByTargetClass = $meta->getAssociationsByTargetClass($classe); if (count($associationsByTargetC...
php
{ "resource": "" }
q27648
QueryWorker.searchAssociationField
train
private function searchAssociationField($associationsByTargetClass, $parentTable, $value) { foreach ($associationsByTargetClass as $table => $association) { if ($table == $parentTable && $association['inversedBy'] == $value) { return $association['fieldName']; } ...
php
{ "resource": "" }
q27649
DateTimeUtil.getJsFormat
train
public static function getJsFormat($locale = null, $timezone = null, $date = true, $time = true, $seconds = false) { $pattern = static::getPattern($locale, $timezone, $date, $time, $seconds); return static::convertToJsFormat($pattern); }
php
{ "resource": "" }
q27650
DateTimeUtil.getPattern
train
public static function getPattern($locale = null, $timezone = null, $date = true, $time = true, $seconds = false) { $formatter = static::getFormatter($locale, $timezone, $date, $time, $seconds); $pattern = $formatter->getPattern(); return $pattern; }
php
{ "resource": "" }
q27651
DateTimeUtil.getFormatter
train
public static function getFormatter($locale = null, $timezone = null, $date = true, $time = true, $seconds = false) { $locale = null === $locale ? \Locale::getDefault() : $locale; $date_format = \IntlDateFormatter::NONE; $time_format = \IntlDateFormatter::NONE; if ($date) { ...
php
{ "resource": "" }
q27652
DateTimeUtil.convertToJsFormat
train
public static function convertToJsFormat($pattern) { if (false === strpos($pattern, 'yyyy')) { if (false !== strpos($pattern, 'yy')) { $pattern = str_replace('yy', 'yyyy', $pattern); } elseif (false !== strpos($pattern, 'y')) { $pattern = str_replace('...
php
{ "resource": "" }
q27653
RawBinding.quoteMany
train
private function quoteMany(array $values) { foreach ($values as &$value) { $value = $this->quote($value); } return $values; }
php
{ "resource": "" }
q27654
AddonExtension.createBlockView
train
protected function createBlockView(FormView $view) { $bView = new BlockView(); $bView->vars = $view->vars; $bView->vars['block'] = $bView; unset($bView->vars['form']); return $bView; }
php
{ "resource": "" }
q27655
Input.getMessages
train
public function getMessages() { $messages = array(); foreach ($this->_fields as $fieldName => $values) { if (! $values['isValid']) { $invalidators = array(); foreach ($values['validators'] as $validatorName => $validatorValue) { if (! $...
php
{ "resource": "" }
q27656
Input.getFilteredFields
train
public function getFilteredFields() { $filteredFields = array(); foreach ($this->_fields as $fieldName => $data) { $filteredFields[$fieldName] = $data['value']; } return $filteredFields; }
php
{ "resource": "" }
q27657
Input.setField
train
private function setField($paramName, $value = false, $isValid = null, $validators = null) { if (! isset($this->_fields[$paramName])) { $this->_fields[$paramName] = array( 'originalValue' => (isset($this->_params[$paramName])) ? $this->_params[$paramName] : null, ...
php
{ "resource": "" }
q27658
Input.validateMatches
train
public static function validateMatches($value, $compareField, $instance) { if (isset($instance->_fields[$compareField])) { return ($value == $instance->_fields[$compareField]['value']); } }
php
{ "resource": "" }
q27659
Input.validateUrl
train
public static function validateUrl($value) { if (($url = parse_url($value)) && ! empty($url['scheme']) && ! empty($url['host'])) { return true; } return false; }
php
{ "resource": "" }
q27660
Uuid.fromRamseyUuid
train
private static function fromRamseyUuid(\Ramsey\Uuid\Uuid $uuid) { return new self( $uuid->getFieldsHex(), $uuid->getNumberConverter(), \Ramsey\Uuid\Uuid::getFactory()->getCodec() ); }
php
{ "resource": "" }
q27661
Exam.get
train
public static function get(Bookboon $bookboon, string $examId) : BookboonResponse { if (Entity::isValidUUID($examId) === false) { throw new BadUUIDException(); } $bResponse = $bookboon->rawRequest("/exams/$examId"); $bResponse->setEntityStore( new EntityStor...
php
{ "resource": "" }
q27662
Exam.getAll
train
public static function getAll(Bookboon $bookboon) : BookboonResponse { $bResponse = $bookboon->rawRequest("/exams"); $bResponse->setEntityStore( new EntityStore(static::getEntitiesFromArray($bResponse->getReturnArray())) ); return $bResponse; }
php
{ "resource": "" }
q27663
Configuration.getConfigTreeBuilder
train
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('vm_pro_api'); $rootNode ->children() ->scalarNode('base_url') ->defaultValue(self::DEFAULT_API_BASE_URL) ->end() ...
php
{ "resource": "" }
q27664
NewsCMSExtension.generateCMSFields
train
public function generateCMSFields(FieldList $fields) { /** @var News $owner */ $owner = $this->owner; /** @var SiteConfig $siteConfig */ $siteConfig = SiteConfig::current_site_config(); $this->type_array = array( 'news' => _t('News.NEWSITEMTYPE', 'Newsitem'), ...
php
{ "resource": "" }
q27665
NewsCMSExtension.defaultFields
train
private function defaultFields() { $owner = $this->owner; $this->field_list = array( 'Root.Main' => array( 0 => TextField::create('Title', $owner->fieldLabel('Title')), 6 => HTMLEditorField::create('Content', $owner->fieldLabel('Content')), ...
php
{ "resource": "" }
q27666
NewsCMSExtension.siteConfigFields
train
private function siteConfigFields(News $owner, SiteConfig $siteConfig) { /** First the defaults */ if ($siteConfig->UseAbstract) { $this->field_list['Root.Main'][4] = TextareaField::create('Synopsis', $owner->fieldLabel('Synopsis')); } if ($siteConfig->AllowExternals) { ...
php
{ "resource": "" }
q27667
NewsCMSExtension.multipleNewsHolderPages
train
private function multipleNewsHolderPages() { $enabled = false; // If we have translations, disable translation filter to get all pages. if (class_exists('Translatable')) { $enabled = Translatable::disable_locale_filter(); } $pages = Versioned::get_by_stage('NewsHo...
php
{ "resource": "" }
q27668
NewsCMSExtension.existingItem
train
private function existingItem(News $owner, SiteConfig $siteConfig) { if (!$owner->ID) { $member = Member::currentUser(); $this->field_list['Root.Main'][13] = ReadonlyField::create('Tags', $owner->fieldLabel('Tags'), _t('News.TAGAFTERID', 'Tags can be added after the item has been sav...
php
{ "resource": "" }
q27669
NewsCMSExtension.displayLogic
train
private function displayLogic() { if (class_exists('DisplayLogicFormField') && count($this->type_array) > 1) { $this->field_list['Root.Main'][5]->hideUnless('Type')->isEqualTo('external'); $this->field_list['Root.Main'][6]->hideUnless('Type')->isEqualTo('news'); $this->fi...
php
{ "resource": "" }
q27670
NewsCMSExtension.setupFields
train
private function setupFields(News $owner, FieldList $fields) { // Remove all basic fields from parent, so we can setup as we wish. $fields->removeByName(array_keys($owner->db())); $fields->removeByName(array_keys($owner->has_one())); $fields->removeByName(array_keys($owner->has_many(...
php
{ "resource": "" }
q27671
Response.decode
train
private function decode($json) { // Attempt to fix bad UTF-8 data when the right flag is set on the client if (BaseClient::$flags & BaseClient::FLAG_ATTEMPT_UTF8_RECOVERY) if (!preg_match("//u", $json)) $json = utf8_encode(utf8_decode($json)); $response = json_decode($json); $errorCode = json_last_er...
php
{ "resource": "" }
q27672
StandardPermissions.providePermissions
train
public function providePermissions() { $permissions = array(); $config = Config::inst()->get('PublishProvider', 'classes'); foreach ($config as $class) { $subClasses = array_keys(ClassInfo::subclassesFor($class)); foreach ($subClasses as $subClass) { ...
php
{ "resource": "" }
q27673
DefaultFilters.filter_call
train
function filter_call ($instance, $method, ...$args) { if (is_object ($instance)) { if (is_object ($instance) && method_exists ($instance, $method)) return $instance->$method (...$args); if (isset($instance[$method]) && is_callable ($instance[$method])) { $m = $instance[$method]; return...
php
{ "resource": "" }
q27674
DefaultFilters.filter_assetUrl
train
function filter_assetUrl ($v) { /** @var ViewServiceInterface $viewService */ $viewService = $this->injector->make (ViewServiceInterface::class); $view = $viewService->currentView (); $path = $viewService->getModuleOfPath ($view->getPath ()); return "modules/$path/$v"; }
php
{ "resource": "" }
q27675
DefaultFilters.filter_extract
train
function filter_extract ($v, $field = 'id') { return map ($v, function ($e) use ($field) { return getField ($e, $field); }); }
php
{ "resource": "" }
q27676
DefaultFilters.filter_fileUrl
train
function filter_fileUrl ($v) { /** @var ContentRepositoryInterface $repo */ $repo = $this->injector->make (ContentRepositoryInterface::class); return $repo->getFileUrl ($v); }
php
{ "resource": "" }
q27677
Parser.subtag_check
train
private function subtag_check ($tagName) { $propName = lcfirst ($tagName); if ($this->current instanceof Metadata) { switch ($this->current->type) { // All descendants of a metadata property are always metadata. case type::metadata: return true; } // Descendants of ...
php
{ "resource": "" }
q27678
Parser.text_optimize
train
private function text_optimize (Component $c) { $o = []; $prev = null; if ($c->hasChildren ()) foreach ($c->getChildren () as $child) { if ($prev && $prev instanceof Text && !$prev->getBindings () && $child instanceof Text && !$child->getBin...
php
{ "resource": "" }
q27679
TimedRotatingFile.computeRollover
train
protected function computeRollover($currentTime) { if ($this->when == 'MIDNIGHT') { return strtotime("midnight + 1 day", $currentTime); } if (substr($this->when, 0, 1) == 'W') { return strtotime( "next " . self::$dayNames[$this->dayOfWeek], ...
php
{ "resource": "" }
q27680
TimedRotatingFile.getFilesToDelete
train
protected function getFilesToDelete() { $dirName = dirname($this->baseFilename); $baseName = basename($this->baseFilename); $fileNames = scandir($dirName); $result = array(); $prefix = $baseName . '.'; $plen = strlen($prefix); foreach ($fi...
php
{ "resource": "" }
q27681
ContainerBuilder.resolvePackage
train
public function resolvePackage($name) { $packages = $this->getPackages(); //most commonly we have Foobar or SupraPackageFoobar, which maps directly to package class //the other options is "foobar", which is mapped to AbstractPackage::getName foreach ($packages as $instance) { $class = get_class($instance);...
php
{ "resource": "" }
q27682
ContainerBuilder.buildTemplating
train
protected function buildTemplating($container) { $container['templating.global'] = function () { return new SupraGlobal(); }; $container['templating.templating'] = function () use ($container) { $templating = new TwigTemplating(); $templating->addGlobal('supra', $container['templating.global']); re...
php
{ "resource": "" }
q27683
ViewConfig.engine
train
public function engine($engineIdent = null) { if ($engineIdent === null) { $engineIdent = $this->defaultEngine(); } if (!is_string($engineIdent)) { throw new InvalidArgumentException( 'Invalid engine identifier (must be a string)' ); ...
php
{ "resource": "" }
q27684
Formatter.setPythonLike
train
public function setPythonLike($pythonLike) { if (!is_bool($pythonLike)) { throw new \Plop\Exception('Invalid value'); } $this->pythonLike = $pythonLike; return $this; }
php
{ "resource": "" }
q27685
Formatter.formatTime
train
protected function formatTime( \Plop\RecordInterface $record, $dateFormat = self::DEFAULT_DATE_FORMAT ) { $date = clone $record['createdDate']; if ($this->timezone !== null) { $date->setTimeZone($this->timezone); } return $date->format((string) $dateFormat...
php
{ "resource": "" }
q27686
Formatter.formatException
train
protected function formatException(\Exception $exception) { if (!$this->pythonLike) { $s = (string) $exception; if (substr($s, -1) == "\n") { $s = substr($s, 0, -1); } return $s; } $s = "Traceback (most recent call last):\...
php
{ "resource": "" }
q27687
Volume.fromLengths
train
public static function fromLengths(Length $length, Length $width, Length $height) { $length = $length->convertTo(UnitLength::meters()); $width = $width->convertTo(UnitLength::meters()); $height = $height->convertTo(UnitLength::meters()); $volume = $length->value() * $width->value() * $height->value(); $vol...
php
{ "resource": "" }
q27688
PagesContentController.getAction
train
public function getAction() { $localization = $this->getPageLocalization(); $pageRequest = $this->createPageRequest(); $pageController = $this->getPageController(); $templateException = $response = $internalHtml = null; try { $response = $pageController->execute($pageRequest); } catch (\Twig...
php
{ "resource": "" }
q27689
PagesContentController.insertBlockAction
train
public function insertBlockAction() { $this->isPostRequest(); $this->checkLock(); $pageRequest = $this->createPageRequest(); $blockComponentName = $this->getRequestParameter('type'); // Generate block according the page localization type provided $block = Block::factory($this->getPageLocalization()); ...
php
{ "resource": "" }
q27690
PagesContentController.deleteBlockAction
train
public function deleteBlockAction() { $this->isPostRequest(); $this->checkLock(); $blockId = $this->getRequestParameter('block_id'); $entityManager = $this->getEntityManager(); $block = $entityManager->find(Block::CN(), $blockId); if ($block === null) { throw new CmsException(null, sprintf('Block wi...
php
{ "resource": "" }
q27691
AbstractInlineTokenParser.removeHtmlTag
train
protected function removeHtmlTag(Node $body, $lineno) { if (0 === \count($body)) { $body = new Node([$body], [], $lineno); } $this->removeTagContent($body, 0, '/(|\ \\t|\\n|\\n\ \\t)<([a-zA-Z0-9]+)[a-zA-Z\=\'\"\ \/]+>(\\n?|\\r?)/'); $this->removeTagContent($body, \count(...
php
{ "resource": "" }
q27692
AbstractInlineTokenParser.removeTagContent
train
protected function removeTagContent(Node $body, $position, $pattern): void { if ($body->getNode($position) instanceof TextNode) { $positionBody = $body->getNode($position)->getAttribute('data'); $positionBody = preg_replace($pattern, '', $positionBody); $body->getNode($p...
php
{ "resource": "" }
q27693
ViewsAPITrait.findControllerForView
train
function findControllerForView ($viewName) { /** @var DocumentContext $this */ $path = $this->viewService->resolveTemplatePath ($viewName, $base); // inspect ($viewName, $base, $path); if (isset($this->controllers[$path])) return $this->controllers[$path]; foreach ($this->controllerNamespace...
php
{ "resource": "" }
q27694
MySqlEnumColumn.getEnumValues
train
public static function getEnumValues($modelName, $enumFieldName) { $schema = SolutionSchema::getModelSchema($modelName); $enum = $schema->getColumns()[$enumFieldName]; return $enum->enumValues; }
php
{ "resource": "" }
q27695
ValidateTrait.getErrors
train
public function getErrors(): array { $errors = $this->validate()->getErrors(); foreach ($errors as &$error) { if (is_string($error) && Translator::isMessage($error)) { // translate error message $error = $this->say($error); } unset...
php
{ "resource": "" }
q27696
SetWritePermissions.setPermissions
train
private function setPermissions() { if (!App::environment('production') || $this->option('force')) { $this->comment("Setting write permissions"); foreach ($this->writableDirectories as $path) { $this->process->setCommandLine('chmod -R 0777 ' . base_path($path)); ...
php
{ "resource": "" }
q27697
ObjectCreatorPage_FrontEndWorkflowController.getContextID
train
protected function getContextID() { $result = (int)$this->request->param('Action'); if ($result) { return $result; } return (int)$this->request->param('ID'); }
php
{ "resource": "" }
q27698
BlockController.editAction
train
public function editAction(Request $request) { $block = $this->findBlockByRequest($request); try { $response = $this->getEditor()->getBlockManager()->update($block, $request); } catch (EditorExceptionInterface $e) { return $this->handleException($e); } ...
php
{ "resource": "" }
q27699
BlockController.layoutAction
train
public function layoutAction(Request $request) { $block = $this->findBlockByRequest($request); $data = $request->request->get('data', []); try { $this->getEditor()->getLayoutAdapter()->updateBlockLayout($block, $data); } catch (EditorExceptionInterface $e) { ...
php
{ "resource": "" }