_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q28600 | BaseController.serialize | train | protected function serialize($data, $group = self::SERIALIZE_FULL)
{
return $this->get('serializer')->serialize($data, 'json', ['groups' => [$group]]);
} | php | {
"resource": ""
} |
q28601 | BaseController.getEditor | train | protected function getEditor()
{
if (null !== $this->editor) {
return $this->editor;
}
return $this->editor = $this
->get('ekyna_cms.editor.editor')
->setEnabled(true); // TODO Do this somewhere else
} | php | {
"resource": ""
} |
q28602 | Metadata.compile | train | public static function compile (array $metadata, Component $parent, $prepend = false)
{
foreach ($metadata as $item) {
if (!$item instanceof self) {
$parent->addChild ($item->cloneWithContext ($parent->context), $prepend);
continue;
}
$tag = $item->getTagName ();
$prop... | php | {
"resource": ""
} |
q28603 | CategoryTrait.findByPostType | train | public static function findByPostType($postTypeSlug)
{
$postType = PostType::findBySlug($postTypeSlug);
if($postType) {
return self::where('postTypeID', $postType->postTypeID)->get();
}
return;
} | php | {
"resource": ""
} |
q28604 | CategoryTrait.hasPosts | train | public static function hasPosts($postType, $categoriesID)
{
if(DB::table(categoriesRelationTable($postType))->where('categoryID', $categoriesID)->count()
) {
return true;
}else{
return false;
}
} | php | {
"resource": ""
} |
q28605 | CategoryTrait.isInMenuLinks | train | public static function isInMenuLinks($categoriesID)
{
$isInMenulinks = MenuLink::where('belongsToID', $categoriesID)->where('belongsTo', 'category')->count();
if ($isInMenulinks) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q28606 | CategoryTrait.addToMenu | train | public function addToMenu(Menu $menu)
{
if($this->postTypeID) {
$data = [
'menuID' => $menu->menuID,
'belongsToID' => $this->categoryID,
'belongsTo' => 'category',
'params' => $this->menuLinkParameters(),
'routeName'... | php | {
"resource": ""
} |
q28607 | CategoryTrait.updateMenulink | train | public static function updateMenulink($category)
{
if(self::isInMenuLinks($category->categoryID)) {
$menuLinks = MenuLink::where('belongsToID', $category->categoryID)->where('belongsTo', 'category')->get();
foreach($menuLinks as $menuLink){
$menuLink->params = $catego... | php | {
"resource": ""
} |
q28608 | CategoryTrait.getChildren | train | public function getChildren($parentID)
{
$tmp = [];
foreach($this->categoryList as $key => $item){
if($item->parentID == $parentID) {
$tmp[] = $item;
}
}
return $tmp;
} | php | {
"resource": ""
} |
q28609 | CategoryTrait.getAllChildren | train | public function getAllChildren($parentID)
{
$children = $this->getChildren($parentID);
foreach ($children as $key => $child){
$this->categoriesToBeDeleted[$child->categoryID] = $child;
$this->getAllChildren($child->categoryID);
}
} | php | {
"resource": ""
} |
q28610 | CategoryTrait.deleteChildren | train | public function deleteChildren(int $parentID, int $postTypeID)
{
$this->categoryList = self::where("postTypeID", $postTypeID)->get();
$this->getAllChildren($parentID);
foreach($this->categoriesToBeDeleted as $cat){
// Post type should not be able to be deleted if it has posts
... | php | {
"resource": ""
} |
q28611 | Utils.isValidHour | train | public static function isValidHour($time)
{
$result = preg_match('/^([0-9]{1,2}):([0-9]{1,2})(?::([0-9]{1,2}))?$/', $time, $regs);
if ($result) {
$hour = $regs[1];
$minutes = $regs[2];
$result = ($hour >= 0 && $hour < 24) && ($minutes >= 0 && $minutes < 60);... | php | {
"resource": ""
} |
q28612 | Utils.concatPath | train | public static function concatPath()
{
$args = func_get_args();
$len = count($args);
if ($len == 0) {
return '';
}
$path = $args[0];
for ($i = 1; $i < $len; $i++) {
$path = rtrim($path, '/') . '/' . ltrim($args[$i], '/');
}
... | php | {
"resource": ""
} |
q28613 | MenuTrait.getMenuLinks | train | public static function getMenuLinks($menuSlug)
{
// Set active MenuLinks
MenuLink::setActiveIDs(true);
$menuData = self::findBySlug($menuSlug);
$menuLinks = MenuLink::where('menuID', $menuData->menuID)->orderBy('order')->get();
if($menuLinks) {
return MenuLink::... | php | {
"resource": ""
} |
q28614 | MenuTrait.setPrimaryMenuID | train | public static function setPrimaryMenuID()
{
$primaryMenu = Menu::all()->where('isPrimary', 1)->first();
//if no primary menu is found, get the first one from the list
if (!$primaryMenu) {
$primaryMenu = Menu::first();
}
if (isset($primaryMenu->menuID)) {
... | php | {
"resource": ""
} |
q28615 | MenuTrait.printMenu | train | public static function printMenu($menuSlug = "primary", $customView = '', $ulClass = '')
{
$menuLinks = self::getMenuLinks($menuSlug);
if($menuLinks) {
return new HtmlString(
view()->make(
($customView ? $customView : "vendor.menulinks.bootstrap-4"), [... | php | {
"resource": ""
} |
q28616 | Plop.getLevelName | train | public function getLevelName($level)
{
if (!is_int($level)) {
throw new \Plop\Exception('Invalid level value');
}
if (!isset($this->levelNames[$level])) {
return "Level $level";
}
return $this->levelNames[$level];
} | php | {
"resource": ""
} |
q28617 | Plop.getLevelValue | train | public function getLevelValue($levelName)
{
if (!is_string($levelName)) {
throw new \Plop\Exception('Invalid level name');
}
$key = array_search($levelName, $this->levelNames, true);
return (int) $key; // false is silently converted to 0.
} | php | {
"resource": ""
} |
q28618 | Plop.getLogger | train | public function getLogger($namespace = '', $class = '', $method = '')
{
// Remove any potential namespace from the class and method names.
$class = substr($class, strrpos('\\' . $class, '\\'));
$method = substr($method, strrpos('\\' . $method, '\\'));
// If __METHOD__ was used inste... | php | {
"resource": ""
} |
q28619 | Plop.addLogger | train | public function addLogger(\Plop\LoggerInterface $logger /*, ... */)
{
$loggers = func_get_args();
foreach ($loggers as $logger) {
if (!($logger instanceof \Plop\LoggerInterface)) {
throw new \Plop\Exception('Not a logger');
}
}
foreach ($logge... | php | {
"resource": ""
} |
q28620 | Plop.getLoggerId | train | protected static function getLoggerId(\Plop\LoggerInterface $logger)
{
$func = $logger->getMethod();
$cls = $logger->getClass();
$ns = $logger->getNamespace();
return "$func:$cls:$ns";
} | php | {
"resource": ""
} |
q28621 | Plop.offsetSet | train | public function offsetSet($offset, $logger)
{
if (!($logger instanceof \Plop\LoggerInterface)) {
throw new \Plop\Exception('Invalid logger');
}
$id = static::getLoggerId($logger);
if (is_string($offset)) {
if ($offset != $id) {
throw new \Plop... | php | {
"resource": ""
} |
q28622 | Plop.offsetGet | train | public function offsetGet($offset)
{
if (!is_string($offset)) {
throw new \Plop\Exception('Invalid identifier');
}
$parts = explode(':', $offset, 3);
if (count($parts) != 3) {
throw new \Plop\Exception('Invalid identifier');
}
list($method, $c... | php | {
"resource": ""
} |
q28623 | Plop.offsetExists | train | public function offsetExists($offset)
{
if ($offset instanceof \Plop\LoggerInterface) {
$offset = static::getLoggerId($offset);
}
if (!is_string($offset)) {
throw new \Plop\Exception('Invalid identifier');
}
return isset($this->loggers[$offset]);
} | php | {
"resource": ""
} |
q28624 | Plop.offsetUnset | train | public function offsetUnset($offset)
{
if ($offset instanceof \Plop\LoggerInterface) {
$offset = static::getLoggerId($offset);
}
if ($offset == "::") {
throw new \Plop\Exception('The root logger cannot be unset');
}
unset($this->loggers[$offset]);
... | php | {
"resource": ""
} |
q28625 | Plop.findCaller | train | public static function findCaller()
{
if (version_compare(PHP_VERSION, '5.3.6', '>=')) {
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
} else {
$bt = debug_backtrace(false);
}
$max = count($bt);
$ns = __NAMESPACE__ . '\\';
$len ... | php | {
"resource": ""
} |
q28626 | WebpackRequireTagRenderer.preRender | train | protected function preRender(RequireTagInterface $tag)
{
if ($this->isNonExistentOptionalTag($tag)) {
return '';
}
$output = $this->doRender($tag, $tag->getPath());
$output .= $this->preRenderLocalized($tag);
return $output;
} | php | {
"resource": ""
} |
q28627 | WebpackRequireTagRenderer.doRender | train | protected function doRender(RequireTagInterface $tag, $assetName)
{
$type = $tag->getType();
$output = '';
if ($this->canBeRendered($assetName, $type)) {
$attributes = $this->prepareAttributes($tag, $assetName);
$this->assetRendered($assetName, $type);
$... | php | {
"resource": ""
} |
q28628 | WebpackRequireTagRenderer.preRenderLocalized | train | protected function preRenderLocalized(RequireTagInterface $tag)
{
$output = '';
foreach ($this->getLocalizedAssets($tag->getPath()) as $localeAsset) {
$output .= $this->doRender($tag, $localeAsset);
}
return $output;
} | php | {
"resource": ""
} |
q28629 | WebpackRequireTagRenderer.prepareAttributes | train | protected function prepareAttributes(RequireTagInterface $tag, $assetName)
{
$path = $this->getAssetPath($assetName, $tag->getType());
$attributes = $tag->getAttributes();
$attributes[$tag->getLinkAttribute()] = $path;
return $attributes;
} | php | {
"resource": ""
} |
q28630 | WebpackRequireTagRenderer.isNonExistentOptionalTag | train | protected function isNonExistentOptionalTag(RequireTagInterface $tag)
{
if (!$this->manager->has($tag->getPath(), $tag->getType())) {
if ($tag->isOptional()) {
return true;
}
throw new RequireTagRendererException($tag, sprintf('The %s %s "%s" is not manag... | php | {
"resource": ""
} |
q28631 | WebpackRequireTagRenderer.assetRendered | train | protected function assetRendered($assets, $type): void
{
$assets = (array) $assets;
foreach ($assets as $asset) {
$this->renderedTags[] = $type.'::'.$asset;
}
} | php | {
"resource": ""
} |
q28632 | Plugin.add | train | public function add($snippet, Callable $callable=null) {
if (is_object($snippet) && $snippet instanceof Snippets) {
$this->addSnippetClass($snippet);
}
if (is_string($snippet) && is_callable($callable)) {
// '$snippet' is a tag name: register $callable
$this->snippets[$snippet] = $callable;
}
} | php | {
"resource": ""
} |
q28633 | OpauthIdentity.factory | train | public static function factory(array $oaResponse) {
if(empty($oaResponse['auth'])) {
throw new InvalidArgumentException('The auth key is required to continue.');
}
if(empty($oaResponse['auth']['provider'])) {
throw new InvalidArgumentException('Unable to determine provider.');
}
$auth = $oaResponse['a... | php | {
"resource": ""
} |
q28634 | OpauthIdentity.onBeforeWrite | train | public function onBeforeWrite() {
parent::onBeforeWrite();
if(!$this->isInDb()) {
$this->_isCreating = true;
$this->extend('onBeforeCreate');
}
if($this->isChanged('MemberID')) {
$this->extend('onMemberLinked');
}
} | php | {
"resource": ""
} |
q28635 | OpauthIdentity.onAfterWrite | train | public function onAfterWrite() {
parent::onAfterWrite();
if($this->_isCreating === true) {
$this->_isCreating = false;
$this->extend('onAfterCreate');
}
} | php | {
"resource": ""
} |
q28636 | OpauthIdentity.findOrCreateMember | train | public function findOrCreateMember($usrSettings = array()) {
$defaults = array(
/**
* Link this identity to any newly discovered member.
*/
'linkOnMatch' => true,
/**
* True, false, or an array of fields to overwrite if we merge data.
* Exception to this rule is overwriteEmail, which takes p... | php | {
"resource": ""
} |
q28637 | MockDelegateFunctionBuilder.build | train | public function build($functionName = null)
{
$parameterBuilder = new ParameterBuilder();
$parameterBuilder->build($functionName);
$signatureParameters = $parameterBuilder->getSignatureParameters();
/**
* If a class with the same signature exists, it is considered equivalen... | php | {
"resource": ""
} |
q28638 | SlideShowExtension.renderSlideShow | train | public function renderSlideShow($slideShowOrTag, array $options = [])
{
if (is_string($slideShowOrTag)) {
$slideShowOrTag = $this->repository->findOneBy(['tag' => $slideShowOrTag]);
}
if (!$slideShowOrTag instanceof SlideShow) {
throw new \InvalidArgumentException("Ex... | php | {
"resource": ""
} |
q28639 | SysLog.encodePriority | train | protected function encodePriority($facility, $priority)
{
if (is_string($facility)) {
$facility = static::$facilityNames[$facility];
}
if (is_string($priority)) {
$priority = static::$priorityNames[$priority];
}
return ($facility << 3) | $priority;
... | php | {
"resource": ""
} |
q28640 | SysLog.close | train | protected function close()
{
if ($this->socket !== false) {
fclose($this->socket);
$this->socket = false;
}
} | php | {
"resource": ""
} |
q28641 | Detect.detectLocale | train | public function detectLocale(): self
{
$locale = null;
$detectors = [
FallbackDetector::class,
HiddenSegmentDetector::class,
SegmentDetector::class,
QueryDetector::class,
];
foreach ($detectors as $detector) {
$locale = ap... | php | {
"resource": ""
} |
q28642 | MenuEventListener.getMenuFromEvent | train | private function getMenuFromEvent(ResourceEventInterface $event)
{
$resource = $event->getResource();
if (!$resource instanceof MenuInterface) {
throw new InvalidArgumentException("Expected instance of MenuInterface");
}
return $resource;
} | php | {
"resource": ""
} |
q28643 | oAuthClientCredentials.clientCredentials | train | public function clientCredentials()
{
if (! $this->credentials) {
// $this->credentials = new ClientCredentials;
$this->credentials = new Credentials('client_credentials');
// Get API endpoints
$this->endpointDiscovery();
// Acquire the tokens an... | php | {
"resource": ""
} |
q28644 | oAuthClientCredentials.getOauthFields | train | private function getOauthFields()
{
$this->oAuthFields = [
'grant_type' => 'client_credentials',
'scope' => $this->scope,
'client_secret' => $this->mpClientSecret,
'client_id' => $this->mpClientId,
];
$this->fieldCount = count($this->oAuthFiel... | php | {
"resource": ""
} |
q28645 | oAuthClientCredentials.initCache | train | private function initCache()
{
// Create a new Container object, needed by the cache manager.
$container = new Container;
// The CacheManager creates the cache "repository" based on config values
$container['config'] = [
'cache.default' => 'file',
'cache.stor... | php | {
"resource": ""
} |
q28646 | ViewableTrait.fragment | train | public function fragment($method, array $params=[]) {
$c = clone $this; #clone to allow nested fragments
$c->view = null;
$c->defaultView = $method;
return $c->runTemplate($method, $params);
} | php | {
"resource": ""
} |
q28647 | ViewableTrait.solveTemplatePath | train | protected function solveTemplatePath($template) {
foreach(array_reverse($this->templatePathSolvers) as $s) {
if(($r = $s($this, $template)) && file_exists($r))
return $r;
}
} | php | {
"resource": ""
} |
q28648 | ViewableTrait.renderDefaultTemplate | train | protected function renderDefaultTemplate($template, $params=[]) {
if(!file_exists($template)) {
$template = $this->solveTemplatePath($orig = $template);
if(!file_exists($template))
throw new \Exception('The template file "'.$orig.'" could not be found.');
}
extract($params);
ob_start();
include($t... | php | {
"resource": ""
} |
q28649 | ApplicationLocale.get | train | public function get(): Locale
{
$locale = $this->originalLocale;
$convert_locales = $this->config->get('convert_locales');
$conversions = $this->config->get('convert_locales_to', []);
if ('auto' === $convert_locales) {
$locale = isset($conversions[$locale->get()])
... | php | {
"resource": ""
} |
q28650 | Area.fromLengthAndWidth | train | public static function fromLengthAndWidth(Length $length, Length $width)
{
$length = $length->convertTo(UnitLength::meters());
$width = $width->convertTo(UnitLength::meters());
$area = $length->value() * $width->value();
return new static($area, UnitArea::squareMeters());
} | php | {
"resource": ""
} |
q28651 | Speed.fromLengthAndDuration | train | public static function fromLengthAndDuration(Length $length, Duration $duration)
{
$meters = $length->convertTo(UnitLength::meters());
$seconds = $duration->convertTo(UnitDuration::seconds());
$speed = $meters->value() / $seconds->value();
return new static($speed, UnitSpeed::metersPerSecond());
} | php | {
"resource": ""
} |
q28652 | ExistingFileNameUploadFilter.validate | train | public function validate(FileAbstraction $entity, $typeName, $sourceFilePath = null)
{
$siblings = $entity->getSiblings();
$creatingFilename = $entity->getFileName();
foreach ($siblings as $record) {
/* @var $record File */
if ( ! $record->equals($entity)) {
$recordName = $record->getFileName();
... | php | {
"resource": ""
} |
q28653 | GnCache.GetCachedItem | train | public function GetCachedItem(string $propName, string $groupName, int $expiriesIn, $initFunc)
{
if (static::$DisableCache && $initFunc) {
if (GnApi::$Debug) {
GnLogger::Verbose("Cache is disable");
}
return $initFunc();
}
// In case memca... | php | {
"resource": ""
} |
q28654 | GnCache.ClearCache | train | public function ClearCache(string $keyPattern = NULL)
{
if (GnApi::$Debug) {
GnLogger::Verbose("Clear cache '{$keyPattern}'");
}
if (static::$CacheHandler) {
static::$CacheHandler->deleteKey($keyPattern);
static::$CacheHandler->deleteGroup($keyPattern);
... | php | {
"resource": ""
} |
q28655 | Acceleration.fromLengthAndDuration | train | public static function fromLengthAndDuration(Length $length, Duration $duration)
{
$meters = $length->convertTo(UnitLength::meters());
$seconds = $duration->convertTo(UnitDuration::seconds());
$acceleration = $meters->value() / ($seconds->value() * $seconds->value());
return new static($acceleration, UnitAcc... | php | {
"resource": ""
} |
q28656 | AssetExtension.setRenderers | train | public function setRenderers(array $renderers)
{
$this->renderers = [];
foreach ($renderers as $renderer) {
$this->addRenderer($renderer);
}
return $this;
} | php | {
"resource": ""
} |
q28657 | AssetExtension.createTagPosition | train | public function createTagPosition($category, $type, $lineno = -1, $name = null, $position = null)
{
$tag = $this->formatTagPosition($category, $type, $position);
if (\in_array($tag, $this->tagPositions, true)) {
throw new AlreadyExistTagPositionException($category, $type, $position, $li... | php | {
"resource": ""
} |
q28658 | AssetExtension.renderTags | train | public function renderTags($allPosition = true): void
{
$output = ob_get_contents();
$start = 0;
preg_match_all('/(<!--|\/\*)#tag-position:([\w0-9_:-]+):[\w0-9]+#(-->|\*\/)/', $output, $matches, PREG_OFFSET_CAPTURE);
ob_clean();
$this->renderContents($output, $matches, $star... | php | {
"resource": ""
} |
q28659 | AssetExtension.doRenderTags | train | protected function doRenderTags($contentType): void
{
if (isset($this->contents[$contentType])) {
$tags = $this->contents[$contentType];
/** @var TagRendererInterface[] $renderers */
$renderers = [];
$rendererTags = [];
foreach ($tags as $tag) {
... | php | {
"resource": ""
} |
q28660 | AssetExtension.findRenderer | train | protected function findRenderer(TagInterface $tag)
{
foreach ($this->getRenderers() as $renderer) {
if ($renderer->validate($tag)) {
return $renderer;
}
}
throw $this->buildRuntimeTagRendererException($tag);
} | php | {
"resource": ""
} |
q28661 | AssetExtension.buildRuntimeTagRendererException | train | protected function buildRuntimeTagRendererException(TagInterface $tag)
{
$msg = sprintf('No template tag renderer has been found for the "%s_%s" tag', $tag->getCategory(), $tag->getType());
if ($tag instanceof RequireTagInterface) {
$msg .= sprintf(' with the asset "%s"', $tag->getPath(... | php | {
"resource": ""
} |
q28662 | AssetExtension.validateRenderTags | train | protected function validateRenderTags($allPosition = true): void
{
if ($allPosition && !empty($this->contents)) {
$keys = array_keys($this->contents);
throw new MissingTagPositionException($this->contents[$keys[0]][0]);
}
} | php | {
"resource": ""
} |
q28663 | AssetExtension.getTagPosition | train | protected function getTagPosition($name, $category)
{
$pattern = 'inline' === $category
? '/*'.'%s'.'*/'
: '<!--%s-->';
return sprintf($pattern, '#tag-position:'.$name.':'.spl_object_hash($this).'#');
} | php | {
"resource": ""
} |
q28664 | AssetExtension.createTagPositionFunction | train | private function createTagPositionFunction($name, array $options)
{
$options = array_merge($options, [
'node_class' => 'Fxp\Component\RequireAsset\Twig\Node\TagPositionFunctionNode',
'is_safe' => ['html'],
'category' => null,
'type' => null,
], $option... | php | {
"resource": ""
} |
q28665 | ErrorHandler.register | train | public static function register() {
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(-1);
static::$reservedMemory = str_repeat('a', 10240);
static::$errorAtStart = error_get_last();
$errorHandler = new static();
set_error_handler([$errorHandler, 'phpErrorHandler']);
... | php | {
"resource": ""
} |
q28666 | ErrorHandler.shutdownFunction | train | public function shutdownFunction() {
if(($e=error_get_last()) && $e !== static::$errorAtStart) {
foreach($this->ignoreDirs as $dir) {
if(strpos($e['file'], $dir) === 0)
return;
}
while(ob_get_level()) ob_end_clean();
$exceptionHandler = set_exception_handler(function() {});
restore_exception_... | php | {
"resource": ""
} |
q28667 | ErrorHandler.getBacktraceFromException | train | public function getBacktraceFromException($e) {
$trace = $e->getTrace();
if($e instanceof FatalErrorException) {
#Credit to Symfony
if(function_exists('xdebug_get_function_stack')) {
$trace = array_slice(array_reverse(xdebug_get_function_stack()), 4);
foreach($trace as $i => $frame) {
if(!isset(... | php | {
"resource": ""
} |
q28668 | ErrorHandler.phpErrorHandler | train | public function phpErrorHandler($errno, $errstr, $errfile, $errline) {
foreach($this->ignoreDirs as $dir) {
if(strpos($errfile, $dir) === 0)
return;
}
if($this->isLogging() && $this->logPHPErrors)
$this->log(\Psr\Log\LogLevel::NOTICE, 'PHP ('.static::getPHPError($errno).'): '.$errstr, $errfile, $errlin... | php | {
"resource": ""
} |
q28669 | ErrorHandler.getPHPErrorSeverity | train | public static function getPHPErrorSeverity($code) {
$PHP_ERROR_LEVELS = [
E_PARSE => \Psr\Log\LogLevel::ERROR,
E_ERROR => \Psr\Log\LogLevel::ERROR,
E_CORE_ERROR => \Psr\Log\LogLevel::ERROR,
E_COMPILE_ERROR => \Psr\Log\LogLevel::ERROR,
E_USER_ERROR => \Psr\Log\LogLevel::ERROR,
E_RECOVERABLE_ERROR => ... | php | {
"resource": ""
} |
q28670 | DoctrineRepository.getMax | train | protected function getMax()
{
if ( ! $this->locked) {
//\Log::info('Should lock before changes');
}
$dql = "SELECT MAX(e.right) FROM {$this->className} e";
$dql .= $this->getAdditionalCondition('WHERE');
$query = $this->entityManager
->createQuery($dql);
$max = (int) $query->getSingleScalarResult()... | php | {
"resource": ""
} |
q28671 | DoctrineRepository.delete | train | public function delete(Node\NodeInterface $node)
{
if ( ! $this->locked) {
//\Log::info('Should lock before changes');
}
if ( ! $node instanceof Node\DoctrineNode) {
throw new Exception\WrongInstance($node, 'Node\DoctrineNode');
}
$left = $node->getLeftValue();
$right = $node->getRightValue();
... | php | {
"resource": ""
} |
q28672 | DoctrineRepository.search | train | public function search(SearchCondition\SearchConditionInterface $filter, SelectOrder\SelectOrderInterface $order = null)
{
$qb = $this->createSearchQueryBuilder($filter, $order);
$result = $qb->getQuery()
->getResult();
return $result;
} | php | {
"resource": ""
} |
q28673 | DoctrineRepository.destroy | train | public function destroy()
{
$this->arrayHelper->destroy();
$this->arrayHelper = null;
$this->entityManager = null;
} | php | {
"resource": ""
} |
q28674 | Component._ | train | static function _ (Component $parent, array $props = null, array $bindings = null)
{
return (string)static::create ($parent, $props, $bindings);
} | php | {
"resource": ""
} |
q28675 | Component.create | train | static function create (Component $parent, array $props = null, array $bindings = null)
{
return (new static)->setup ($parent, $parent->context, $props, $bindings);
} | php | {
"resource": ""
} |
q28676 | Component.setProps | train | function setProps (array $props = null)
{
if ($this->supportsProperties ()) {
if ($props)
$this->props->apply ($props);
}
else if ($props)
throw new ComponentException($this, 'This component does not support properties.');
} | php | {
"resource": ""
} |
q28677 | Component.setup | train | function setup (Component $parent = null, DocumentContext $context, $props = null, array $bindings = null)
{
if (is_object ($props)) {
$this->props = $props;
$props = [];
}
$this->setContext ($context);
$this->bindings = $bindings;
$this->onCreate ($props, $parent);
$this->se... | php | {
"resource": ""
} |
q28678 | TimestampableListener.onFlush | train | public function onFlush(OnFlushEventArgs $eventArgs)
{
$em = $eventArgs->getEntityManager();
$uow = $em->getUnitOfWork();
foreach ($uow->getScheduledEntityUpdates() as $entity) {
if ($entity instanceof TimestampableInterface) {
$entity->setModificationTime();
$className = get_class($entity);
$cla... | php | {
"resource": ""
} |
q28679 | Table.addColumn | train | public function addColumn(string $column, array $definition = []) : Table
{
$this->data['columns'][$column] = TableColumn::fromArray($column, $definition);
return $this;
} | php | {
"resource": ""
} |
q28680 | Table.addColumns | train | public function addColumns(array $columns) : Table
{
foreach ($columns as $column => $definition) {
if (is_numeric($column) && is_string($definition)) {
$this->addColumn($definition, []);
} else {
$this->addColumn($column, $definition);
}
... | php | {
"resource": ""
} |
q28681 | Table.setPrimaryKey | train | public function setPrimaryKey($column) : Table
{
if (!is_array($column)) {
$column = [ $column ];
}
$this->data['primary'] = $column;
return $this;
} | php | {
"resource": ""
} |
q28682 | Table.hasOne | train | public function hasOne(
Table $toTable,
string $name = null,
$toTableColumn = null,
string $sql = null,
array $par = []
) : Table {
$columns = $toTable->getColumns();
$keymap = [];
if (!isset($toTableColumn)) {
$toTableColumn = [];
... | php | {
"resource": ""
} |
q28683 | Table.manyToMany | train | public function manyToMany(
Table $toTable,
Table $pivot,
$name = null,
$toTableColumn = null,
$localColumn = null
) : Table {
$pivotColumns = $pivot->getColumns();
$keymap = [];
if (!isset($toTableColumn)) {
$toTableColumn = [];
}... | php | {
"resource": ""
} |
q28684 | Table.addRelation | train | public function addRelation(TableRelation $relation, string $name = null)
{
$name = $name ?? $relation->name;
$relation->name = $name;
$this->relations[$name] = $relation;
return $this;
} | php | {
"resource": ""
} |
q28685 | Table.renameRelation | train | public function renameRelation(string $name, string $new) : array
{
if (!isset($this->relations[$name])) {
throw new DBException("Relation not found");
}
if (isset($this->relations[$new])) {
throw new DBException("A relation with that name already exists");
}
... | php | {
"resource": ""
} |
q28686 | KernelEventListener.onKernelRequest | train | public function onKernelRequest(GetResponseEvent $event)
{
if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
return;
}
$request = $event->getRequest();
if (1 === intval($request->query->get('cms-editor-enable', 0))) {
$this->editor->set... | php | {
"resource": ""
} |
q28687 | KernelEventListener.onKernelResponse | train | public function onKernelResponse(FilterResponseEvent $event)
{
if ($this->editor->isEnabled()) {
$event
->getResponse()
->setSharedMaxAge(0)
->setMaxAge(0)
->setExpires(null)
->setLastModified(null)
-... | php | {
"resource": ""
} |
q28688 | Config.validateEachCanonicalLocaleExists | train | private function validateEachCanonicalLocaleExists(array $config)
{
$canonicals = $config['canonicals'] ?? [];
foreach ($canonicals as $locale => $canonical) {
if (!$this->existsAsLocale($config['locales'], $locale)) {
throw new InvalidConfig('Canonical key '.$locale.' is... | php | {
"resource": ""
} |
q28689 | GnUtil.GenerateRandomString | train | public static function GenerateRandomString(int $length = 20)
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[ran... | php | {
"resource": ""
} |
q28690 | AbstractAdapter.getAssetType | train | protected function getAssetType($asset, array $availables, $type)
{
$type = null === $type
? $this->findAssetType($asset, $availables)
: $this->formatAssetType($type);
if (null !== $type) {
return $type;
}
throw new InvalidArgumentException(sprin... | php | {
"resource": ""
} |
q28691 | Util.convertLocationCoordinates | train | public static function convertLocationCoordinates(Location $location)
{
$coordinates = $location->getCoordinates()->getCoordinates();
$coordinate = doubleval($coordinates[1]) . '%' . doubleval($coordinates[0]);
$coordinate = strtr($coordinate, [
'%'=>',',
','=>'.'
... | php | {
"resource": ""
} |
q28692 | Util.convertSolrDateToPhpDateTime | train | public static function convertSolrDateToPhpDateTime($solrDate)
{
$solrDate = trim($solrDate);
$dateTime = DateTime::createFromFormat(Manager::SOLR_DATE_FORMAT, $solrDate);
$valid = $dateTime && ($dateTime->format(Manager::SOLR_DATE_FORMAT) === $solrDate);
if (!$valid) {
... | php | {
"resource": ""
} |
q28693 | CustomerController.viewLoginAction | train | public function viewLoginAction()
{
if ($this->getSecurityContext()->hasCustomerUser()) {
// Redirect to home page
return $this->generateRedirect(URL::getInstance()->getIndexPage());
}
return $this->render("login");
} | php | {
"resource": ""
} |
q28694 | CustomerController.viewAction | train | public function viewAction()
{
$this->checkAuth();
/** @var Customer $customer */
$customer = $this->getSecurityContext()->getCustomerUser();
$newsletter = NewsletterQuery::create()->findOneByEmail($customer->getEmail());
$data = array(
'id' =>... | php | {
"resource": ""
} |
q28695 | CustomerController.logoutAction | train | public function logoutAction()
{
if ($this->getSecurityContext()->hasCustomerUser()) {
$this->dispatch(TheliaEvents::CUSTOMER_LOGOUT);
}
$this->clearRememberMeCookie($this->getRememberMeCookieName());
// Redirect to home page
return $this->generateRedirect(URL::... | php | {
"resource": ""
} |
q28696 | Group.isDescendant | train | public function isDescendant($group = null) {
if (is_numeric($group)) {
$group = Group::factory((int) $group);
}
if (!isset($group->guid)) {
return false;
}
// Check to see if the group is a descendant of the given group.
if (!isset($this->parent)) {
return false;
}
if ... | php | {
"resource": ""
} |
q28697 | Group.getDescendants | train | public function getDescendants($andSelf = false) {
$return = [];
$entities = Nymph::getEntities(
['class' => '\Tilmeld\Entities\Group'],
['&',
'equal' => ['enabled', true],
'ref' => ['parent', $this]
]
);
foreach ($entities as $entity) {
$childArray = $e... | php | {
"resource": ""
} |
q28698 | Group.getLevel | train | public function getLevel() {
$group = $this;
$level = 0;
while (isset($group->parent) && $group->parent->enabled) {
$level++;
$group = $group->parent;
}
return $level;
} | php | {
"resource": ""
} |
q28699 | Group.getUsers | train | public function getUsers($descendants = false) {
if ($descendants) {
$groups = $this->getDescendants();
$or = ['|',
'ref' => [
['group', $groups],
['groups', $groups]
]
];
} else {
$or = null;
}
$groups[] = $this;
$return = Nymph:... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.