_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q24800
SecuritySubscriber.setDefaultUser
train
public function setDefaultUser(ConfigureOptionsEvent $event) { $optionsResolver = $event->getOptions(); $optionsResolver->setDefault(static::USER_OPTION, null); if (null === $this->tokenStorage) { return; } $token = $this->tokenStorage->getToken(); if ...
php
{ "resource": "" }
q24801
PhoneType.addPhone
train
public function addPhone(\Sulu\Bundle\ContactBundle\Entity\Phone $phones) { $this->phones[] = $phones; return $this; }
php
{ "resource": "" }
q24802
PhoneType.removePhone
train
public function removePhone(\Sulu\Bundle\ContactBundle\Entity\Phone $phones) { $this->phones->removeElement($phones); }
php
{ "resource": "" }
q24803
WebspaceCollection.getPortal
train
public function getPortal($key) { return array_key_exists($key, $this->portals) ? $this->portals[$key] : null; }
php
{ "resource": "" }
q24804
WebspaceCollection.getPortalInformations
train
public function getPortalInformations($environment, $types = null) { if (!isset($this->portalInformations[$environment])) { throw new \InvalidArgumentException(sprintf( 'Unknown portal environment "%s"', $environment )); } if (null === $types) { ...
php
{ "resource": "" }
q24805
WebspaceCollection.getWebspace
train
public function getWebspace($key) { return array_key_exists($key, $this->webspaces) ? $this->webspaces[$key] : null; }
php
{ "resource": "" }
q24806
WebspaceCollection.toArray
train
public function toArray() { $collection = []; $webspaces = []; foreach ($this->webspaces as $webspace) { $webspaces[] = $webspace->toArray(); } $portalInformations = []; foreach ($this->portalInformations as $environment => $environmentPortalInformations...
php
{ "resource": "" }
q24807
AbstractListBuilder.retrieveIndexOfFieldDescriptor
train
protected function retrieveIndexOfFieldDescriptor( FieldDescriptorInterface $fieldDescriptor, array $fieldDescriptors ) { foreach ($fieldDescriptors as $index => $other) { if ($fieldDescriptor->compare($other)) { return $index; } } ret...
php
{ "resource": "" }
q24808
TagsSubscriber.addTags
train
public function addTags(): void { $tags = $this->getTags(); $currentStructureUuid = $this->getCurrentStructureUuid(); if ($currentStructureUuid && !in_array($currentStructureUuid, $tags)) { $tags[] = $currentStructureUuid; } if (count($tags) <= 0) { r...
php
{ "resource": "" }
q24809
TagsSubscriber.getTags
train
private function getTags(): array { $tags = []; foreach ($this->referenceStorePool->getStores() as $alias => $referenceStore) { $tags = array_merge($tags, $this->getTagsFromStore($alias, $referenceStore)); } return $tags; }
php
{ "resource": "" }
q24810
TagsSubscriber.getTagsFromStore
train
private function getTagsFromStore($alias, ReferenceStoreInterface $referenceStore): array { $tags = []; foreach ($referenceStore->getAll() as $reference) { $tag = $reference; if (!Uuid::isValid($reference)) { $tag = $alias . '-' . $reference; } ...
php
{ "resource": "" }
q24811
TagsSubscriber.getCurrentStructureUuid
train
private function getCurrentStructureUuid(): ?string { $request = $this->requestStack->getCurrentRequest(); if (!$request) { return null; } $structure = $request->get('structure'); if (!$structure || !$structure instanceof StructureInterface) { return ...
php
{ "resource": "" }
q24812
CustomUrlManager.findRoute
train
protected function findRoute($uuid) { $document = $this->documentManager->find($uuid); if (!$document instanceof RouteDocument) { return; } return $document; }
php
{ "resource": "" }
q24813
CustomUrlManager.bind
train
private function bind(CustomUrlDocument $document, $data) { $document->setTitle($data['title']); unset($data['title']); $metadata = $this->metadataFactory->getMetadataForAlias('custom_url'); $accessor = PropertyAccess::createPropertyAccessor(); foreach ($metadata->getField...
php
{ "resource": "" }
q24814
SuluNodeHelper.getLanguagesForNode
train
public function getLanguagesForNode(NodeInterface $node) { $languages = []; foreach ($node->getProperties() as $property) { /* @var PropertyInterface $property */ preg_match('/^' . $this->languageNamespace . ':([a-zA-Z_]*?)-changer/', $property->getName(), $matches); ...
php
{ "resource": "" }
q24815
SuluNodeHelper.getStructureTypeForNode
train
public function getStructureTypeForNode(NodeInterface $node) { $mixinTypes = $node->getPropertyValueWithDefault('jcr:mixinTypes', []); if (in_array('sulu:' . Structure::TYPE_PAGE, $mixinTypes)) { return Structure::TYPE_PAGE; } if (in_array('sulu:' . Structure::TYPE_SNIP...
php
{ "resource": "" }
q24816
SuluNodeHelper.getBaseSnippetPath
train
public function getBaseSnippetPath($type = null) { $path = '/' . $this->getPath('base') . '/' . $this->getPath('snippet'); if ($type) { $path .= '/' . $type; } return $path; }
php
{ "resource": "" }
q24817
SuluNodeHelper.getBaseSnippetUuid
train
public function getBaseSnippetUuid($type = null) { try { return $this->session->getNode($this->getBaseSnippetPath($type))->getIdentifier(); } catch (PathNotFoundException $e) { $snippetStructures = array_map(function(StructureMetadata $structureMetadata) { ret...
php
{ "resource": "" }
q24818
SuluNodeHelper.extractSnippetTypeFromPath
train
public function extractSnippetTypeFromPath($path) { if ('/' !== substr($path, 0, 1)) { throw new \InvalidArgumentException( sprintf( 'Path must be absolute, got "%s"', $path ) ); } $snippetsPath ...
php
{ "resource": "" }
q24819
SuluNodeHelper.getTranslatedProperty
train
public function getTranslatedProperty($property, $locale, $prefix = null) { return new TranslatedProperty($property, $locale, $this->languageNamespace, $prefix); }
php
{ "resource": "" }
q24820
Operator.getValues
train
public function getValues() { $values = $this->entity->getValues(); $result = []; if ($values) { foreach ($values as $value) { $result[] = new OperatorValue($value, $this->locale); } return $result; } return; }
php
{ "resource": "" }
q24821
AppendAnalyticsListener.onResponse
train
public function onResponse(FilterResponseEvent $event) { if ($this->preview || 0 !== strpos($event->getResponse()->headers->get('Content-Type'), 'text/html') || null === $this->requestAnalyzer->getPortalInformation() ) { return; } $portalUrl = $th...
php
{ "resource": "" }
q24822
AppendAnalyticsListener.generateAnalyticsContent
train
protected function generateAnalyticsContent(array $analyticsContent, Analytics $analytics) { foreach (array_keys(self::$positions) as $position) { $template = 'SuluWebsiteBundle:Analytics:' . $analytics->getType() . '/' . $position . '.html.twig'; if (!$this->engine->exists($templat...
php
{ "resource": "" }
q24823
AppendAnalyticsListener.setAnalyticsContent
train
protected function setAnalyticsContent($responseContent, array $analyticsContent) { foreach ($analyticsContent as $id => $content) { if (!$content) { continue; } $responseContent = preg_replace( self::$positions[$id]['regex'], ...
php
{ "resource": "" }
q24824
FilterTranslation.setFilter
train
public function setFilter(\Sulu\Bundle\ResourceBundle\Entity\Filter $filter) { $this->filter = $filter; return $this; }
php
{ "resource": "" }
q24825
LocalStorage.getUniqueFileName
train
private function getUniqueFileName(string $folder, string $fileName, int $counter = 0): string { $newFileName = $fileName; if ($counter > 0) { $fileNameParts = explode('.', $fileName, 2); $newFileName = $fileNameParts[0] . '-' . $counter; if (isset($fileNamePart...
php
{ "resource": "" }
q24826
SnippetController.cgetAction
train
public function cgetAction(Request $request) { $locale = $this->getLocale($request); // if the type parameter is falsy, assign NULL to $type $type = $request->query->get('type', null) ?: null; $idsString = $request->get('ids'); if ($idsString) { $ids = explode(...
php
{ "resource": "" }
q24827
SnippetController.getAction
train
public function getAction(Request $request, $id = null) { $locale = $this->getLocale($request); $snippet = $this->findDocument($id, $locale); $view = View::create($snippet); return $this->viewHandler->handle($view); }
php
{ "resource": "" }
q24828
SnippetController.postAction
train
public function postAction(Request $request) { $document = $this->documentManager->create(Structure::TYPE_SNIPPET); $form = $this->processForm($request, $document); return $this->handleView($form->getData()); }
php
{ "resource": "" }
q24829
SnippetController.putAction
train
public function putAction(Request $request, $id) { $document = $this->findDocument($id, $this->getLocale($request)); $this->requestHashChecker->checkHash($request, $document, $document->getUuid()); if (!$this->checkAreaSnippet($request, $document)) { return new JsonResponse( ...
php
{ "resource": "" }
q24830
SnippetController.deleteAction
train
public function deleteAction(Request $request, $id) { $locale = $this->getLocale($request); $webspaceKey = $request->query->get('webspace', null); $references = $this->snippetRepository->getReferences($id); if (count($references) > 0) { $force = $request->headers->get('...
php
{ "resource": "" }
q24831
SnippetController.postTriggerAction
train
public function postTriggerAction($id, Request $request) { $view = null; $snippet = null; $locale = $this->getLocale($request); $action = $this->getRequestParameter($request, 'action', true); try { switch ($action) { case 'copy-locale': ...
php
{ "resource": "" }
q24832
SnippetController.decorateSnippet
train
private function decorateSnippet(array $snippet, $locale) { return array_merge( $snippet, [ '_links' => [ 'self' => $this->urlGenerator->generate( 'get_snippet', ['id' => $snippet['id'], 'language' =>...
php
{ "resource": "" }
q24833
SnippetController.getReferentialIntegrityResponse
train
private function getReferentialIntegrityResponse($webspace, $references, $id, $locale) { $data = [ 'structures' => [], 'other' => [], 'isDefault' => $this->defaultSnippetManager->isDefault($id), ]; foreach ($references as $reference) { if ($re...
php
{ "resource": "" }
q24834
ContentQueryExecutor.createSql2Query
train
private function createSql2Query($sql2, $limit = null, $offset = null) { $queryManager = $this->sessionManager->getSession()->getWorkspace()->getQueryManager(); $query = $queryManager->createQuery($sql2, 'JCR-SQL2'); if ($limit) { $query->setLimit($limit); } if (...
php
{ "resource": "" }
q24835
CustomUrlSubscriber.handlePersist
train
public function handlePersist(PersistEvent $event) { $document = $event->getDocument(); if (!($document instanceof CustomUrlBehavior)) { return; } $webspaceKey = $this->inspector->getWebspace($document); $domain = $this->generator->generate($document->getBaseDoma...
php
{ "resource": "" }
q24836
CustomUrlSubscriber.createRoute
train
protected function createRoute( $domain, CustomUrlBehavior $document, Localization $locale, $persistedLocale, $routesPath ) { $path = sprintf('%s/%s', $routesPath, $domain); $routeDocument = $this->findOrCreateRoute($path, $persistedLocale, $document, $domain)...
php
{ "resource": "" }
q24837
CustomUrlSubscriber.findOrCreateRoute
train
protected function findOrCreateRoute($path, $locale, CustomUrlBehavior $document, $route) { try { /** @var RouteDocument $routeDocument */ $routeDocument = $this->documentManager->find($path, $locale); } catch (DocumentNotFoundException $ex) { return $this->docume...
php
{ "resource": "" }
q24838
CustomUrlSubscriber.handleRemove
train
public function handleRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!($document instanceof CustomUrlBehavior)) { return; } foreach ($this->inspector->getReferrers($document) as $referrer) { if ($referrer instanceof RouteBehavior) { ...
php
{ "resource": "" }
q24839
DomainRepository.findByUrlAndEnvironment
train
public function findByUrlAndEnvironment($url, $environment) { $queryBuilder = $this->createQueryBuilder('u') ->where('u.url = :url') ->andWhere('u.environment = :environment'); $query = $queryBuilder->getQuery(); $query->setParameter('url', $url); $query->set...
php
{ "resource": "" }
q24840
PortalInformation.getHostLength
train
private function getHostLength() { $hostLength = strpos($this->url, '/'); $hostLength = (false === $hostLength) ? strlen($this->url) : $hostLength; return $hostLength; }
php
{ "resource": "" }
q24841
PasteTransformation.createMask
train
protected function createMask($maskPath, $width, $height) { $mask = $this->imagine->open($maskPath); $mask->resize( new Box( $width ?: 1, $height ?: 1 ) ); return $mask; }
php
{ "resource": "" }
q24842
JsConfigPool.addConfigParams
train
public function addConfigParams(JsConfigInterface $params) { $this->pool = array_merge($this->pool, [$params->getName() => $params->getParameters()]); }
php
{ "resource": "" }
q24843
ListXmlLoader.loadPropertyMetadata
train
private function loadPropertyMetadata(\DOMXPath $xpath, \DOMNode $propertyNode) { $propertyMetadata = null; switch ($propertyNode->nodeName) { case 'concatenation-property': $propertyMetadata = $this->loadConcatenationPropertyMetadata($xpath, $propertyNode); ...
php
{ "resource": "" }
q24844
ListXmlLoader.getFilterTypeParameters
train
protected function getFilterTypeParameters(\DOMXPath $xpath, \DOMNode $propertyNode) { $parameters = []; foreach ($xpath->query('x:filter-type-parameters/x:parameter', $propertyNode) as $parameterNode) { $key = XmlUtil::getValueFromXPath('@key', $xpath, $parameterNode); $para...
php
{ "resource": "" }
q24845
GeolocatorController.queryAction
train
public function queryAction(Request $request) { $geolocatorName = $request->get('providerName'); $query = $request->get('query'); try { $geolocator = $this->geolocatorManager->get($geolocatorName); } catch (GeolocatorNotFoundException $e) { throw new NotFound...
php
{ "resource": "" }
q24846
LinkTag.preload
train
private function preload($attributesByTag, $locale, $published = true) { $hrefsByType = []; foreach ($attributesByTag as $attributes) { $provider = $this->getValue($attributes, 'provider', self::DEFAULT_PROVIDER); if (!array_key_exists($provider, $hrefsByType)) { ...
php
{ "resource": "" }
q24847
LinkTag.getValue
train
private function getValue(array $attributes, $name, $default = null) { if (array_key_exists($name, $attributes) && !empty($attributes[$name])) { return $attributes[$name]; } return $default; }
php
{ "resource": "" }
q24848
ResourceLocatorRepository.getBasePath
train
private function getBasePath($uuid = null, $default = 1) { if (null !== $uuid) { return str_replace('{uuid}', $uuid, $this->apiBasePath[2]); } else { return $this->apiBasePath[$default]; } }
php
{ "resource": "" }
q24849
SnippetContent.getSnippets
train
private function getSnippets(PropertyInterface $property) { /** @var PageBridge $page */ $page = $property->getStructure(); $webspaceKey = $page->getWebspaceKey(); $locale = $page->getLanguageCode(); $shadowLocale = null; if ($page->getIsShadow()) { $shado...
php
{ "resource": "" }
q24850
SnippetContent.getParameterValue
train
private function getParameterValue(array $parameter, $name, $default = null) { if (!array_key_exists($name, $parameter)) { return $default; } return $parameter[$name]->getValue(); }
php
{ "resource": "" }
q24851
Export.getPropertyData
train
protected function getPropertyData(PropertyMetadata $property, $propertyValue) { return $this->createProperty( $property->getName(), $this->exportManager->export($property->getType(), $propertyValue), $this->exportManager->getOptions($property->getType(), $this->format), ...
php
{ "resource": "" }
q24852
Export.getBlockPropertyData
train
protected function getBlockPropertyData(BlockMetadata $property, $propertyValue) { $children = []; $blockDataList = $this->exportManager->export($property->getType(), $propertyValue); foreach ($blockDataList as $blockData) { $blockType = $blockData['type']; $block ...
php
{ "resource": "" }
q24853
Export.getPropertiesContentData
train
protected function getPropertiesContentData($properties, $propertyValues) { $contentData = []; foreach ($properties as $property) { if ($this->exportManager->hasExport($property->getType(), $this->format)) { if (!isset($propertyValues[$property->getName()])) { ...
php
{ "resource": "" }
q24854
Export.getContentData
train
protected function getContentData($document, $locale) { /** @var BasePageDocument $loadedDocument */ $loadedDocument = $this->documentManager->find($document->getUuid(), $locale); /** @var \Sulu\Component\Content\Metadata\StructureMetadata $metaData */ $metaData = $this->documentIns...
php
{ "resource": "" }
q24855
Export.getTemplate
train
protected function getTemplate($format) { if (!isset($this->formatFilePaths[$format])) { throw new \Exception(sprintf('No format "%s" configured for Snippet export', $format)); } $templatePath = $this->formatFilePaths[$format]; if (!$this->templating->exists($templatePa...
php
{ "resource": "" }
q24856
MappingSubscriber.persistReference
train
private function persistReference( NodeInterface $node, DocumentAccessor $accessor, $fieldName, $locale, $fieldMapping ) { $referenceDocument = $accessor->get($fieldName); if (!$referenceDocument) { return; } if ($fieldMapping['mu...
php
{ "resource": "" }
q24857
MappingSubscriber.persistGeneric
train
private function persistGeneric( NodeInterface $node, DocumentAccessor $accessor, $fieldName, $locale, array $fieldMapping ) { try { $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapping['property'], $locale); $value = $a...
php
{ "resource": "" }
q24858
MappingSubscriber.hydrateReferenceField
train
private function hydrateReferenceField( NodeInterface $node, $document, DocumentAccessor $accessor, $fieldName, $locale, array $fieldMapping, array $options ) { try { $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapp...
php
{ "resource": "" }
q24859
MappingSubscriber.hydrateGenericField
train
private function hydrateGenericField( NodeInterface $node, DocumentAccessor $accessor, $fieldName, $locale, array $fieldMapping ) { try { $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapping['property'], $locale); $value...
php
{ "resource": "" }
q24860
WebspaceSerializeEventSubscriber.appendPortalInformation
train
private function appendPortalInformation(Webspace $webspace, Context $context, JsonSerializationVisitor $visitor) { $portalInformation = $this->webspaceManager->getPortalInformationsByWebspaceKey( $this->environment, $webspace->getKey() ); $portalInformation = $conte...
php
{ "resource": "" }
q24861
WebspaceSerializeEventSubscriber.appendUrls
train
private function appendUrls(Webspace $webspace, Context $context, JsonSerializationVisitor $visitor) { $urls = $this->webspaceUrlProvider->getUrls($webspace, $this->environment); $urls = $context->accept($urls); $visitor->addData('urls', $urls); }
php
{ "resource": "" }
q24862
WebspaceSerializeEventSubscriber.appendCustomUrls
train
private function appendCustomUrls(Webspace $webspace, Context $context, JsonSerializationVisitor $visitor) { $customUrls = []; foreach ($webspace->getPortals() as $portal) { $customUrls = array_merge( $customUrls, $this->getCustomUrlsForEnvironment($portal...
php
{ "resource": "" }
q24863
WebspaceSerializeEventSubscriber.getCustomUrlsForEnvironment
train
private function getCustomUrlsForEnvironment(Portal $portal, Environment $environment, Context $context) { $customUrls = []; foreach ($environment->getCustomUrls() as $customUrl) { $customUrl = $context->accept($customUrl); $customUrl['locales'] = $context->accept($portal->ge...
php
{ "resource": "" }
q24864
HitListener.onHit
train
public function onHit(HitEvent $event) { if (false === $event->getMetadata()->reflection->isSubclassOf(BasePageDocument::class)) { return; } $document = $event->getHit()->getDocument(); if ('/' !== $document->getUrl()[0]) { // is absolute URL ret...
php
{ "resource": "" }
q24865
PathSubscriber.onPostSerialize
train
public function onPostSerialize(ObjectEvent $event) { $visitor = $event->getVisitor(); $document = $event->getObject(); if (!$document instanceof PathBehavior || !$this->documentRegistry->hasDocument($document)) { return; } $visitor->addData('path', $this->docum...
php
{ "resource": "" }
q24866
WebspaceController.cgetAction
train
public function cgetAction(Request $request) { $checkForPermissions = $request->get('checkForPermissions', true); $locale = $this->getRequestParameter($request, 'locale', true); $webspaces = []; $securityChecker = $this->get('sulu_security.security_checker'); foreach ($this-...
php
{ "resource": "" }
q24867
WebspaceController.getAction
train
public function getAction($webspaceKey) { return $this->handleView( $this->view($this->get('sulu_core.webspace.webspace_manager')->findWebspaceByKey($webspaceKey)) ); }
php
{ "resource": "" }
q24868
SmartContentItemController.getItemsAction
train
public function getItemsAction(Request $request) { // prepare filters and options $providerAlias = $this->getRequestParameter($request, 'provider', true); $filters = $request->query->all(); $filters['excluded'] = array_filter(explode(',', $this->getRequestParameter($request, 'exclude...
php
{ "resource": "" }
q24869
SmartContentItemController.getParams
train
private function getParams(array $params) { $result = []; foreach ($params as $name => $item) { $value = $item['value']; if ('collection' === $item['type']) { $value = $this->getParams($value); } $result[$name] = new PropertyParameter(...
php
{ "resource": "" }
q24870
CustomUrlRouteProvider.addHistoryRedirectToRouteCollection
train
private function addHistoryRedirectToRouteCollection( Request $request, RouteDocument $routeDocument, RouteCollection $collection, $webspaceKey ) { $resourceSegment = PathHelper::relativizePath( $routeDocument->getTargetDocument()->getPath(), $this->ge...
php
{ "resource": "" }
q24871
PageDataProvider.loadPaginated
train
private function loadPaginated(array $options, $limit, $page, $pageSize) { $pageSize = intval($pageSize); $offset = ($page - 1) * $pageSize; $position = $pageSize * $page; if (null !== $limit && $position >= $limit) { $pageSize = $limit - $offset; $loadLimit ...
php
{ "resource": "" }
q24872
ContentMapperSubscriber.handlePreRemove
train
public function handlePreRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } $event = $this->getDeleteEvent($document); $this->deleteEvents[spl_object_hash($document)] = $event; $this->eventDispatc...
php
{ "resource": "" }
q24873
ContentMapperSubscriber.handlePostRemove
train
public function handlePostRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } $oid = spl_object_hash($document); $event = $this->deleteEvents[$oid]; $this->eventDispatcher->dispatch( C...
php
{ "resource": "" }
q24874
ContentMapperSubscriber.handlePersist
train
public function handlePersist(PersistEvent $event) { if (!$this->supports($event->getDocument())) { return; } $this->persistEvents[] = $event; }
php
{ "resource": "" }
q24875
ContentMapperSubscriber.handleFlush
train
public function handleFlush(FlushEvent $event) { foreach ($this->persistEvents as $persistEvent) { $document = $persistEvent->getDocument(); $structure = $this->documentToStructure($document); $event = new ContentNodeEvent($this->documentInspector->getNode($document), $s...
php
{ "resource": "" }
q24876
EmailType.addEmail
train
public function addEmail(\Sulu\Bundle\ContactBundle\Entity\Email $emails) { $this->emails[] = $emails; return $this; }
php
{ "resource": "" }
q24877
EmailType.removeEmail
train
public function removeEmail(\Sulu\Bundle\ContactBundle\Entity\Email $emails) { $this->emails->removeElement($emails); }
php
{ "resource": "" }
q24878
AbstractLoader.loadStructureTags
train
protected function loadStructureTags($path, $xpath) { $result = []; foreach ($xpath->query($path) as $node) { $tag = [ 'name' => null, 'attributes' => [], ]; foreach ($node->attributes as $key => $attr) { if (in_ar...
php
{ "resource": "" }
q24879
AbstractLoader.loadStructureAreas
train
protected function loadStructureAreas($path, $xpath) { $result = []; foreach ($xpath->query($path) as $node) { $area = []; foreach ($node->attributes as $key => $attr) { if (in_array($key, ['key'])) { $area[$key] = $attr->value; ...
php
{ "resource": "" }
q24880
UserProvider.getSystem
train
private function getSystem() { $system = $this->suluSystem; $request = $this->requestStack->getCurrentRequest(); if (null !== $request && $request->attributes->has('_sulu') && null !== ($webspace = $request->attributes->get('_sulu')->getAttribute('webspace')) ...
php
{ "resource": "" }
q24881
PhpcrMapper.iterateRouteNodes
train
private function iterateRouteNodes( NodeInterface $node, $callback, $webspaceKey, $languageCode, $segmentKey = null ) { if ($node->isNew()) { return null; } $routePath = $this->sessionManager->getRoutePath($webspaceKey, $languageCode); ...
php
{ "resource": "" }
q24882
PhpcrMapper.getWebspaceRouteNode
train
private function getWebspaceRouteNode($webspaceKey, $languageCode, $segmentKey) { return $this->sessionManager->getRouteNode($webspaceKey, $languageCode, $segmentKey); }
php
{ "resource": "" }
q24883
PhpcrMapper.getWebspaceRouteNodeBasePath
train
private function getWebspaceRouteNodeBasePath($webspaceKey, $languageCode, $segmentKey) { return $this->sessionManager->getRoutePath($webspaceKey, $languageCode, $segmentKey); }
php
{ "resource": "" }
q24884
PhpcrMapper.getPath
train
private function getPath($relPath, $webspaceKey, $languageCode, $segmentKey) { $basePath = $this->getWebspaceRouteNodeBasePath($webspaceKey, $languageCode, $segmentKey); return '/' . ltrim($basePath, '/') . ('' !== $relPath ? '/' . ltrim($relPath, '/') : ''); }
php
{ "resource": "" }
q24885
PhpcrMapper.getResourceLocator
train
private function getResourceLocator($path, $webspaceKey, $languageCode, $segmentKey) { $basePath = $this->getWebspaceRouteNodeBasePath($webspaceKey, $languageCode, $segmentKey); if ($path === $basePath) { return '/'; } if (false !== strpos($path, $basePath . '/')) { ...
php
{ "resource": "" }
q24886
RobotSubscriber.handleMetadataLoad
train
public function handleMetadataLoad(MetadataLoadEvent $event) { $metadata = $event->getMetadata(); if (false === $metadata->getReflectionClass()->isSubclassOf(RobotBehavior::class)) { return; } $metadata->addFieldMapping( 'noFollow', [ ...
php
{ "resource": "" }
q24887
MediaImageExtractor.convertPdfToImage
train
private function convertPdfToImage($resource) { $temporaryFilePath = $this->createTemporaryFile($resource); $command = $this->ghostScriptPath . ' -dNOPAUSE -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -sOutputFile=' . $temporaryFilePath . ' ' . '-dJPEGQ=100 -r300x300 -q ' . $tem...
php
{ "resource": "" }
q24888
MediaImageExtractor.convertPsdToImage
train
private function convertPsdToImage($resource) { $temporaryFilePath = $this->createTemporaryFile($resource); try { $image = $this->imagine->open($temporaryFilePath); $image = $image->layers()[0]; unlink($temporaryFilePath); return $this->createTempor...
php
{ "resource": "" }
q24889
MediaImageExtractor.convertVideoToImage
train
private function convertVideoToImage($resource) { $temporaryFilePath = $this->createTemporaryFile($resource); $this->videoThumbnail->generate($temporaryFilePath, '00:00:02:01', $temporaryFilePath); $extractedImage = file_get_contents($temporaryFilePath); unlink($temporaryFilePath); ...
php
{ "resource": "" }
q24890
MediaImageExtractor.createTemporaryResource
train
private function createTemporaryResource(string $content) { $tempResource = fopen('php://memory', 'r+'); fwrite($tempResource, $content); rewind($tempResource); return $tempResource; }
php
{ "resource": "" }
q24891
MediaImageExtractor.createTemporaryFile
train
private function createTemporaryFile($resource) { $path = tempnam(sys_get_temp_dir(), 'media'); $tempResource = fopen($path, 'w'); stream_copy_to_stream($resource, $tempResource); return $path; }
php
{ "resource": "" }
q24892
BlockContentType.doWrite
train
private function doWrite( NodeInterface $node, PropertyInterface $property, $userId, $webspaceKey, $languageCode, $segmentKey, $isImport = false ) { if ($property->getIsBlock()) { /** @var BlockPropertyInterface $blockProperty */ ...
php
{ "resource": "" }
q24893
BlockContentType.writeProperty
train
private function writeProperty( PropertyInterface $property, PropertyInterface $blockProperty, $value, $index, NodeInterface $node, $userId, $webspaceKey, $languageCode, $segmentKey, $isImport = false ) { // save sub property ...
php
{ "resource": "" }
q24894
SuluLocationExtension.configureMapManager
train
private function configureMapManager($config, ContainerBuilder $container) { $mapManager = $container->getDefinition('sulu_location.map_manager'); foreach ($config['enabled_providers'] as $enabledProviderName) { $providerConfig = $config['providers'][$enabledProviderName]; $...
php
{ "resource": "" }
q24895
SuluLocationExtension.configureGeolocators
train
private function configureGeolocators($config, $container) { $geolocatorName = $config['geolocator']; $container->setParameter('sulu_location.geolocator.name', $geolocatorName); $nominatim = function($config, $container) { $endpoint = $config['geolocators']['nominatim']['endpoin...
php
{ "resource": "" }
q24896
LastLoginListener.updateLastLogin
train
protected function updateLastLogin($user) { if ($user instanceof BaseUser) { $user->setLastLogin(new \DateTime()); $this->entityManager->flush(); } }
php
{ "resource": "" }
q24897
QuerySubscriber.handleCreate
train
public function handleCreate(QueryCreateEvent $event) { $innerQuery = $event->getInnerQuery(); if (is_string($innerQuery)) { $phpcrQuery = $this->getQueryManager()->createQuery($innerQuery, QueryInterface::JCR_SQL2); } elseif ($innerQuery instanceof QueryInterface) { ...
php
{ "resource": "" }
q24898
QuerySubscriber.handleQueryExecute
train
public function handleQueryExecute(QueryExecuteEvent $event) { $query = $event->getQuery(); $locale = $query->getLocale(); $phpcrResult = $query->getPhpcrQuery()->execute(); $event->setResult( new QueryResultCollection($phpcrResult, $this->eventDispatcher, $locale, $even...
php
{ "resource": "" }
q24899
ContactRepository.addSorting
train
private function addSorting($qb, $sorting, $prefix = 'u') { // Add order by foreach ($sorting as $k => $d) { $qb->addOrderBy($prefix . '.' . $k, $d); } return $qb; }
php
{ "resource": "" }