_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q28300 | Entity.getValidator | train | public function getValidator(array $locales=[]) {
$validator = $this->getDefinition()->getEntityManager()->createValidator();
return $this->prepareValidator($validator, $locales);
} | php | {
"resource": ""
} |
q28301 | Entity.errors | train | public function errors($groups=[]) {
$data = $this->toArrayRaw();
$validator = $this->getValidator();
$report = $this->getDefinition()->trigger('validation', [$this, $validator, $groups, &$data], function($chain, $entity, $validator, $groups, &$data) {
$report = $validator->errors($data, $groups);
$report->... | php | {
"resource": ""
} |
q28302 | Entity._get | train | public function _get($name, $locale=null) {
$name = strtolower($name);
if(!$locale)
$locale = $this->getLocale();
if($this->getDefinition()->hasProperty($name)) {
if($this->getDefinition()->property($name)->get('i18n') && $locale !== $this->getLocale()) {
#multiple locales at once
if(is_array($l... | php | {
"resource": ""
} |
q28303 | Entity.get | train | public function get($name, $locale=null, $hook=true) {
if(!$locale)
$locale = $this->getLocale();
if($hook && ($res = $this->getDefinition()->trigger('get', [$this, $name, $locale])) !== null)
return $res;
return $this->_get($name, $locale);
} | php | {
"resource": ""
} |
q28304 | Entity.translate | train | public function translate($locale) {
$localeEntity = clone $this;
$localeEntity->setLocale($locale);
if(isset($this->data['translations'][$locale]))
$localeEntity->_set($this->data['translations'][$locale]);
unset($localeEntity->data['translations'][$locale]);
$localeEntity->data['translations'][$this->get... | php | {
"resource": ""
} |
q28305 | Entity.validI18N | train | public function validI18N(array $locales=[], $groups=[]) {
if(!$locales)
$locales = $this->getLocales();
$data = $this->toArrayRawI18N($locales);
$validator = $this->getValidator($locales);
return $validator->valid($data, $groups);
} | php | {
"resource": ""
} |
q28306 | Entity.errorsI18N | train | public function errorsI18N(array $locales=[], $groups=[]) {
if(!$locales)
$locales = $this->getLocales();
$data = $this->toArrayRawI18N($locales);
$validator = $this->getValidator($locales);
return $validator->errors($data, $groups);
} | php | {
"resource": ""
} |
q28307 | Entity.getchangedI18N | train | public function getchangedI18N($locale=null) {
if(!$locale)
return array_keys($this->translationschanged);
elseif(isset($this->translationschanged[$locale]))
return array_keys($this->translationschanged[$locale]);
else
return [];
} | php | {
"resource": ""
} |
q28308 | QuotedPrintableStream.write | train | public function write($string)
{
$encodedLine = quoted_printable_encode($this->lastLine);
$lineAndString = rtrim(quoted_printable_encode($this->lastLine . $string), "\r\n");
$write = substr($lineAndString, strlen($encodedLine));
$this->stream->write($write);
$written = strlen... | php | {
"resource": ""
} |
q28309 | QuotedPrintableStream.beforeClose | train | private function beforeClose()
{
if ($this->isWritable() && $this->lastLine !== '') {
$this->stream->write("\r\n");
$this->lastLine = '';
}
} | php | {
"resource": ""
} |
q28310 | Script.render | train | protected function render ()
{
$prop = $this->props;
$assets = $this->context->getAssetsService ();
if (exists ($prop->var))
$assets->addInlineScript (sprintf ('var %s=%s;', $prop->var, javascriptLiteral ($prop->export, false)));
elseif (exists ($prop->src))
$assets->addScript ($prop->... | php | {
"resource": ""
} |
q28311 | SocialSubjectEventListener.onResolveSubject | train | public function onResolveSubject(SubjectEvent $event)
{
$params = $event->getParameters();
if (array_key_exists('type', $params)) {
if ($params['type'] == 'page') {
$event->setSubject($this->createPageSubject());
$event->stopPropagation();
} e... | php | {
"resource": ""
} |
q28312 | SocialSubjectEventListener.createPageSubject | train | private function createPageSubject()
{
if (null !== $page = $this->pageHelper->getCurrent()) {
return $this->createSubjectFromPage($page);
}
return null;
} | php | {
"resource": ""
} |
q28313 | SocialSubjectEventListener.createGlobalSubject | train | private function createGlobalSubject()
{
if (null !== $home = $this->pageHelper->getHomePage()) {
return $this->createSubjectFromPage($home);
}
return null;
} | php | {
"resource": ""
} |
q28314 | SocialSubjectEventListener.createSubjectFromPage | train | private function createSubjectFromPage(PageInterface $page)
{
try {
$url = $this->urlGenerator->generate($page->getRoute(), [], UrlGeneratorInterface::ABSOLUTE_URL);
$subject = new Subject();
$subject->title = $page->getSeo()->getTitle();
$subject->url = $u... | php | {
"resource": ""
} |
q28315 | ContactController.sendAction | train | public function sendAction()
{
$contactForm = $this->createForm(FrontForm::CONTACT);
try {
$form = $this->validateForm($contactForm);
$event = new ContactEvent($form);
$this->dispatch(TheliaEvents::CONTACT_SUBMIT, $event);
$this->getMailer(... | php | {
"resource": ""
} |
q28316 | MustacheEngine.setHelpers | train | public function setHelpers($helpers)
{
if ($helpers instanceof HelpersInterface) {
$helpers = $helpers->toArray();
}
if (!is_array($helpers) && !$helpers instanceof Traversable) {
throw new InvalidArgumentException(sprintf(
'setHelpers expects an arra... | php | {
"resource": ""
} |
q28317 | MustacheEngine.addHelper | train | public function addHelper($name, $helper)
{
if ($this->mustache !== null) {
throw new RuntimeException(
'Can not add helper to Mustache engine: the engine has already been initialized.'
);
}
$this->helpers[$name] = $helper;
return $this;
... | php | {
"resource": ""
} |
q28318 | String.altrim | train | public static function altrim($str, $arr)
{
try {
foreach ($arr as &$item) {
if (is_string($item)) {
$str= preg_replace("/^{$item}/", '', $str);
}
}
return $str;
} catch (\Exception $e) {}
} | php | {
"resource": ""
} |
q28319 | BlockRepository.findByTimetableAndDomId | train | public function findByTimetableAndDomId($timetableId, $domId)
{
$block = $this->findOneBy(
array(
'timetable' => $timetableId,
'domId' => $domId,
)
);
// no block found so create first a non persistent block
if (empty($block)) {... | php | {
"resource": ""
} |
q28320 | BlockRepository.findByTimetableAndStopPointAndDomId | train | public function findByTimetableAndStopPointAndDomId($timetableId, $externalStopPointId, $domId)
{
$query = $this->getEntityManager()
->createQuery(
'SELECT block FROM CanalTPMttBundle:Block block
INNER JOIN block.stopPoint stop_point
WHERE stop_poi... | php | {
"resource": ""
} |
q28321 | PageController.execute | train | public function execute(PageRequest $pageRequest)
{
$this->pageRequest = $pageRequest;
$this->pageResponse = $this->createPageResponse();
$localization = $pageRequest->getLocalization();
if (! $localization instanceof Localization) {
throw new \UnexpectedValueException(sprintf(
'Expecting Localizatio... | php | {
"resource": ""
} |
q28322 | PageController.findBlockCache | train | protected function findBlockCache()
{
// Don't search for cache in CMS
if (! $this->pageRequest instanceof PageRequestView) {
return;
}
$localization = $this->pageRequest->getLocalization();
$blockCacheRequests = &$this->blockCacheRequests;
$self = $this;
$this->iterateBlocks(function(Block $block) ... | php | {
"resource": ""
} |
q28323 | PageController.findBlockControllers | train | protected function findBlockControllers()
{
$blockContentCache = &$this->blockContentCache;
$blockCollection = $this->getBlockCollection();
// Iterates through all blocks and calls the function passed
$this->iterateBlocks(function(Block $block, &$blockController) use ($blockCollection, &$blockContentCache) {... | php | {
"resource": ""
} |
q28324 | PageController.prepareBlockControllers | train | protected function prepareBlockControllers()
{
$pageRequest = $this->pageRequest;
$this->iterateBlocks(function(Block $block, BlockController $blockController) use ($pageRequest) {
$blockController->prepare($pageRequest);
});
} | php | {
"resource": ""
} |
q28325 | PageController.findContextDependentBlockCache | train | protected function findContextDependentBlockCache()
{
// Don't search for cache in CMS
if (! $this->pageRequest instanceof PageRequestView) {
return;
}
$localization = $this->pageRequest->getLocalization();
$context = $this->pageResponse->getContext();
$self = $this;
// Iterates through all blocks... | php | {
"resource": ""
} |
q28326 | PageController.executeBlockControllers | train | protected function executeBlockControllers()
{
$blockContentCache = $this->blockContentCache;
$this->iterateBlocks(function(Block $block, BlockController $controller) use (&$blockContentCache) {
// skip cached
if (! array_key_exists($block->getId(), $blockContentCache)) {
$controller->execute();
}
... | php | {
"resource": ""
} |
q28327 | PageController.cacheBlockResponses | train | protected function cacheBlockResponses()
{
$cacheRequests = $this->blockCacheRequests;
$localization = $this->pageRequest->getLocalization();
$logger = $this->container->getLogger();
$cache = $this->container->getCache();
$this->iterateBlocks(function(Block $block, BlockController $controller)
use (&$c... | php | {
"resource": ""
} |
q28328 | PageController.iterateBlocks | train | private function iterateBlocks(\Closure $function)
{
$return = array();
foreach ($this->pageRequest->getBlockSet() as $index => $block) {
/* @var $block Block */
$blockId = $block->getId();
/* @var $blockController BlockController */
if ( ! isset($this->blockControllers[$blockId])) {
$this->bloc... | php | {
"resource": ""
} |
q28329 | PageController.createPlaceResponse | train | protected function createPlaceResponse(PlaceHolder $placeHolder)
{
return $this->pageRequest instanceof PageRequestEdit
? new PlaceHolderResponseEdit($placeHolder)
: new PlaceHolderResponseView($placeHolder);
} | php | {
"resource": ""
} |
q28330 | Xss.decodeEntity | train | protected static function decodeEntity($match)
{
// Protect GET variables in URLs
// 901119URL5918AMP18930PROTECT8198
$match = preg_replace('|\&([a-z\_0-9\-]+)\=([a-z\_0-9\-/]+)|i', self::token . '\\1=\\2', $match[ 0 ]);
$charset = 'UTF-8';
if (function_exists('config... | php | {
"resource": ""
} |
q28331 | MySQL.import | train | public function import($src) {
if(!file_exists(realpath($src)))
throw new \Exception('File '.$src.' does not exist.');
$host = $this->config['host'];
$user = $this->config['user'];
$pwd = $this->config['password'];
$db = $this->config['database'];
$cmd = 'mysql -h '.$host.' -u '.$user.($pwd ? ' -p'.$pwd:... | php | {
"resource": ""
} |
q28332 | MySQL.dump | train | public function dump($dst) {
$host = $this->config['host'];
$user = $this->config['user'];
$pwd = $this->config['password'];
$db = $this->config['database'];
\Asgard\File\FileSystem::mkdir(dirname($dst));
$cmd = 'mysqldump --user='.$user.' --password='.$pwd.' --host='.$host.' '.$db.' > '.$dst;
$process =... | php | {
"resource": ""
} |
q28333 | EventManager._callListenersWithCallback | train | protected function _callListenersWithCallback($listeners, array $arguments, $continueCallback)
{
$counter = count($listeners);
$execCount = 0;
foreach ($listeners as $listener) {
$counter--;
if ($result = $this->_callListener($listener, $arguments)) {
... | php | {
"resource": ""
} |
q28334 | EventManager._isContainPart | train | protected function _isContainPart($eNameParts, $ePaths)
{
// Length of parts is equels
if (count($eNameParts) !== count($ePaths)) {
return false;
}
$isFound = true;
foreach ($eNameParts as $pos => $eNamePart) {
if ('*' !== $eNamePart && array_key_exi... | php | {
"resource": ""
} |
q28335 | EventManager.cleanEventName | train | public function cleanEventName($eventName)
{
$eventName = strtolower($eventName);
$eventName = str_replace('..', '.', $eventName);
$eventName = trim($eventName, '.');
$eventName = trim($eventName);
if (!$eventName) {
throw new Exception('Event name is empty!');
... | php | {
"resource": ""
} |
q28336 | Cache.fetch | train | public function fetch($id, $default=false) {
$res = $this->driver->fetch($id);
if($res === false) {
if($default === false)
return false;
if(is_callable($default))
$res = $default();
else
$res = $default;
$this->save($id, $res);
}
return $res;
} | php | {
"resource": ""
} |
q28337 | Cache.save | train | public function save($id, $data, $lifeTime=0) {
return $this->driver->save($id, $data, $lifeTime);
} | php | {
"resource": ""
} |
q28338 | Cache.offsetSet | train | public function offsetSet($offset, $value) {
if(is_null($offset))
throw new \LogicException('Offset cannot be empty.');
else
$this->save($offset, $value);
} | php | {
"resource": ""
} |
q28339 | Image.findImageSize | train | public function findImageSize($sizeName)
{
if ($this->imageSizes->containsKey($sizeName)) {
return $this->imageSizes->get($sizeName);
} else {
return null;
}
} | php | {
"resource": ""
} |
q28340 | Image.getImageSize | train | public function getImageSize($sizeName)
{
$size = $this->findImageSize($sizeName);
if ( ! $size instanceof ImageSize) {
$size = new ImageSize($sizeName);
$size->setMaster($this);
}
return $size;
} | php | {
"resource": ""
} |
q28341 | Endpoint.register_rewrite_rules | train | protected function register_rewrite_rules() {
if ( ! empty( $this->rewrite_rule ) ) {
foreach ( $this->rewrite_rule as $value ) {
\add_rewrite_rule( $value['regex'], $value['replace'], $value['type'] );
}
}
} | php | {
"resource": ""
} |
q28342 | Endpoint.register_rewrite_tags | train | protected function register_rewrite_tags() {
if ( ! empty( $this->rewrite_tag ) ) {
foreach ( $this->rewrite_tag as $param => $value ) {
\add_rewrite_tag( $param, $value );
}
}
} | php | {
"resource": ""
} |
q28343 | Endpoint.register_rewrite_endpoints | train | protected function register_rewrite_endpoints() {
if ( ! empty( $this->rewrite_endpoint ) ) {
foreach ( $this->rewrite_endpoint as $slug => $arr ) {
\add_rewrite_endpoint( $slug, $arr['type'] );
}
}
} | php | {
"resource": ""
} |
q28344 | Endpoint.add_endpoint | train | public function add_endpoint( $endpoint = '', $endpoint_type = \EP_ROOT, $callback = array() ) {
if ( ! isset( $this->rewrite_endpoint[ $endpoint ] ) ) {
$this->rewrite_endpoint[ $endpoint ] = array(
'type' => $endpoint_type,
'callback' => $callback,
);
}
return $this;
} | php | {
"resource": ""
} |
q28345 | Endpoint.add_rewrite_rule | train | public function add_rewrite_rule( $path = '', $after = 'top' ) {
$uri = '^' . preg_replace( $this->parameter_pattern, $this->value_pattern_replace, $path );
$url = 'index.php?';
$_url = array();
$matches = [];
if ( preg_match_all( $this->parameter_pattern, $path, $matches ) ) {
foreach ( $match... | php | {
"resource": ""
} |
q28346 | Endpoint.add_tag | train | public function add_tag( $tag = '', $regex = '', $force = false ) {
if ( ! isset( $this->rewrite_tag[ $tag ] ) || isset( $this->rewrite_tag[ $tag ] ) && true === $force ) {
$this->rewrite_tag[ $tag ] = $regex;
}
return $this;
} | php | {
"resource": ""
} |
q28347 | Endpoint.add_query_vars | train | public function add_query_vars( $vars = array() ) {
if ( ! empty( $this->rewrite_endpoint ) ) {
$keys = array_keys( $this->rewrite_endpoint );
return array_merge( $vars, $keys );
}
return $vars;
} | php | {
"resource": ""
} |
q28348 | Column.getStorageColumns | train | public function getStorageColumns()
{
$columns = $this->createStorageColumns();
$namedColumns = [];
foreach ($columns as $column) {
$namedColumns[$column->columnName] = $column;
}
return $namedColumns;
} | php | {
"resource": ""
} |
q28349 | Column.getRepositorySpecificColumn | train | final public function getRepositorySpecificColumn($repositoryClassName)
{
$reposName = basename(str_replace("\\", "/", $repositoryClassName));
// Get the provider specific implementation of the column.
$className = '\Rhubarb\Stem\Repositories\\' . $reposName . '\Schema\Columns\\' . $reposNa... | php | {
"resource": ""
} |
q28350 | Psr7MiddlewareAction.execute | train | public function execute(TransactionData $transactionData, $argument = null)
{
if ($argument instanceof ClassArgumentObject) {
$middleware = $argument->getInstance();
$transactionData->setResponse(
$middleware(
$transactionData->getRequest(),
... | php | {
"resource": ""
} |
q28351 | AssetsAdapter.readFile | train | private function readFile()
{
$content = @file_get_contents($this->filename);
if (false === $content) {
throw new InvalidArgumentException(sprintf('Cannot access "%s" to read the JSON file', $this->filename));
}
$content = json_decode($content, true);
if (JSON_... | php | {
"resource": ""
} |
q28352 | AssetsAdapter.getCachedContent | train | private function getCachedContent()
{
$item = null;
if (null !== $this->cache) {
$item = $this->cache->getItem($this->cacheKey);
$cacheContent = $item->get();
if ($item->isHit() && null !== $cacheContent) {
$this->contentCache = $cacheContent;
... | php | {
"resource": ""
} |
q28353 | AssetsAdapter.saveContentInCache | train | private function saveContentInCache($item, array $content)
{
if (null !== $this->cache && null !== $item) {
$item->set($this->contentCache);
$this->cache->save($item);
}
return $content;
} | php | {
"resource": ""
} |
q28354 | ProfilerController.logboardAction | train | public function logboardAction($token, Request $request)
{
$this->loadServices($token, $request);
if ($this->queryManager->isPreview())
return new Response($this->twig->render("LogboardBundle:Collector:viewer.html.twig", array('logs_stack' => $this->profilerManager->getPreviewData(), 'pr... | php | {
"resource": ""
} |
q28355 | ProfilerController.loadServices | train | protected function loadServices($token, Request $request)
{
$this->templates = $this->container->getParameter('data_collector.templates');
$this->twig = $this->container->get("twig");
$this->accessor = PropertyAccess::createPropertyAccessor();
$this->profilerManager = $this->containe... | php | {
"resource": ""
} |
q28356 | ProfilerController.setEngine | train | protected function setEngine()
{
if (null !== $this->engine) {
$service = sprintf('logboard.%s', $this->engine);
if ($this->container->has($service)) {
$this->queryManager->setEngine($this->container->get($service));
} else {
throw new BadQ... | php | {
"resource": ""
} |
q28357 | BlockSet.removeInvalidBlock | train | public function removeInvalidBlock(Block $block, $reason = 'unknown')
{
/* @var $testBlock Entity\Abstraction\Block */
foreach ($this as $index => $testBlock) {
if ($testBlock->equals($block)) {
\Log::warn("Block {$block} removed as invalid with reason: {$reason}");
$this->offsetUnset($index);
}... | php | {
"resource": ""
} |
q28358 | BlockSet.orderByPlaceHolderNameArray | train | public function orderByPlaceHolderNameArray(array $placeHolderNames = null)
{
if (is_null($placeHolderNames)) {
return;
}
$blockArray = iterator_to_array($this);
$sortFunction = function(Block $block1, Block $block2) use ($placeHolderNames, $blockArray) {
$name1 = $block1->getPlaceHolder()->getName... | php | {
"resource": ""
} |
q28359 | TranslatedAliasOptionsListener.isEventForMe | train | private function isEventForMe(GetOptionsEvent $event)
{
$input = $event->getEnvironment()->getInputProvider();
if ($input->hasValue('type')) {
$type = $input->getValue('type');
}
if (empty($type)) {
$type = $event->getModel()->getProperty('type');
}
... | php | {
"resource": ""
} |
q28360 | Tools.truncateHTML | train | public static function truncateHTML($html, $maxLength, $trailing='...') {
$html = trim($html);
$printedLength = 0;
$position = 0;
$tags = [];
$res = '';
while ($printedLength < $maxLength && preg_match('{</?([a-z]+)[^>]*>|&#?[a-zA-Z0-9]+;}', $html, $match, PREG_OFFSET_CAPTURE, $position)) {
li... | php | {
"resource": ""
} |
q28361 | Tools.truncate | train | public static function truncate($str, $length, $trailing='...') {
$length -= mb_strlen($trailing);
if (mb_strlen($str) > $length)
return mb_substr($str,0,$length).$trailing;
return $str;
} | php | {
"resource": ""
} |
q28362 | Tools.truncateWords | train | public static function truncateWords($str, $length, $trailing='...') {
$words = explode(' ', $str);
$cutwords = array_slice($words, 0, $length);
return implode(' ', $cutwords).(count($words) > count($cutwords) ? $trailing:'');
} | php | {
"resource": ""
} |
q28363 | Tools.loadClassFile | train | public static function loadClassFile($file) {
$before = array_merge(get_declared_classes(), get_declared_interfaces());
require_once $file;
$after = array_merge(get_declared_classes(), get_declared_interfaces());
$diff = array_diff($after, $before);
#class was maybe already loaded
if(!$diff) {
... | php | {
"resource": ""
} |
q28364 | LayoutModelManager.save | train | public function save(Layout $layout)
{
$archiveDir = $this->getUploadDir().'/archives';
$templateDir = $this->getUploadDir().'/templates';
$tmpDir = $this->getUploadDir().'/tmp/'.time();
// Copy the archive to the archive directory
$file = $layout->getFile()->move(
... | php | {
"resource": ""
} |
q28365 | LayoutModelManager.moveFiles | train | protected function moveFiles($extension, $actualDir, $targetDir, $throwExceptionIfNotFound = true)
{
if (!is_array($extension)) {
$extension = (array) $extension;
}
$finder = new Finder();
$finder->files()->in($actualDir);
foreach ($extension as $ext) {
... | php | {
"resource": ""
} |
q28366 | LayoutModelManager.readConfiguration | train | protected function readConfiguration($actualDir)
{
$finder = new Finder();
$finder->files()->in($actualDir)->name('*.yml');
if (iterator_count($finder) < 1) {
throw new \Exception('The configuration (.yml) file is missing.');
}
$files = iterator_to_array($finder... | php | {
"resource": ""
} |
q28367 | LayoutModelManager.getDirectories | train | private function getDirectories($dir, $directoryName = null)
{
$finder = new Finder();
$finder->directories()->in($dir);
if (null !== $directoryName) {
$finder->name($directoryName);
}
if (iterator_count($finder) > 0) {
return iterator_to_array($find... | php | {
"resource": ""
} |
q28368 | UserGroupModel.createAdminRole | train | public static function createAdminRole($force = false)
{
if(!$force) {
if(Permission::exists('global', 'admin')) {
return false;
}
}
return self::createRole(
'Admin', true, [[
'app' => 'global',
'key' => 'admin'
... | php | {
"resource": ""
} |
q28369 | UserGroupModel.createEditorRole | train | public static function createEditorRole($force = false)
{
if(!$force) {
if(Permission::exists('global', 'editor')) {
return false;
}
}
return self::createRole(
'Editor', true, [[
'app' => 'global',
'key' => 'editor'... | php | {
"resource": ""
} |
q28370 | UserGroupModel.createAuthorRole | train | public static function createAuthorRole($force = false)
{
if(!$force) {
if(Permission::exists('global', 'author')) {
return false;
}
}
return self::createRole(
'Author', true, [[
'app' => 'global',
'key' => 'author'... | php | {
"resource": ""
} |
q28371 | UserGroupModel.createRole | train | public static function createRole($name, $isDefault, $permissions = [])
{
// Create admin role
$role = (new static());
$role->name = $name;
$role->isDefault = $isDefault;
$role->slug = str_slug($name);
if($createdRole = $role->save()) {
// Assert Permiss... | php | {
"resource": ""
} |
q28372 | BasicLexer.setNewlineTokenName | train | public function setNewlineTokenName(string $name) : BasicLexer
{
if (strlen($name) == 0) {
throw new \InvalidArgumentException('The name of the newline token must be not empty.');
}
$this->newlineTokenName = $name;
return $this;
} | php | {
"resource": ""
} |
q28373 | BasicLexer.setEosTokenName | train | public function setEosTokenName(string $name) : BasicLexer
{
if (strlen($name) == 0) {
throw new \InvalidArgumentException('The name of the EOS token must be not empty.');
}
$this->eosTokenName = $name;
return $this;
} | php | {
"resource": ""
} |
q28374 | BasicLexer.match | train | protected function match(string $line, int $lineNumber, int $offset) : array
{
$restLine = substr($line, $offset);
foreach ($this->terminals as $pattern => $name) {
if (preg_match($pattern, $restLine, $matches)) {
return [
$name,
$... | php | {
"resource": ""
} |
q28375 | ORMMigrations.autoMigrate | train | public function autoMigrate($definitions) {
if(!is_array($definitions))
$definitions = [$definitions];
$entitiesSchema = $this->getEntitiesSchemas($definitions);
$sqlSchema = $this->getSQLSchemas();
$this->processSchemas($entitiesSchema, $sqlSchema);
} | php | {
"resource": ""
} |
q28376 | ORMMigrations.generateMigration | train | public function generateMigration($definitions, $migrationName) {
if(!is_array($definitions))
$definitions = [$definitions];
$entitiesSchema = $this->getEntitiesSchemas($definitions);
$sqlSchema = $this->getSQLSchemas();
$up = $this->buildMigration($entitiesSchema, $sqlSchema, false);
$down = $this->buildM... | php | {
"resource": ""
} |
q28377 | ORMMigrations.previewMigration | train | public function previewMigration($definitions, $migrationName) {
if(!is_array($definitions))
$definitions = [$definitions];
$entitiesSchema = $this->getEntitiesSchemas($definitions);
$sqlSchema = $this->getSQLSchemas();
$up = $this->buildMigration($entitiesSchema, $sqlSchema, false);
$down = $this->buildMi... | php | {
"resource": ""
} |
q28378 | ORMMigrations.processSchemas | train | protected function processSchemas(\Doctrine\DBAL\Schema\Schema $newSchema, \Doctrine\DBAL\Schema\Schema $oldSchema) {
$comparator = new \Doctrine\DBAL\Schema\Comparator;
$schemaDiff = $comparator->compare($oldSchema, $newSchema);
$platform = $this->dataMapper->getDB()->getConn()->getDatabasePlatform();
$queri... | php | {
"resource": ""
} |
q28379 | ORMMigrations.buildMigration | train | protected function buildMigration(\Doctrine\DBAL\Schema\Schema $newSchema, \Doctrine\DBAL\Schema\Schema $oldSchema, $drop) {
$comparator = new \Doctrine\DBAL\Schema\Comparator;
$schemaDiff = $comparator->compare($oldSchema, $newSchema);
$res = '';
if($drop) {
foreach($schemaDiff->removedTables as $tableNam... | php | {
"resource": ""
} |
q28380 | ORMMigrations.renameColumn | train | protected function renameColumn($name, \Doctrine\DBAL\Schema\Column $col) {
$res = "\n\t\$table->rename('$name', '".$col->getName()."');";
return $res;
} | php | {
"resource": ""
} |
q28381 | ORMMigrations.createTable | train | protected function createTable($tableName, $table) {
$res = "\$this->schema->create('$tableName', function(\$table) {";
foreach($table->getColumns() as $colName=>$col)
$res .= $this->createColumn($colName, $col);
foreach($table->getIndexes() as $index)
$res .= $this->createIndex($index);
foreach($table... | php | {
"resource": ""
} |
q28382 | ORMMigrations.updateColumn | train | protected function updateColumn($name, \Doctrine\DBAL\Schema\ColumnDiff $col) {
$res = "\n\t\$table->changeColumn('$name', [";
$type_changed = in_array('type', $col->changedProperties);
foreach($col->column->toArray() as $propName=>$prop) {
if(($type_changed && $prop && $propName !== 'name') || in_array($prop... | php | {
"resource": ""
} |
q28383 | ORMMigrations.createColumn | train | protected function createColumn($name, \Doctrine\DBAL\Schema\Column $col) {
$type = strtolower($col->getType());
$res = "\n\t\$table->addColumn('$name', '".$type."', [";
if($col->getNotnull())
$res .= "\n 'notnull' => true,";
if($col->getAutoincrement())
$res .= "\n 'autoincrement' => true,";
if($col... | php | {
"resource": ""
} |
q28384 | ORMMigrations.createIndex | train | protected function createIndex($index) {
if($index->isPrimary())
$res = "\n\t\$table->setPrimaryKey(\n\t\t".$this->outputPHP($index->getColumns(), 2).",\n\t\t'".$index->getName()."'\n\t);";
elseif($index->isUnique())
$res = "\n\t\$table->addUniqueIndex(\n\t\t".$this->outputPHP($index->getColumns(), 2).",\n\t\... | php | {
"resource": ""
} |
q28385 | ORMMigrations.createForeignKey | train | protected function createForeignKey($key) {
$res = "\n\t\$table->addForeignKeyConstraint('".$key->getForeignTableName()."', ".$this->outputPHP($key->getLocalColumns(), 2).", ".$this->outputPHP($key->getForeignColumns(), 2).
", ".$this->outputPHP($key->getOptions(), 2).", '".$key->getName()."');";
return $res;
... | php | {
"resource": ""
} |
q28386 | DataAccessFunctions.productDataAccess | train | public function productDataAccess($params, &$smarty)
{
$productId = $this->getRequest()->get('product_id');
if ($productId !== null) {
return $this->dataAccessWithI18n(
"Product",
$params,
ProductQuery::create()->filterByPrimaryKey($produc... | php | {
"resource": ""
} |
q28387 | DataAccessFunctions.categoryDataAccess | train | public function categoryDataAccess($params, &$smarty)
{
$categoryId = $this->getRequest()->get('category_id');
if ($categoryId === null) {
$productId = $this->getRequest()->get('product_id');
if ($productId !== null) {
if (null !== $product = ProductQuery::c... | php | {
"resource": ""
} |
q28388 | DataAccessFunctions.contentDataAccess | train | public function contentDataAccess($params, &$smarty)
{
$contentId = $this->getRequest()->get('content_id');
if ($contentId !== null) {
return $this->dataAccessWithI18n(
"Content",
$params,
ContentQuery::create()->filterByPrimaryKey($conten... | php | {
"resource": ""
} |
q28389 | DataAccessFunctions.folderDataAccess | train | public function folderDataAccess($params, &$smarty)
{
$folderId = $this->getRequest()->get('folder_id');
if ($folderId === null) {
$contentId = $this->getRequest()->get('content_id');
if ($contentId !== null) {
if (null !== $content = ContentQuery::create()-... | php | {
"resource": ""
} |
q28390 | DataAccessFunctions.brandDataAccess | train | public function brandDataAccess($params, &$smarty)
{
$brandId = $this->getRequest()->get('brand_id');
if ($brandId === null) {
$productId = $this->getRequest()->get('product_id');
if ($productId !== null) {
if (null !== $product = ProductQuery::create()->fin... | php | {
"resource": ""
} |
q28391 | DataAccessFunctions.currencyDataAccess | train | public function currencyDataAccess($params, $smarty)
{
$currency = $this->getSession()->getCurrency();
if ($currency) {
return $this->dataAccessWithI18n(
"Currency",
$params,
CurrencyQuery::create()->filterByPrimaryKey($currency->getId()),... | php | {
"resource": ""
} |
q28392 | DataAccessFunctions.countryDataAccess | train | public function countryDataAccess($params, $smarty)
{
switch ($params["ask"]) {
case "default":
return $this->dataAccessWithI18n(
"defaultCountry",
$params,
CountryQuery::create()->filterByByDefault(1)->limit(1)
... | php | {
"resource": ""
} |
q28393 | DataAccessFunctions.cartDataAccess | train | public function cartDataAccess($params, $smarty)
{
/** @var Country $taxCountry */
if (array_key_exists('currentCountry', self::$dataAccessCache)) {
$taxCountry = self::$dataAccessCache['currentCountry'];
} else {
$taxCountry = $this->taxEngine->getDeliveryCountry();
... | php | {
"resource": ""
} |
q28394 | DataAccessFunctions.orderDataAccess | train | public function orderDataAccess($params, &$smarty)
{
/** @var Order $order */
$order = $this->getSession()->getOrder();
$attribute = $this->getNormalizedParam($params, array('attribute', 'attrib', 'attr'));
switch ($attribute) {
case 'untaxed_postage':
ret... | php | {
"resource": ""
} |
q28395 | DataAccessFunctions.moduleConfigDataAccess | train | public function moduleConfigDataAccess($params, $smarty)
{
$key = $this->getParam($params, 'key', false);
$moduleCode = $this->getParam($params, 'module', false);
$locale = $this->getParam($params, 'locale');
if (null === $locale) {
$locale = $this->getSession()->getLang... | php | {
"resource": ""
} |
q28396 | DataAccessFunctions.metaAccess | train | public function metaAccess($params, $smarty)
{
$meta = $this->getParam($params, 'meta', null);
$key = $this->getParam($params, 'key', null);
$id = $this->getParam($params, 'id', null);
$cacheKey = sprintf('meta_%s_%s_%s', $meta, $key, $id);
$out = null;
if (array_k... | php | {
"resource": ""
} |
q28397 | DataAccessFunctions.underscoreToCamelcase | train | private function underscoreToCamelcase($str)
{
// Split string in words.
$words = explode('_', strtolower($str));
$return = '';
foreach ($words as $word) {
$return .= ucfirst(trim($word));
}
return $return;
} | php | {
"resource": ""
} |
q28398 | TRedirectHelpers.redirectTo | train | public function redirectTo($route = null)
{
if (is_null($route)) {
$url = $this->di->request->getCurrentUrl();
} else {
$url = $this->di->url->create($route);
}
$this->di->response->redirect($url);
} | php | {
"resource": ""
} |
q28399 | Client.verify | train | private function verify(RequestInterface $httpRequest)
{
$extensions = array('crt', 'pem', 'cer', 'der');
$caDir = __DIR__ . '/../CA/';
// Must be https
$url = $httpRequest->getUrl();
if (substr($url, 0, 5) != 'https') {
$httpRequest->getConfig()->set('verify', f... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.