_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q28000 | PostModel.getCategoriesAttribute | train | public function getCategoriesAttribute()
{
// Request category only if post type uses categories
$getPostType = getPostType($this->getTable());
if($getPostType->hasCategories) {
return $this->getRelationValue('categories');
}
return null;
} | php | {
"resource": ""
} |
q28001 | PostModel.getUserAttribute | train | public function getUserAttribute()
{
if($this->createdByUserID) {
// search in cache
$user = User::where('userID', $this->createdByUserID)->first();
// search in database
if (!$user) {
$user = $this->getRelationValue('user');
}
... | php | {
"resource": ""
} |
q28002 | PostModel.categories | train | public function categories()
{
$findPostType = PostType::findBySlug($this->getTable());
if(!$findPostType) {
throw new \Exception("Categories relations could not be made because the post type of the post #".$this->postID." could ont be found!");
}
return $this->customHas... | php | {
"resource": ""
} |
q28003 | GnCommentsApi.AddComment | train | public function AddComment(string $text, int $itemType = GnCommentItemType::Community, string $itemKey = NULL)
{
$result = $this->ExecuteCall("AddComment", (object)[
"itemType" => $itemType,
"itemKey" => $itemKey,
"text" => $text
], GnResponseType::Json, FALSE, PH... | php | {
"resource": ""
} |
q28004 | PageManager.copyLocalization | train | public function copyLocalization(
Localization $source,
LocaleInterface $targetLocale
) {
$deepCopy = new DeepCopy();
$entityManager = $this->container->getDoctrine()->getManagerForClass(get_class($source));
// Matches Localization::$master.
// Prevents AbstractPage to be cloned.
$deepCopy->addFilter... | php | {
"resource": ""
} |
q28005 | SwiftMessage.attachFile | train | public function attachFile($file, $options=[]) {
$attachment = \Swift_Attachment::fromPath($file);
if(isset($options['filename']))
$attachment->setFilename($options['filename']);
if(isset($options['mime']))
$attachment->setContentType($options['mime']);
return $this->attach($attachment);
} | php | {
"resource": ""
} |
q28006 | SwiftMessage.attachData | train | public function attachData($data, $options=[]) {
$attachment = \Swift_Attachment::newInstance($data);
if(isset($options['filename']))
$attachment->setFilename($options['filename']);
if(isset($options['mime']))
$attachment->setContentType($options['mime']);
return $this->attach($attachment);
} | php | {
"resource": ""
} |
q28007 | SwiftMessage.embedFile | train | public function embedFile($file, $options=[]) {
$image = \Swift_Image::fromPath($file);
if(isset($options['filename']))
$image->setFilename($options['filename']);
if(isset($options['mime']))
$image->setContentType($options['mime']);
return $this->embed($image);
} | php | {
"resource": ""
} |
q28008 | SwiftMessage.embedData | train | public function embedData($data, $options=[]) {
$image = \Swift_Image::newInstance($data);
if(isset($options['filename']))
$image->setFilename($options['filename']);
if(isset($options['mime']))
$image->setContentType($options['mime']);
return $this->embed($image);
} | php | {
"resource": ""
} |
q28009 | ImageInfo.process | train | public function process($filePath)
{
if ( ! is_string($filePath) && ! file_exists($filePath) && ! is_readable($filePath)) {
$this->error = 'Failed to get image path';
return;
}
$imageInfo = getimagesize($filePath);
if ($imageInfo === false) {
$this->error = 'Failed to get image information from path... | php | {
"resource": ""
} |
q28010 | ImageInfo.toArray | train | public function toArray()
{
return array(
'width' => $this->width,
'height' => $this->height,
'type' => $this->type,
'bits' => $this->bits,
'channels' => $this->channels,
'mime' => $this->mime,
'path' => $this->path,
'size' => $this->size,
'name' => $this->name,
'directory' => $this->di... | php | {
"resource": ""
} |
q28011 | PlaceHolder.addBlock | train | public function addBlock(Block $block)
{
if ($this->lock('block')) {
$this->matchDiscriminator($block);
if ($this->addUnique($this->blocks, $block)) {
$block->setPlaceHolder($this);
}
$this->unlock('block');
}
} | php | {
"resource": ""
} |
q28012 | PlaceHolder.removeBlock | train | public function removeBlock(Block $block)
{
if (! $this->equals($block->getPlaceHolder())
|| ! $this->blocks->contains($block)) {
throw new \InvalidArgumentException('Block does not belongs to this placeholder.');
}
$position = $block->getPosition();
$this->blocks->removeElement($block);
foreach (... | php | {
"resource": ""
} |
q28013 | PlaceHolder.setMaster | train | public function setMaster(Localization $localization)
{
$this->matchDiscriminator($localization);
if ($this->writeOnce($this->localization, $localization)) {
$this->localization->addPlaceHolder($this);
}
} | php | {
"resource": ""
} |
q28014 | PlaceHolder.factory | train | public static function factory(Localization $localization, $name, PlaceHolder $source = null)
{
$placeHolder = null;
switch ($localization::DISCRIMINATOR) {
case self::TEMPLATE_DISCR:
$placeHolder = new TemplatePlaceHolder($name);
break;
case self::PAGE_DISCR:
case self::APPLICATION_DISCR:
... | php | {
"resource": ""
} |
q28015 | Arr.get | train | public static function get(array $data, string $key, $defaultValue = null)
{
$data = self::dataByPath($data, $key);
if ($data === null) {
$data = $defaultValue;
}
return $data;
} | php | {
"resource": ""
} |
q28016 | Arr.set | train | public static function set(array &$array, string $key, $value, bool $create = false): void
{
// Extract key/path.
$keyLast = Str::last($key, '.');
$key = Str::removeLast($key, '.');
// Extract data.
$pathArray = null;
if ($key !== '' && $key !== null) {
$... | php | {
"resource": ""
} |
q28017 | Arr.first | train | public static function first(array $data, ?string $key = null)
{
if (count($data) === 0) {
return null;
}
reset($data);
$element = current($data);
if ($key !== null && is_array($element) && isset($element[$key])) {
return $element[$key];
}
... | php | {
"resource": ""
} |
q28018 | Arr.last | train | public static function last(array $data, ?string $key = null)
{
if (count($data) === 0) {
return null;
}
$element = end($data);
if ($key !== null && is_array($element) && isset($element[$key])) {
return $element[$key];
}
return $element;
} | php | {
"resource": ""
} |
q28019 | Arr.isStringInList | train | public static function isStringInList(array $list, ?string $key = null): bool
{
$stringInList = false;
if (count($list) === 0) {
return $stringInList;
}
foreach ($list as $item) {
if ($key !== null && isset($item[$key])) {
$value = $item[$key];... | php | {
"resource": ""
} |
q28020 | Arr.keysExist | train | public static function keysExist(array $data, array $keys): bool
{
if (count($keys) > 0) {
foreach ($keys as $key) {
if (!array_key_exists($key, $data)) {
return false;
}
}
}
return true;
} | php | {
"resource": ""
} |
q28021 | Arr.lineMatch | train | public static function lineMatch(
array $lines,
string $prefix,
string $suffix,
bool $doTrim,
bool $removePrefixSuffix = false
): array {
$result = [];
foreach ($lines as $line) {
$isHit = true;
if ($prefix !== '' && $prefix !== null &&... | php | {
"resource": ""
} |
q28022 | Arr.toJson | train | public static function toJson(array $array, bool $prettyPrint = true, bool $unescapedSlashes = true): string
{
$options = 0;
if ($unescapedSlashes) {
$options += JSON_UNESCAPED_SLASHES;
}
if ($prettyPrint) {
$options += JSON_PRETTY_PRINT;
}
ret... | php | {
"resource": ""
} |
q28023 | Arr.& | train | private static function &dataByPath(array &$data, string $key, bool $create = false, $defaultValue = null)
{
if ($key === '') {
return $data;
}
$pathSegments = explode('.', $key);
foreach ($pathSegments as $pathSegment) {
if (!is_array($data)) {
... | php | {
"resource": ""
} |
q28024 | Configuration.addSeoSection | train | private function addSeoSection(ArrayNodeDefinition $node)
{
/** @noinspection PhpUndefinedMethodInspection */
$node
->children()
->arrayNode('seo')
->addDefaultsIfNotSet()
->children()
->booleanNode('no_follo... | php | {
"resource": ""
} |
q28025 | Configuration.addMenuSection | train | private function addMenuSection(ArrayNodeDefinition $node)
{
/** @noinspection PhpUndefinedMethodInspection */
$node
->children()
->arrayNode('menu')
->addDefaultsIfNotSet()
->children()
->arrayNode('roots')
... | php | {
"resource": ""
} |
q28026 | Configuration.addSlideShowSection | train | private function addSlideShowSection(ArrayNodeDefinition $node)
{
/** @noinspection PhpUndefinedMethodInspection */
$node
->children()
->arrayNode('slide_show')
->addDefaultsIfNotSet()
->children()
->arrayNod... | php | {
"resource": ""
} |
q28027 | Configuration.addSchemaOrgSection | train | private function addSchemaOrgSection(ArrayNodeDefinition $node)
{
/** @noinspection PhpUndefinedMethodInspection */
$node
->children()
->arrayNode('schema_org')
->addDefaultsIfNotSet()
->children()
->arrayNod... | php | {
"resource": ""
} |
q28028 | Snippets.isValidDomainName | train | protected function isValidDomainName($domain_name) {
return (preg_match('/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i', $domain_name) //valid chars check
&& preg_match('/^.{1,253}$/', $domain_name) //overall length check
&& preg_match('/^[^\.]{1,63}(\.[^\.]{1,63})*$/', $domain_name) ) //length of each... | php | {
"resource": ""
} |
q28029 | Snippets.getHtmlAttributes | train | protected function getHtmlAttributes($attributes) {
$list = array();
foreach ($attributes as $name=>$value) {
if (!empty($value)) {
if (is_scalar($value)) {
$list[] = "$name='" . htmlentities($value, ENT_QUOTES, "UTF-8") . "'";
} elseif (is_array($value)) {
$list[] = $this->getHtmlAttributes($v... | php | {
"resource": ""
} |
q28030 | MediaManager.getMedia | train | private function getMedia($timetable, $externalStopPointId = false)
{
$seasonCategory = $this->getSeasonCategory(
$timetable->getLineConfig()->getSeason()->getPerimeter()->getExternalNetworkId(),
$timetable->getExternalRouteId(),
$timetable->getLineConfig()->getSeason()->... | php | {
"resource": ""
} |
q28031 | Logger.log | train | public function log($message): void
{
$defaults = [
'SEVERITY' => 'INFO',
'AUDIT_TYPE_ID' => $this->auditTypeId,
'ITEM_ID' => $this->itemId ?: '',
];
$message = $this->logMessToArray($message);
CEventLog::Add(array_merge($defaults, $message, ['MODULE_ID' => $this->moduleId]));
} | php | {
"resource": ""
} |
q28032 | Logger.debug | train | public function debug($message): void
{
$message = $this->logMessToArray($message);
$this->log(array_merge(['SEVERITY' => 'DEBUG'], $message));
} | php | {
"resource": ""
} |
q28033 | Logger.warning | train | public function warning($message): void
{
$message = $this->logMessToArray($message);
$this->log(array_merge(['SEVERITY' => 'WARNING'], $message));
} | php | {
"resource": ""
} |
q28034 | Logger.error | train | public function error($message): void
{
$message = $this->logMessToArray($message);
$this->log(array_merge(['SEVERITY' => 'ERROR'], $message));
} | php | {
"resource": ""
} |
q28035 | Logger.security | train | public function security($message): void
{
$message = $this->logMessToArray($message);
$this->log(array_merge(['SEVERITY' => 'SECURITY'], $message));
} | php | {
"resource": ""
} |
q28036 | DB.buildPDO | train | public function buildPDO(array $config=null) {
if(!$config)
$config = $this->config;
$driver = $config['driver'];
$user = isset($config['user']) ? $config['user']:'root';
$password = isset($config['password']) ? $config['password']:'';
$database = isset($config['database']) ? $config['database']:null... | php | {
"resource": ""
} |
q28037 | Command.callSilent | train | public function callSilent($command, array $arguments = []) {
$instance = $this->getApplication()->find($command);
$arguments['command'] = $command;
return $instance->run(new ArrayInput($arguments), new NullOutput);
} | php | {
"resource": ""
} |
q28038 | Command.confirm | train | public function confirm($questionStr) {
$helper = $this->getHelperSet()->get('question');
$question = new ConfirmationQuestion($questionStr.' (yes/no)', false);
return $helper->ask($this->input, $this->output, $question);
} | php | {
"resource": ""
} |
q28039 | PregReplaceFilterStream.fillBuffer | train | private function fillBuffer($length)
{
$fill = intval(max([$length, 8192]));
while ($this->buffer->getSize() < $length) {
$read = $this->stream->read($fill);
if ($read === false || $read === '') {
break;
}
$this->buffer->write(preg_repl... | php | {
"resource": ""
} |
q28040 | AbstractSyntaxHighlighterTwigExtension.syntaxHighlighterConfig | train | protected function syntaxHighlighterConfig(SyntaxHighlighterConfig $config) {
$template = [];
$template[] = "SyntaxHighlighter.config.bloggerMode = " . StringHelper::parseBoolean($config->getBloggerMode()) . ";";
$template[] = "SyntaxHighlighter.config.stripBrs = " . StringHelper::parseBoolean... | php | {
"resource": ""
} |
q28041 | AbstractSyntaxHighlighterTwigExtension.syntaxHighlighterDefaults | train | protected function syntaxHighlighterDefaults(SyntaxHighlighterDefaults $defaults) {
$template = [];
$template[] = "SyntaxHighlighter.defaults['auto-links'] = " . StringHelper::parseBoolean($defaults->getAutoLinks()) . ";";
$template[] = "SyntaxHighlighter.defaults['class-name'] = \"" . $defaul... | php | {
"resource": ""
} |
q28042 | AbstractSyntaxHighlighterTwigExtension.syntaxHighlighterStrings | train | protected function syntaxHighlighterStrings(SyntaxHighlighterStrings $strings) {
$template = [];
$template[] = "SyntaxHighlighter.config.strings.alert = \"" . $strings->getAlert() . "\";";
$template[] = "SyntaxHighlighter.config.strings.brushNotHtmlScript = \"" . $strings->getBrushNotHtmlScrip... | php | {
"resource": ""
} |
q28043 | ChunkSplitStream.getChunkedString | train | private function getChunkedString($string)
{
$firstLine = '';
if ($this->tell() !== 0) {
$next = $this->lineLength - ($this->position % ($this->lineLength + $this->lineEndingLength));
if (strlen($string) > $next) {
$firstLine = substr($string, 0, $next) . $thi... | php | {
"resource": ""
} |
q28044 | ChunkSplitStream.write | train | public function write($string)
{
$chunked = $this->getChunkedString($string);
$this->position += strlen($chunked);
return $this->stream->write($chunked);
} | php | {
"resource": ""
} |
q28045 | PresenterMapper.formatPresenterClass | train | public function formatPresenterClass(string $presenter): string
{
if (isset($this->presenterMapping[$presenter])) {
return $this->presenterMapping[$presenter];
}
$parts = explode(':', $presenter);
$presenterName = (string) array_pop($parts);
$modules = [];
... | php | {
"resource": ""
} |
q28046 | PresenterMapper.unformatPresenterClass | train | public function unformatPresenterClass(string $class): ?string
{
$presenter = array_search($class, $this->presenterMapping, true);
if ($presenter !== false) {
return (string) $presenter;
}
foreach ($this->moduleMapping as $module => $mapping) {
$mapping = str... | php | {
"resource": ""
} |
q28047 | EditorController.pagesListAction | train | public function pagesListAction(Request $request)
{
$repository = $this->get('ekyna_cms.page.repository');
$lastModifiedAt = $repository->getLastUpdatedAt();
$response = new Response();
$response->headers->set('Content-Type', 'application/json');
$response->setLastModified(... | php | {
"resource": ""
} |
q28048 | EditorController.buildConfig | train | private function buildConfig(Request $request)
{
$editor = $this->getEditor();
$config = $editor->getConfig();
unset($config['layout']);
$locales = [];
foreach ($config['locales'] as $locale) {
$locales[] = [
'name' => $locale,
'... | php | {
"resource": ""
} |
q28049 | EkynaCmsExtension.registerSocialSubjectEventSubscriber | train | private function registerSocialSubjectEventSubscriber(ContainerBuilder $container)
{
$definition = new Definition('Ekyna\Bundle\CmsBundle\EventListener\SocialSubjectEventListener');
$definition->addArgument(new Reference('ekyna_cms.helper.page'));
$definition->addArgument(new Reference('rout... | php | {
"resource": ""
} |
q28050 | EkynaCmsExtension.configureSlideShow | train | private function configureSlideShow(ContainerBuilder $container, $config)
{
$registry = $container->getDefinition('ekyna_cms.slide_show.registry');
$container->setParameter('ekyna_cms.slide_show.static', $config['static']);
$container->setParameter('ekyna_cms.slide_show.themes', $config['th... | php | {
"resource": ""
} |
q28051 | EkynaCmsExtension.registerImageFilters | train | private function registerImageFilters(ContainerBuilder $container)
{
$medias = [
'lg' => 1140,
'md' => 940,
'sm' => 720,
'xs' => 480,
];
$filterSets = [];
foreach ($medias as $size => $width) {
for ($column = 1; $column <=... | php | {
"resource": ""
} |
q28052 | InspectSniffCommand.appendCommandOptions | train | private function appendCommandOptions(array $commandParts)
{
foreach ($this->options as $optionKey) {
// Skip tab-width option because it's appended by default.
if ($optionKey == 'tab-width') {
continue;
}
$optionValue = $this->option($optionK... | php | {
"resource": ""
} |
q28053 | AddressController.createAction | train | public function createAction()
{
$this->checkAuth();
$addressCreate = $this->createForm(FrontForm::ADDRESS_CREATE);
try {
/** @var Customer $customer */
$customer = $this->getSecurityContext()->getCustomerUser();
$form = $this->validateForm($addressCrea... | php | {
"resource": ""
} |
q28054 | TLoadFile.loadFile | train | public function loadFile($filename, $expose = [])
{
$anaxInstallPath = ANAX_INSTALL_PATH . "/config/$filename";
$anaxAppPath = ANAX_APP_PATH . "/config/$filename";
extract($expose);
if (is_readable($anaxAppPath)) {
return require $anaxAppPath;
} elseif (is_readab... | php | {
"resource": ""
} |
q28055 | Manager.addOptions | train | public function addOptions(array $options): void
{
foreach ($options as $key => $option) {
$this->addOption($key, $option);
}
} | php | {
"resource": ""
} |
q28056 | Manager.addTab | train | public function addTab(string $id, array $tab): void
{
$this->optionTabs[] = array_merge($tab, ['DIV' => $id]);
} | php | {
"resource": ""
} |
q28057 | Manager.addTabs | train | public function addTabs(array $tabs): void
{
foreach ($tabs as $key => $tab) {
$this->addTab($key, $tab);
}
} | php | {
"resource": ""
} |
q28058 | Manager.loadOptionValues | train | private function loadOptionValues(): void
{
$this->optionValues = array_merge(
Option::getDefaults($this->moduleId),
Option::getForModule($this->moduleId)
);
} | php | {
"resource": ""
} |
q28059 | Manager.get | train | public function get(string $name)
{
if (empty($this->optionValues)) {
$this->loadOptionValues();
}
return $this->optionValues[$name];
} | php | {
"resource": ""
} |
q28060 | BackgroundPlugin.upgrade | train | private function upgrade(ContainerInterface $container)
{
$data = array_replace(self::DEFAULT_DATA, $container->getData());
if (isset($data['media_id'])) {
$data['image']['media'] = $data['media_id'];
unset($data['media_id']);
}
if (isset($data['video_id'])) ... | php | {
"resource": ""
} |
q28061 | HtmlProcessor.getPlaces | train | public function getPlaces($layoutSrc)
{
$places = array();
// Ignore CDATA
$cdataCallback = function($cdata) {};
// Collect place holders
$macroCallback = function($func, array $args) use (&$places, $layoutSrc) {
if ($func == HtmlProcessor::PLACE_HOLDER) {
if ( ! array_key_exists(0, $args) || $a... | php | {
"resource": ""
} |
q28062 | HtmlProcessor.getFileName | train | protected function getFileName($layoutSrc)
{
$filename = $this->getLayoutDir() . \DIRECTORY_SEPARATOR . $layoutSrc;
if ( ! is_file($filename)) {
throw new LayoutNotFound("File '$layoutSrc' was not found");
}
if ( ! is_readable($filename)) {
throw new \RuntimeException("File '$layoutSrc' is not readable")... | php | {
"resource": ""
} |
q28063 | TFBCLoadAdditionalContent.orderToc | train | private function orderToc($baseRoute, $meta)
{
$defaults = [
"orderby" => "section",
"orderorder" => "asc",
];
$options = array_merge($defaults, $meta);
$orderby = $options["orderby"];
$order = $options["orderorder"];
$toc = $this->meta[$base... | php | {
"resource": ""
} |
q28064 | TFBCLoadAdditionalContent.limitToc | train | private function limitToc(&$toc, &$meta, $baseRoute = null)
{
$defaults = [
"items" => 7,
"offset" => 0,
];
$options = array_merge($defaults, $meta);
// Check if pagination is currently used
if ($this->currentPage) {
$options["offset"] = (... | php | {
"resource": ""
} |
q28065 | Autoloader.load | train | public function load($class)
{
$class = ltrim($class, '\\');
if (strncasecmp($class, 'Plop\\', 4)) {
return false;
}
if (strpos($class, '://') !== false) {
throw new \Exception('Possible exploitation attempt detected');
}
$class = str_replace... | php | {
"resource": ""
} |
q28066 | Uri.toString | train | public function toString()
{
$result = '';
if (!empty($this->scheme)) {
$result.= $this->scheme . ':';
}
if (!empty($this->authority)) {
$result.= '//' . $this->authority;
}
$result.= $this->path;
if (!empty($this->query)) {
... | php | {
"resource": ""
} |
q28067 | Uri.parse | train | protected function parse($uri)
{
$uri = (string) $uri;
$matches = array();
preg_match('!' . self::getPattern() . '!', $uri, $matches);
$scheme = isset($matches[2]) ? $matches[2] : null;
$authority = isset($matches[4]) ? $matches[4] : null;
$path = isset(... | php | {
"resource": ""
} |
q28068 | ResultConverter.convert | train | public function convert(AbstractPaginationQuery $filter, ArrayAccess $response)
{
$entities = [];
$ids = [];
$return = [];
if (!isset($response['response'])
|| !isset($response['response']['docs'])
|| !is_array($response['response']['docs'])) {
th... | php | {
"resource": ""
} |
q28069 | CDI.get | train | public function get($service)
{
// Is the service active?
if (isset($this->active[$service])) {
if ($this->loaded[$service]['singleton']) {
return $this->active[$service];
} else {
return $this->load($service);
}
} elseif (i... | php | {
"resource": ""
} |
q28070 | CDI.load | train | protected function load($service)
{
$sol = isset($this->loaded[$service]['loader'])
? $this->loaded[$service]['loader']
: null;
// Load by calling a function
if (is_callable($sol)) {
try {
$this->active[$service] = $sol();
} ca... | php | {
"resource": ""
} |
q28071 | DCR_Sniffs_Debug_JSCSSniff.parseMessages | train | protected function parseMessages($lines) {
$messages = array();
$message = array();
foreach ($lines as $line) {
if (empty($line) & !empty($message)) {
$messages[] = $message;
$message = array();
continue;
}
$message[] = $line;
}
return $messages;
} | php | {
"resource": ""
} |
q28072 | DCR_Sniffs_Debug_JSCSSniff.parseLineNumber | train | protected function parseLineNumber($lines) {
$number = 0;
foreach ($lines as $k => $line) {
if (strpos($line, '----') === 0) {
$string = trim($lines[$k - 1]);
$string = explode('|', $string);
$number = trim($string[0]);
break;
}
}
return (int) $number;
} | php | {
"resource": ""
} |
q28073 | MySqlModelSchema.checkSchema | train | public function checkSchema(Repository $inRepository)
{
try {
/** @var MySql $repos */
$repos = get_class($inRepository);
if (stripos($repos, "MySql") === false) {
// If our repos has been switched to something that isn't MySql (e.g. Offline if unit testi... | php | {
"resource": ""
} |
q28074 | MySqlModelSchema.createTable | train | private function createTable()
{
$sql = "CREATE TABLE `" . $this->schemaName . "` (";
$definitions = [];
foreach ($this->columns as $columnName => $column) {
// The column might be using a more generic type for it's storage.
$storageColumns = $column->createStorageC... | php | {
"resource": ""
} |
q28075 | UserManager.getNetworks | train | public function getNetworks($user = null)
{
if ($user == null) {
$user = $this->container->get('security.context')->getToken()->getUser();
}
if ($user === 'anon.') {
return (array());
}
$perimeters = $user->getCustomer()->getPerimeters();
if (... | php | {
"resource": ""
} |
q28076 | MakeDummy.setDefaultOption | train | private function setDefaultOption(string $app, int $value)
{
$this->defaultsOptions[$app] = $value;
return $this;
} | php | {
"resource": ""
} |
q28077 | MakeDummy.getDefaultOption | train | public function getDefaultOption(string $app)
{
if($this->option($app)) {
return $this->option($app);
}
if(!isset($this->defaultsOptions[$app])) {
throw new \Exception('Option '.$app.' is not configured');
}
return $this->defaultsOptions[$app];
} | php | {
"resource": ""
} |
q28078 | MakeDummy.createPostTypes | train | private function createPostTypes()
{
if(!$this->option('posts') && ($this->option('post_types') || $this->option('all'))) {
$this->comment('Creating dummy Post Types...');
$output = (new \PostTypeSeeder())
->setCommand($this)
->run($this->getDefaultOpt... | php | {
"resource": ""
} |
q28079 | Meta.display | train | public function display($defaults = array(), $displayTitle = false)
{
$metaAttributes = array_replace_recursive($defaults, $this->attributes);
$results = array();
// Handle other custom properties.
foreach($metaAttributes as $name => $content) {
if ($name === 'keywords'... | php | {
"resource": ""
} |
q28080 | Meta.prepareKeywords | train | private function prepareKeywords($keywords)
{
if ($keywords === null)
return null;
if (is_array($keywords))
$keywords = implode(', ', $keywords);
return strtolower(strip_tags($keywords));
} | php | {
"resource": ""
} |
q28081 | Meta.processNestedAttributes | train | private function processNestedAttributes($property, $content)
{
$results = array();
if ($this->isAssociativeArray($content)) {
foreach ($content as $key => $value) {
$results = array_merge($results, $this->processNestedAttributes("{$property}:{$key}", $value));
... | php | {
"resource": ""
} |
q28082 | BlockController.prepare | train | final public function prepare(PageRequest $request)
{
$this->request = $request;
$this->response = $this->createBlockResponse($request);
$this->properties = $request->getBlockPropertySet()
->getBlockPropertySet($this->block);
try {
$this->doPrepare();
} catch (\Exception $e) {
$this->exception ... | php | {
"resource": ""
} |
q28083 | BlockController.getPropertyViewValue | train | public function getPropertyViewValue($name, array $options = array())
{
$property = $this->getProperty($name);
$propertyConfig = $this->config->getProperty($name);
if ($propertyConfig instanceof Config\PropertyCollectionConfig) {
return new BlockPropertyCollectionValue($property, $propertyConfig, $this, $opt... | php | {
"resource": ""
} |
q28084 | MainController.index | train | public function index($lang = "", $view = "")
{
$classNameArr = explode("\\", get_class($this));
$className = str_replace("Controller", "", $classNameArr[4]);
// check if user has permissions to access this link
$key = ($view == 'list' || $view == '') ? 'read' : $view;
if(!Us... | php | {
"resource": ""
} |
q28085 | MainController.getAll | train | public function getAll($lang = "")
{
$classNameArr = explode("\\", get_class($this));
$className = "App\\Models\\".str_replace("Controller", "", $classNameArr[4]);
$rowsPerPage = $className::$rowsPerPage;
$class = new $className();
$obj = DB::table($class->table);
if... | php | {
"resource": ""
} |
q28086 | MainController.single | train | public function single($lang, $view, $id)
{
$classNameArr = explode("\\", get_class($this));
$className = str_replace("Controller", "", $classNameArr[4]);
// if we are accessing Post Type check if we are are in category or tags and repair the class name and key for them
$key = $view;... | php | {
"resource": ""
} |
q28087 | MainController.getAllWithoutPagination | train | public function getAllWithoutPagination($lang = "")
{
$classNameArr = explode("\\", get_class($this));
$className = "App\\Models\\".str_replace("Controller", "", $classNameArr[4]);
$class = new $className();
return $class->all();
} | php | {
"resource": ""
} |
q28088 | MainController.generateSlug | train | public function generateSlug($title, $tableName, $primaryKey, $languageSlug = '', $id = 0, $translatable = false,
$hasVirtualSlug = false, $delimiter = "-"
) {
$count = 0;
$found = true;
$originalSlug = str_slug($title, $delimiter);
while($found){
if($count != 0)... | php | {
"resource": ""
} |
q28089 | MainController.response | train | protected function response($message, $code = 200, $itemID = null, $redirectToView = '', $redirectUrl = '', $returnInputErrors = false, $errorsList = [], $noty = [])
{
// if we have input errors in the validator
if($returnInputErrors) {
return response()->json(
array(
... | php | {
"resource": ""
} |
q28090 | PdoRepository.getPdoParamName | train | public static function getPdoParamName($columnName)
{
if (isset(self::$pdoParamAliasesUsed[$columnName])) {
self::$pdoParamAliasesUsed[$columnName]++;
return $columnName . self::$pdoParamAliasesUsed[$columnName];
} else {
self::$pdoParamAliasesUsed[$columnName] =... | php | {
"resource": ""
} |
q28091 | PdoRepository.getDefaultConnection | train | public static function getDefaultConnection()
{
if (self::$defaultConnection === null) {
$databaseSettings = StemSettings::singleton();
self::$defaultConnection = static::getConnection($databaseSettings);
if ($databaseSettings->stickyWriteConnection) {
s... | php | {
"resource": ""
} |
q28092 | PdoRepository.executeStatement | train | public static function executeStatement($statement, $namedParameters = [], $connection = null, &$insertedId = null)
{
if ($connection === null) {
$connection = static::getDefaultConnection();
}
self::$secondLastStatement = self::$lastStatement;
self::$lastStatement = $st... | php | {
"resource": ""
} |
q28093 | PdoRepository.returnSingleValue | train | public static function returnSingleValue($statement, $namedParameters = [], $connection = null)
{
$statement = self::executeStatement(
$statement,
$namedParameters,
$connection !== null ? $connection : static::getReadOnlyConnection()
);
return $statement-... | php | {
"resource": ""
} |
q28094 | PdoRepository.returnFirstRow | train | public static function returnFirstRow($statement, $namedParameters = [], $connection = null)
{
$statement = self::executeStatement(
$statement,
$namedParameters,
$connection !== null ? $connection : static::getReadOnlyConnection()
);
return $statement->fe... | php | {
"resource": ""
} |
q28095 | AbstractParser.parse | train | public function parse(string $input)
{
$ts = $this->lexer->tokenize($input);
$parseResult = $this->parseImplementation($ts);
if ($ts->hasPendingTokens()) {
throw new SyntaxErrorException('There are tokens not processed.');
}
return $parseResult;
} | php | {
"resource": ""
} |
q28096 | LanguageTrait.current | train | public static function current(string $column ='')
{
if(isset(self::$current->$column)) {
return self::$current->$column;
}
return self::$current;
} | php | {
"resource": ""
} |
q28097 | LanguageTrait.setCurrent | train | public static function setCurrent(string $languageSlug)
{
$languageData = self::findBySlug($languageSlug);
if ($languageData) {
App::setLocale($languageSlug);
Carbon::setLocale($languageSlug);
self::$current = $languageData;
} else {
self::$cu... | php | {
"resource": ""
} |
q28098 | LanguageTrait.setFromURL | train | public static function setFromURL(Request $request)
{
if(!\Request::route('lang')) {
// language may be present in url without {param} defined
$detectLanguageFromRequest = \App\Models\Language::detectLanguageFromRequest($request);
if ($detectLanguageFromRequest) {
... | php | {
"resource": ""
} |
q28099 | LanguageTrait.printLanguages | train | public static function printLanguages($customView = '', $ulClass='')
{
return new HtmlString(
view()->make(
($customView ? $customView : "vendor.languages.default"), [
'languages' => Language::all(),
'ulClass' => $ulClass,
]
... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.