_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q29600 | BaseTagController.deleteTag | train | private function deleteTag($id)
{
$tags = Tag::find($id);
if(Tag::hasPosts($id)) {
return $this->response("You can't delete this Tag. There are posts associated with it.", 403);
}
if ($tags->delete()) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q29601 | BaseTagController.store | train | public function store(Request $request)
{
// check if user has permissions to access this link
if(!User::hasAccess('Tags', 'create')) {
return $this->noPermission();
}
$validatorData = [
'title' => 'required',
'postTypeID' => 'required',
... | php | {
"resource": ""
} |
q29602 | BaseTagController.detailsJSON | train | public function detailsJSON($lang, $id)
{
// check if user has permissions to access this link
if(!User::hasAccess('Tags', 'update')) {
return $this->noPermission();
}
$tags = Tag::find($id);
$media = Media::find($tags->featuredImageID);
$final = array(
... | php | {
"resource": ""
} |
q29603 | BaseTagController.getAllWithoutPaginationByPostType | train | public function getAllWithoutPaginationByPostType($lang = "", $postType = "")
{
return DB::table('tags')->join('post_type', 'post_type.postTypeID', 'tags.postTypeID')->where('post_type.slug', $postType)->orderBy('name', 'postTypeID')->get();
} | php | {
"resource": ""
} |
q29604 | MenuProvider.findByName | train | public function findByName($name)
{
$this->loadMenus();
$rootId = 0;
if (0 < strpos($name, ':')) {
list($rootName, $name) = explode(':', $name);
if (null === $root = $this->findByName($rootName)) {
throw new \InvalidArgumentException(sprintf('Root men... | php | {
"resource": ""
} |
q29605 | MenuProvider.get | train | public function get($name, array $options = [])
{
if (null === $menu = $this->findByName($name)) {
throw new \InvalidArgumentException(sprintf('The menu "%s" is not defined.', $name));
}
return $this->buildItem($menu, array_merge([
'attributes' => ['id' => $menu['nam... | php | {
"resource": ""
} |
q29606 | MenuProvider.buildItem | train | private function buildItem(array $data, array $options = [])
{
$options = array_merge($options, [
'label' => $data['title'],
]);
if (!empty($data['attributes'])) {
$options['attributes'] = $data['attributes'];
}
// Fix routing / url / path
if ... | php | {
"resource": ""
} |
q29607 | TableQuery.filter | train | public function filter(string $column, $value, bool $negate = false) : self
{
$sql = $this->filterSQL($column, $value, $negate);
return strlen($sql[0]) ? $this->where($sql[0], $sql[1]) : $this;
} | php | {
"resource": ""
} |
q29608 | TableQuery.any | train | public function any(array $criteria) : self
{
$sql = [];
$par = [];
foreach ($criteria as $row) {
if (isset($row[1])) {
$temp = $this->filterSQL($row[0], $row[1] ?? null, $row[2] ?? false);
$sql[] = $temp[0];
$par = array_merge($par... | php | {
"resource": ""
} |
q29609 | TableQuery.sort | train | public function sort(string $column, bool $desc = false) : self
{
return $this->order($this->getColumn($column)['name'] . ' ' . ($desc ? 'DESC' : 'ASC'));
} | php | {
"resource": ""
} |
q29610 | TableQuery.paginate | train | public function paginate(int $page = 1, int $perPage = 25) : self
{
return $this->limit($perPage, ($page - 1) * $perPage);
} | php | {
"resource": ""
} |
q29611 | TableQuery.reset | train | public function reset() : self
{
$this->where = [];
$this->joins = [];
$this->group = [];
$this->withr = [];
$this->order = [];
$this->having = [];
$this->aliases = [];
$this->li_of = [0,0,0];
$this->qiterator = null;
return $this;
... | php | {
"resource": ""
} |
q29612 | TableQuery.groupBy | train | public function groupBy(string $sql, array $params = []) : self
{
$this->qiterator = null;
$this->group = [ $sql, $params ];
return $this;
} | php | {
"resource": ""
} |
q29613 | TableQuery.order | train | public function order(string $sql, array $params = []) : self
{
$this->qiterator = null;
$name = null;
if (!count($params)) {
$name = preg_replace('(\s+(ASC|DESC)\s*$)i', '', $sql);
try {
$name = $this->getColumn(trim($name))['name'];
} cat... | php | {
"resource": ""
} |
q29614 | TableQuery.limit | train | public function limit(int $limit, int $offset = 0, bool $limitOnMainTable = false) : self
{
$this->qiterator = null;
$this->li_of = [ $limit, $offset, $limitOnMainTable ? 1 : 0 ];
return $this;
} | php | {
"resource": ""
} |
q29615 | TableQuery.insert | train | public function insert(array $data) : array
{
$table = $this->definition->getName();
$columns = $this->definition->getFullColumns();
$insert = [];
foreach ($data as $column => $value) {
if (isset($columns[$column])) {
$insert[$column] = $this->normalizeVal... | php | {
"resource": ""
} |
q29616 | TableQuery.update | train | public function update(array $data) : int
{
$table = $this->definition->getName();
$columns = $this->definition->getFullColumns();
$update = [];
foreach ($data as $column => $value) {
if (isset($columns[$column])) {
$update[$column] = $this->normalizeValue... | php | {
"resource": ""
} |
q29617 | TableQuery.delete | train | public function delete() : int
{
$table = $this->definition->getName();
$sql = 'DELETE FROM '.$table.' ';
$par = [];
if (count($this->where)) {
$sql .= 'WHERE ';
$tmp = [];
foreach ($this->where as $v) {
$tmp[] = $v[0];
... | php | {
"resource": ""
} |
q29618 | TableQuery.with | train | public function with(string $relation) : self
{
$this->qiterator = null;
$parts = explode('.', $relation);
$table = $this->definition;
array_reduce(
$parts,
function ($carry, $item) use (&$table) {
$relation = $table->getRelation($item);
... | php | {
"resource": ""
} |
q29619 | Tracker.getList | train | public function getList($db=true) {
if(!file_exists($this->dir.'/migrations.json'))
return [];
$migrations = json_decode(file_get_contents($this->dir.'/migrations.json'), true);
if($db) {
$tracking = [];
$this->createTable();
foreach($this->db->dal()->from('_migrations')->get() as $r)
$tracking[... | php | {
"resource": ""
} |
q29620 | Tracker.getDownList | train | public function getDownList() {
$list = $this->getList();
foreach($list as $migration=>$params) {
if(isset($params['migrated']))
unset($list[$migration]);
}
return $list;
} | php | {
"resource": ""
} |
q29621 | Tracker.getUpList | train | public function getUpList() {
$list = $this->getList();
foreach($list as $migration=>$params) {
if(!isset($params['migrated']))
unset($list[$migration]);
}
return $list;
} | php | {
"resource": ""
} |
q29622 | Tracker.getNext | train | public function getNext() {
$list = $this->getList();
foreach($list as $migration=>$params) {
if(!isset($params['migrated']))
return $migration;
}
} | php | {
"resource": ""
} |
q29623 | Tracker.getLast | train | public function getLast() {
$list = array_reverse($this->getList());
foreach($list as $migration=>$params) {
if(isset($params['migrated']))
return $migration;
}
} | php | {
"resource": ""
} |
q29624 | Tracker.getRevereMigratedUntil | train | public function getRevereMigratedUntil($untilMigration) {
$list = [];
if(!in_array($untilMigration, array_keys($this->getList())))
throw new \Exception($untilMigration.' is not in the list.');
foreach(array_reverse($this->getList()) as $migration=>$params) {
if(isset($params['migrated']))
$list[] = $mig... | php | {
"resource": ""
} |
q29625 | Tracker.add | train | public function add($migrationName) {
$list = $this->getList(false);
if(isset($list[$migrationName]))
return;
$list[$migrationName] = ['added'=>time()+microtime(true)];
$this->writeMigrations($list);
} | php | {
"resource": ""
} |
q29626 | Tracker.remove | train | public function remove($migrationName) {
$list = $this->getList(false);
unset($list[$migrationName]);
$this->writeMigrations($list);
} | php | {
"resource": ""
} |
q29627 | Tracker.unmigrate | train | public function unmigrate($migrationName) {
$this->createTable();
$this->db->dal()->from('_migrations')->where('name', $migrationName)->delete();
} | php | {
"resource": ""
} |
q29628 | Tracker.migrate | train | public function migrate($migrationName) {
$this->createTable();
$this->db->dal()->into('_migrations')->insert(['name'=>$migrationName, 'migrated'=>date('Y-m-d H:i:s')]);
} | php | {
"resource": ""
} |
q29629 | Tracker.writeMigrations | train | protected function writeMigrations($res) {
uasort($res, function($a, $b) {
if(isset($a['migrated']) && !isset($b['migrated']))
return -1;
elseif(!isset($a['migrated']) && isset($b['migrated']))
return 1;
elseif(isset($a['migrated']) && isset($b['migrated'])) {
if($a['migrated'] !== $b['migrated']... | php | {
"resource": ""
} |
q29630 | ParameterDetector.detect | train | public function detect(Request $request)
{
if ($request->isMethod('post')) {
return $request->request->get($this->parameterName);
}
return $request->query->get($this->parameterName);
} | php | {
"resource": ""
} |
q29631 | GnNearbyApi.GetTracksAround | train | public function GetTracksAround(string $community = NULL)
{
$result = $this->ExecuteCall("GetTracksAround", (object)[
"community" => $community
], GnResponseType::ListGnTrack, FALSE, PHP_INT_MAX);
return $result;
} | php | {
"resource": ""
} |
q29632 | Localization.getParent | train | public function getParent()
{
$master = $this->getMaster();
if (empty($master)) {
return null;
}
$parent = $master->getParent();
if (empty($parent)) {
return null;
}
/* @var $parent AbstractPage */
$parentData = $parent->getLocalization($this->locale);
return $parentData;
} | php | {
"resource": ""
} |
q29633 | Localization.getPublicChildren | train | public function getPublicChildren()
{
$coll = $this->getChildren(PageLocalization::CN());
foreach ($coll as $key => $child) {
if ( ! $child instanceof PageLocalization) {
$coll->remove($key);
continue;
}
if ( ! $child->isPublic()) {
$coll->remove($key);
continue;
}
}
return $coll... | php | {
"resource": ""
} |
q29634 | Localization.setPagePriority | train | public function setPagePriority($pagePriority)
{
if ($pagePriority < 0 || $pagePriority > 1) {
throw new \UnexpectedValueException(sprintf('The valid range is from 0.0 to 1.0, [%s] received.', $pagePriority));
}
$this->pagePriority = $pagePriority;
} | php | {
"resource": ""
} |
q29635 | AccioInstall.createDefaultTheme | train | private function createDefaultTheme()
{
$this->info("Creating default theme...");
// Delete default theme, so we later get the latest version from git
$defaultThemePath = base_path('themes/'.config('project.defaultTheme'));
if(file_exists($defaultThemePath)) {
File::del... | php | {
"resource": ""
} |
q29636 | AccioInstall.setBar | train | private function setBar($steps = 14)
{
if($this->option('deleteUploads')) {
$steps++;
}
$this->bar = $this->output->createProgressBar($steps);
return $this;
} | php | {
"resource": ""
} |
q29637 | AccioInstall.welcomeMessage | train | private function welcomeMessage()
{
$this->block(' -- Welcome to CMS -- ', 'fg=white;bg=green;options=bold');
$this->line('');
$this->line('Please answer the following questions:');
$this->line('');
return $this;
} | php | {
"resource": ""
} |
q29638 | AccioInstall.successfullyInstalled | train | private function successfullyInstalled()
{
$this->line('');
$this->block('Success! Accio is now installed', 'fg=black;bg=green');
$this->line('');
$this->header('Next steps');
$this->line('');
$instructions = [
'Visit your website <options=bold>' . $this->A... | php | {
"resource": ""
} |
q29639 | AccioInstall.createDummyContent | train | private function createDummyContent()
{
$this->info("Creating default roles...");
UserGroup::createDefaultRoles();
$this->advanceBar();
$this->info("Creating admin user...");
$this->createAdminUser();
$this->advanceBar();
// Create Default Language
$... | php | {
"resource": ""
} |
q29640 | AccioInstall.saveConfiguration | train | private function saveConfiguration()
{
$this->info("Writing configuration file...");
// Save in .env file
$this->env->setEnv(
[
'APP_URL' => $this->APP_URL,
'DB_CONNECTION' => $this->DB_TYPE,
'DB_HOST' => $this->DB_HOST,
'DB_PORT' ... | php | {
"resource": ""
} |
q29641 | AccioInstall.askInstallingQuestions | train | private function askInstallingQuestions()
{
// Database information
$this->DB_TYPE = $this->ask('Your Database type', config('database.default'));
$this->DB_HOST = $this->ask('Your DB_HOST', config('database.connections.'.$this->DB_TYPE.'.host'));
$this->DB_PORT = $this->ask('Your DB... | php | {
"resource": ""
} |
q29642 | AccioInstall.setSettings | train | private function setSettings()
{
Settings::setSetting('siteTitle', $this->APP_NAME);
Settings::setSetting('adminEmail', $this->ADMIN_EMAIL);
Settings::setSetting('defaultUserRole', 'admin');
Settings::setSetting('timezone', $this->TIMEZONE);
Settings::setSetting('logo', 1);
... | php | {
"resource": ""
} |
q29643 | AccioInstall.createAdminUser | train | private function createAdminUser()
{
$user = factory(User::class)->create(
[
'firstName' => $this->ADMIN_FIRST_NAME,
'lastName' => $this->ADMIN_LAST_NAME,
'slug' => str_slug($this->ADMIN_FIRST_NAME.'-'.$this->ADMIN_LAST_NAME),
'email' => $this->ADM... | php | {
"resource": ""
} |
q29644 | AccioInstall.DBConnectComand | train | private function DBConnectComand()
{
/*
* Check Database Connection
*/
switch ($this->DB_TYPE){
case 'sqlite':
$dsn = 'sqlite:'.$this->DB_DATABASE;
$this->validateSqliteFile($this->DB_DATABASE);
break;
case 'pgsql':
$ds... | php | {
"resource": ""
} |
q29645 | AccioInstall.validateSqliteFile | train | protected function validateSqliteFile($DB_DATABASE)
{
if (!file_exists($DB_DATABASE)) {
$directory = dirname($DB_DATABASE);
if (!is_dir($directory)) {
mkdir($directory, 0644, true);
}
new \PDO('sqlite:' . $DB_DATABASE);
}
retu... | php | {
"resource": ""
} |
q29646 | AccioInstall.askAboutDefaultLanguage | train | private function askAboutDefaultLanguage()
{
$languageList = [];
foreach(Language::ISOlist() as $language){
$languageList[] = $language->name;
}
$languageName = $this->anticipate('What is your site\'s primary language?', $languageList, 'English');
$this->PRIMARY_... | php | {
"resource": ""
} |
q29647 | ViewBuilder.buildContent | train | public function buildContent(Model\ContentInterface $content)
{
$view = new ContentView();
$attributes = $view->getAttributes()->addClass('cms-content');
if ($this->editor->isEnabled()) {
$attributes
->setId('cms-content-' . $content->getId())
->s... | php | {
"resource": ""
} |
q29648 | ViewBuilder.buildContainer | train | public function buildContainer(Model\ContainerInterface $container)
{
// Rendering source (for copy containers)
$source = is_null($container->getCopy()) ? $container : $container->getCopy();
$view = new ContainerView();
$attributes = $view->getAttributes()->addClass('cms-container')... | php | {
"resource": ""
} |
q29649 | ViewBuilder.buildRow | train | public function buildRow(Model\RowInterface $row)
{
$view = new RowView();
$attributes = $view->getAttributes()->addClass('cms-row');
if ($this->editor->isEnabled()) {
$container = $row->getContainer();
$attributes
->setId('cms-row-' . $row->getId())... | php | {
"resource": ""
} |
q29650 | ViewBuilder.buildBlock | train | public function buildBlock(Model\BlockInterface $block)
{
$editable = $this->editor->isEnabled();
$view = new BlockView();
$attributes = $view->getAttributes()->addClass('cms-block');
if ($editable) {
$row = $block->getRow();
$attributes
->s... | php | {
"resource": ""
} |
q29651 | PathInfo.getDirList | train | public function getDirList(): array
{
if (!$this->hasDirs()) {
return [];
}
$path = \str_replace('\\', '/', \trim($this->dirs));
// Drop any leading and trailing "/"s.
$path = \trim($path, '/');
// Drop pointless consecutive "/"s.
while (false !== ... | php | {
"resource": ""
} |
q29652 | FilePathNormalizer.normalizeFile | train | public function normalizeFile(string $file, int $options = self::MODE_DEFAULT): string
{
$file = \str_replace('\\', '/', $file);
if (false === \strrpos($file, '/')) {
$mess = 'An empty path is NOT allowed';
throw new \DomainException($mess);
}
[$fileName, $pat... | php | {
"resource": ""
} |
q29653 | FilePathNormalizer.normalizePath | train | public function normalizePath(string $path, int $options = self::MODE_DEFAULT): string
{
$this->validateOptions($options);
$pathInfo = $this->getPathInfo();
$pathInfo->initAll($path);
$this->checkWrappers($options);
$this->absoluteChecks($options);
$path = '';
... | php | {
"resource": ""
} |
q29654 | FilePathNormalizer.checkWrappers | train | protected function checkWrappers(int $options)
{
$hasWrappers = $this->getPathInfo()
->hasWrappers();
if (($options & self::WRAPPER_DISABLED) && $hasWrappers) {
$mess = 'Given wrapper when wrapper(s) are disabled';
throw new \DomainException($mess)... | php | {
"resource": ""
} |
q29655 | FilePathNormalizer.cleanPartsPath | train | protected function cleanPartsPath(): array
{
$parts = [];
foreach ($this->getPathInfo()
->getDirList() as $part) {
if ('.' === $part) {
continue;
}
if ('..' === $part) {
/*
* Though path may st... | php | {
"resource": ""
} |
q29656 | FilePathNormalizerTrait.getFpn | train | public function getFpn(): FilePathNormalizerInterface
{
if (null === $this->fpn) {
$this->fpn = new FilePathNormalizer();
}
return $this->fpn;
} | php | {
"resource": ""
} |
q29657 | TalendClient.factory | train | public static function factory($config = array())
{
$defaults = array();
$required = array(
'base_url',
'login',
'password'
);
$config = Collection::fromConfig($config, $defaults, $required);
$client = new self($config['base_url'], $conf... | php | {
"resource": ""
} |
q29658 | FormManager.initialize | train | protected function initialize()
{
if (is_null($this->synchronizerToken)) {
$this->synchronizerToken = new SynchronizerTokenNativeSession();
}
if (is_null($this->validator)) {
$this->validator = new Validator($this->configuration, $this->getTranslator());
}
... | php | {
"resource": ""
} |
q29659 | FormManager.prepareConfiguration | train | protected function prepareConfiguration(array $options=null)
{
$configuration = clone $this->configuration;
if (is_array($options)) {
$options = array_replace($configuration->all(), $options);
$configuration = new Configuration($options);
}
return $configurati... | php | {
"resource": ""
} |
q29660 | FormManager.createFormCollection | train | public function createFormCollection(array $entities, $name, array $options=null)
{
$configuration = $this->prepareConfiguration($options);
$this->initialize();
$form = new FormCollection($entities, $name, $configuration);
if (!is_null($validator = $this->validator)) {
... | php | {
"resource": ""
} |
q29661 | eZPageBlock.toXML | train | public function toXML( DOMDocument $dom )
{
$blockNode = $dom->createElement( 'block' );
foreach ( $this->attributes as $attrName => $attrValue )
{
switch ( $attrName )
{
case 'id':
$blockNode->setAttribute( 'id', 'id_' . $attrValu... | php | {
"resource": ""
} |
q29662 | eZPageBlock.createFromXML | train | public static function createFromXML( DOMElement $node )
{
$newObj = new eZPageBlock();
if ( $node->hasAttributes() )
{
foreach ( $node->attributes as $attr )
{
if ( $attr->name == 'id' )
{
$value = explode( '_', $a... | php | {
"resource": ""
} |
q29663 | eZPageBlock.removeProcessed | train | public function removeProcessed()
{
if ( $this->hasAttribute( 'action' ) )
{
unset( $this->attributes['action'] );
}
if ( $this->getItemCount() > 0 )
{
unset( $this->attributes['items'] );
}
return $this;
} | php | {
"resource": ""
} |
q29664 | eZPageBlock.merge | train | protected function merge( $items, $mergeAdded = false )
{
$itemObjects = array();
foreach ( $items as $item )
{
$oid = $item['object_id'];
$itemObjects[$oid] = new eZPageBlockItem( $item, false );
}
if ( isset( $this->attributes['items'] ) && $this->a... | php | {
"resource": ""
} |
q29665 | eZPageBlock.getWaitingItems | train | protected function getWaitingItems()
{
$waitingItems = eZFlowPool::waitingItems( $this->id() );
$merged = $this->merge( $waitingItems, true );
usort( $merged, array( $this, 'sortItems' ) );
return $merged;
} | php | {
"resource": ""
} |
q29666 | eZPageBlock.getValidItems | train | protected function getValidItems()
{
$validItems = eZFlowPool::validItems( $this->id() );
$merged = $this->merge( $validItems );
usort( $merged, array( $this, 'sortItemsByPriority' ) );
return $merged;
} | php | {
"resource": ""
} |
q29667 | eZPageBlock.getLastValidItem | train | protected function getLastValidItem()
{
$validItems = $this->getValidItems();
$result = null;
if( !empty( $validItems ) )
{
$result = null;
$lastTime = 0;
foreach($validItems as $item)
{
if( $item -> attribute( 'ts_visib... | php | {
"resource": ""
} |
q29668 | eZPageBlock.sortItems | train | public function sortItems( eZPageBlockItem $a, eZPageBlockItem $b )
{
if ( $a->attribute('priority') == $b->attribute('priority') )
{
if ( $a->attribute('ts_publication') > $b->attribute('ts_publication') )
{
return 1;
}
else if ( $a->a... | php | {
"resource": ""
} |
q29669 | eZPageBlock.sortItemsByPriority | train | public function sortItemsByPriority( eZPageBlockItem $a, eZPageBlockItem $b )
{
if ( $a->attribute('priority') > $b->attribute('priority') )
{
return -1;
}
else if ( $a->attribute('priority') < $b->attribute('priority') )
{
return 1;
}
... | php | {
"resource": ""
} |
q29670 | Component.iocContainer | train | protected function iocContainer()
{
if (
property_exists($this, 'container')
&& isset($this->container)
&& $this->container instanceof ContainerInterface
) {
return $this->container;
}
/*
* Technically your code can work witho... | php | {
"resource": ""
} |
q29671 | TreeGrid.renderTableRow | train | public function renderTableRow($model, $key, $index)
{
$cells = [];
/* @var $column TreeColumn */
foreach ($this->columns as $column) {
$cells[] = $column->renderDataCell($model, $key, $index);
}
if ($this->rowOptions instanceof Closure) {
$options = c... | php | {
"resource": ""
} |
q29672 | TreeGrid.renderTableFooter | train | public function renderTableFooter()
{
$cells = [];
foreach ($this->columns as $column) {
/* @var $column TreeColumn */
$cells[] = $column->renderFooterCell();
}
$content = Html::tag('tr', implode('', $cells), $this->footerRowOptions);
return "<tfoot>\n... | php | {
"resource": ""
} |
q29673 | TreeGrid.renderItems | train | public function renderItems()
{
$rows = [];
$this->dataProvider->setKeys([]);
$models = array_values($this->dataProvider->getModels());
$models = $this->normalizeData($models, $this->parentRootValue);
$this->dataProvider->setModels($models);
$this->dataProvider->setKe... | php | {
"resource": ""
} |
q29674 | TreeGrid.normalizeData | train | protected function normalizeData(array $data, $parentId = null) {
$result = [];
foreach ($data as $element) {
if (ArrayHelper::getValue($element, $this->parentColumnName) === $parentId) {
$result[] = $element;
$children = $this->normalizeData($data, ArrayHelpe... | php | {
"resource": ""
} |
q29675 | GeotNotifications.notify | train | public static function notify( $msg ) {
self::$msg = $msg;
add_action( 'wp_footer', [ self::class, 'print_message' ], 999 );
if ( isset( $_GET['page'] ) && 'geot-settings' == $_GET['page'] ) {
add_action( 'admin_footer', [ self::class, 'print_message' ], 999 );
}
} | php | {
"resource": ""
} |
q29676 | BlocksAdderMenu.build | train | public function build(array $elements)
{
$parsedElements = $this->parse($elements);
$result = $this->group($parsedElements);
return $result;
} | php | {
"resource": ""
} |
q29677 | Validator.setLanguage | train | public function setLanguage($lang = 'en', $langDir = __DIR__ . '/lang/')
{
$this->lang = $lang;
$this->langDir = $langDir;
$langFile = realpath($langDir . $lang . '.php');
if (!file_exists($langFile)) {
throw new \InvalidArgumentException('No such file: ' . $langDir .... | php | {
"resource": ""
} |
q29678 | Validator.setRuleMessage | train | public function setRuleMessage(string $name, string $message)
{
$this->messages['rules'][$name] = $message;
return $this;
} | php | {
"resource": ""
} |
q29679 | Validator.setAttributeMessage | train | public function setAttributeMessage(string $name, string $message)
{
$this->messages['custom'][$name] = $message;
return $this;
} | php | {
"resource": ""
} |
q29680 | Validator.reset | train | public function reset()
{
// Remove all rules and messages
$this->rules = [];
$this->messages = ['rules' => [], 'custom' => []];
$this->clear();
// Add the initial rules and messages
Validate::addRuleSet($this);
$this->setLanguage($this->lang, $this->langDir)... | php | {
"resource": ""
} |
q29681 | Validator.getProcessedErrors | train | public function getProcessedErrors()
{
$errors = [];
foreach ($this->errors as $error) {
// Process replacements
$message = ArrDots::get($this->messages['custom'], $error['attribute'])
?? ArrDots::get($this->messages['rules'], $error['rule']);
... | php | {
"resource": ""
} |
q29682 | Login.onSuccess | train | protected function onSuccess()
{
$redirectionUrl = "";
// First check if the model has a target for redirection in mind.
if (isset($this->model->redirectUrl)) {
$redirectionUrl = $this->model->redirectUrl;
}
if (!$redirectionUrl){
// Finally fallback... | php | {
"resource": ""
} |
q29683 | Login.isRedirectionUrlValid | train | protected function isRedirectionUrlValid(string $url)
{
// No http or https
if (stripos(trim($url), "http")===0){
return false;
}
// In fact no scheme:// at all thanks.
if (stripos($url, "://")!==false){
return false;
}
return true;
... | php | {
"resource": ""
} |
q29684 | Arrays.stripslashes | train | public static function stripslashes(array $input): array
{
$result = [];
foreach ($input as $k => $v) {
$result[$k] = \is_array($v) ? self::stripslashes($v) : \stripslashes($v);
}
return $result;
} | php | {
"resource": ""
} |
q29685 | Arrays.mergeDeep | train | public static function mergeDeep(array $a, array $b): array
{
$result = $a;
foreach ($b as $k => $v) {
if (\is_int($k)) {
$result[] = $v;
continue;
}
if (!\array_key_exists($k, $result)) {
... | php | {
"resource": ""
} |
q29686 | Dumper.dump | train | public function dump($value, int $output = self::OUTPUT_ECHO): string
{
switch ($output) {
case self::OUTPUT_ECHO:
echo $this->style->wrapContainer($this->dumpValue($value, '', 0));
break;
case self::OUTPUT_LOG:
if (!empty($this->logge... | php | {
"resource": ""
} |
q29687 | Chronicle.record | train | public function record(Model $model = null, $name, $user = null)
{
if ( ! $this->isEnabled())
{
return false;
}
$activity = $this->initActivity();
// Auto determine user if none is supplied
$user = $this->getUserId($user);
$data = [
... | php | {
"resource": ""
} |
q29688 | Chronicle.delete | train | public function delete(Model $model, $user = null)
{
if (! $this->isEnabled()) {
return false;
}
$activity = $this->initActivity();
// Auto determine user if none is supplied
$user = $this->getUserId($user);
$data = [
'user_id' => $user... | php | {
"resource": ""
} |
q29689 | Chronicle.getUserId | train | protected function getUserId($user)
{
if (is_null($user))
{
$user = auth()->user();
}
if ($user instanceof Model)
{
$user = $user->getKey();
}
return $user;
} | php | {
"resource": ""
} |
q29690 | Chronicle.getRecords | train | public function getRecords($limit = null, $name = null)
{
$modelName = $this->getModelName();
$activity = $modelName::with('subject');
if ( ! is_null($limit))
{
$activity->limit($limit);
}
if ($name)
{
if ( ! is_array($name))
... | php | {
"resource": ""
} |
q29691 | Chronicle.getUserActivity | train | public function getUserActivity($user, $limit = null, $name = null)
{
$user = $this->getUserId($user);
$modelName = $this->getModelName();
$activity = $modelName::belongsToUser($user);
if ( ! is_null($limit))
{
$activity->limit($limit);
}
if ($... | php | {
"resource": ""
} |
q29692 | ProductLinkObserver.prepareArtefacts | train | protected function prepareArtefacts($linkTypeCode, array $columns)
{
// initialize the array for the product media
$artefacts = array();
// load the parent SKU from the row
$parentSku = $this->getValue(ColumnKeys::SKU);
// shift the column with the header information from ... | php | {
"resource": ""
} |
q29693 | CmsBootstrapListener.onKernelRequest | train | public function onKernelRequest(GetResponseEvent $event)
{
$this->setUpRequiredFolders();
$this->setUpPageTree();
$this->checkTemplatesSlots();
$this->setupBootstrapVersion();
$this->setupConfiguration();
} | php | {
"resource": ""
} |
q29694 | CmsBootstrapListener.normalizeCmsRequestAttributes | train | private function normalizeCmsRequestAttributes(Request $request, DataManager $dataManager)
{
if ($request->getMethod() == 'POST') {
return;
}
$page = $dataManager->getPage();
if (null !== $page) {
$request->attributes->set('page', $page->getPageName());
... | php | {
"resource": ""
} |
q29695 | FormTypeNodeIdExtension.finishView | train | public function finishView(FormView $view, FormInterface $form, array $options)
{
$data = $this->context->getCurrentNodeId();
if (!$view->parent && $options['compound'] and !empty($data)) {
$factory = $form->getConfig()->getFormFactory();
$form = $factory->createNamed($opti... | php | {
"resource": ""
} |
q29696 | CmsController.dispatchCurrentPageEvent | train | protected function dispatchCurrentPageEvent(Request $request)
{
$pageName = $request->get('page');
$seo = $this->seoRepository->fromPermalink($pageName);
if (null !== $seo) {
$page = $this->pageRepository->fromPk($seo->getPageId());
$pageName = $page->getPageName();
... | php | {
"resource": ""
} |
q29697 | Blacklist.add | train | public function add($name, $sid = NULL) {
$user = new User;
if (!$user->isAdmin($sid)) throw new \JohnVanOrange\Core\Exception\NotAllowed('Must be an admin to access method', 401);
if (strlen($name) < 1 OR $name == NULL) throw new \Exception('Tag name cannot be empty');
$tag = htmlspecialchars(trim(stripslashes... | php | {
"resource": ""
} |
q29698 | Logger.getErrorPage | train | private function getErrorPage(ErrorBag $errorBag)
{
$code = $errorBag->getCode();
$data = ['bag' => $errorBag, 'errorBag' => $errorBag];
//Fetch user error page for the error code
try {
return View::fetch("errors/$code", $data);
} catch (Exception $e) {
... | php | {
"resource": ""
} |
q29699 | eZFlowPool.insertItems | train | static function insertItems( array $items )
{
// Checking the validity of items.
foreach ( $items as $item )
{
if ( !isset( $item['blockID'], $item['objectID'], $item['nodeID'], $item['priority'], $item['timestamp'] ) )
{
eZDebug::writeError( "Pool ite... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.