_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q300
|
Issue.addComment
|
train
|
public function addComment($issue, $body, $visibilityType = null, $visibilityName = null, $expand = false)
{
$path = "/issue/{$issue}/comment" . ($expand ? '?expand' : '');
$data = array(
'body' => $body
);
if ($visibilityType !== null && $visibilityName !== null) {
$data['visibility'] = array(
'type' => $visibilityType,
'value' => $visibilityName
);
|
php
|
{
"resource": ""
}
|
q301
|
Issue.deleteComment
|
train
|
public function deleteComment($issue, $commentId)
{
$path = "/issue/{$issue}/comment/{$commentId}";
|
php
|
{
"resource": ""
}
|
q302
|
Issue.getEditMetadata
|
train
|
public function getEditMetadata($issue)
{
$path = "/issue/{$issue}/editmeta";
try {
$data = $this->client->callGet($path)->getData();
if (!isset($data['fields'])) {
throw new JiraException("Bad metadata");
|
php
|
{
"resource": ""
}
|
q303
|
Issue.addWatcher
|
train
|
public function addWatcher($issue, $login)
{
$path = "/issue/{$issue}/watchers";
try {
$this->client->callPost($path, $login);
} catch (Exception $e) {
|
php
|
{
"resource": ""
}
|
q304
|
Issue.deleteWatcher
|
train
|
public function deleteWatcher($issue, $login)
{
$path = "/issue/{$issue}/watchers?username={$login}";
try {
$this->client->callDelete($path);
} catch (Exception $e) {
|
php
|
{
"resource": ""
}
|
q305
|
Issue.get
|
train
|
public function get($issue, $includedFields = null, $expandFields = false)
{
$params = array();
if ($includedFields !== null) {
$params['fields'] = $includedFields;
}
if ($expandFields) {
$params['expand'] = '';
|
php
|
{
"resource": ""
}
|
q306
|
Packetizer.findall
|
train
|
protected function findall(string $haystack, $needle): array
{
$lastPos = 0;
$positions = [];
while (($lastPos = strpos($haystack, $needle, $lastPos)) !== false) {
|
php
|
{
"resource": ""
}
|
q307
|
Packetizer.findFirstPacketOffset
|
train
|
protected function findFirstPacketOffset()
{
// This is quite ugly because it will parse the entire buffer whatever it's size is
// TODO Rewrite this in a more clever way
$positions = $this->findall($this->buffer, 'G');
|
php
|
{
"resource": ""
}
|
q308
|
BaseCollector.extGetLL
|
train
|
protected function extGetLL($key, $convertWithHtmlspecialchars = true)
{
$labelStr = $this->getLanguageService()->getLL($key);
if ($convertWithHtmlspecialchars) {
|
php
|
{
"resource": ""
}
|
q309
|
BaseCollector.extGetFeAdminValue
|
train
|
public function extGetFeAdminValue($sectionName, $val = '')
{
$beUser = $this->getBackendUser();
// Override all settings with user TSconfig
if ($val && isset($beUser->extAdminConfig['override.'][$sectionName . '.'][$val])) {
return $beUser->extAdminConfig['override.'][$sectionName . '.'][$val];
}
if (!$val && isset($beUser->extAdminConfig['override.'][$sectionName])) {
|
php
|
{
"resource": ""
}
|
q310
|
CollectionBlockService.loadCollection
|
train
|
protected function loadCollection(BlockInterface $block)
{
$properties = $block->getProperties();
$conditions = (isset($properties['conditions'])) ? $properties['conditions'] : '[]';
$conditions = $this->expressionEngine->deserialize($conditions);
if (empty($conditions)) {
return;
}
$site = $this->siteManager->getSite();
$qb = $this->expressionEngine->toQueryBuilder($conditions, $this->contentManager->getClass());
$qb->andWhere('a.publishAt < :now OR a.publishAt IS NULL')
->andWhere('a.active = :active')
->andWhere('a.layout = :layout');
if ($site == null) {
$qb->andWhere('a.site IS NULL');
} else {
$qb->andWhere('a.site = :site')
->setParameter('site', $site);
}
$qb->setParameter('active', true)
->setParameter('layout', false)
->setParameter('now', new \DateTime());
|
php
|
{
"resource": ""
}
|
q311
|
PointerBlockService.setResponseHeaders
|
train
|
protected function setResponseHeaders(BlockInterface $block, Response $response)
{
if ($block && $block->getReference()) {
if ($this->getReferenceService($block)->isEsiEnabled($block->getReference())) {
|
php
|
{
"resource": ""
}
|
q312
|
PostController.listAction
|
train
|
public function listAction()
{
$source = new Entity($this->get('opifer.form.post_manager')->getClass());
$formColumn = new TextColumn(['id' => 'posts', 'title' => 'Form', 'source' => false, 'filterable' => false, 'sortable' => false, 'safe' => false]);
$formColumn->manipulateRenderCell(function ($value, $row, $router) {
return '<a href="'.$this->generateUrl('opifer_form_form_edit', ['id'=> $row->getEntity()->getForm()->getId()]).'">'.$row->getEntity()->getForm()->getName().'</a>';
|
php
|
{
"resource": ""
}
|
q313
|
plgSystemBasicAuth.onAfterRoute
|
train
|
public function onAfterRoute()
{
$app = JFactory::getApplication();
$username = $app->input->server->get('PHP_AUTH_USER', null, 'string');
$password = $app->input->server->get('PHP_AUTH_PW', null, 'string');
if ($username && $password)
{
|
php
|
{
"resource": ""
}
|
q314
|
plgSystemBasicAuth._login
|
train
|
protected function _login($username, $password, $application)
{
// If we did receive the user credentials from the user, try to login
if($application->login(array('username' => $username, 'password' => $password)) !== true) {
return false;
}
// If we have logged in succesfully, make sure to fullfil
// Koowa's CSRF authenticator checks if the framework is
|
php
|
{
"resource": ""
}
|
q315
|
Media.getReadableFilesize
|
train
|
public function getReadableFilesize()
{
$size = $this->filesize;
if ($size < 1) {
return $size;
}
if ($size < 1024) {
|
php
|
{
"resource": ""
}
|
q316
|
MediaRepository.createQueryBuilderFromRequest
|
train
|
public function createQueryBuilderFromRequest(Request $request)
{
$qb = $this->createQueryBuilder('m');
if ($request->get('ids')) {
$ids = explode(',', $request->get('ids'));
$qb->andWhere('m.id IN (:ids)')->setParameter('ids', $ids);
}
$qb->andWhere('m.status = :status')->setParameter('status', Media::STATUS_ENABLED);
if ($request->get('search')) {
$qb->andWhere('m.name LIKE :term')->setParameter('term', '%'.$request->get('search').'%');
|
php
|
{
"resource": ""
}
|
q317
|
MediaRepository.search
|
train
|
public function search($term, $limit, $offset, $orderBy = null)
{
$qb = $this->createQueryBuilder('m');
$qb->where('m.name LIKE :term')
->andWhere('m.status IN (:statuses)')
->setParameters(array(
'term' => '%'.$term.'%',
'statuses' => array(0, 1),
)
);
if ($limit) {
|
php
|
{
"resource": ""
}
|
q318
|
FilterableTrait.setQuerystring
|
train
|
public function setQuerystring(array $str = array(), $append = true, $default = true)
{
if ( is_null($this->filterable) ) {
$this->resetFilterableOptions();
}
if ( sizeof($str) == 0 && $default ) {
// Default to PHP query string
parse_str($_SERVER['QUERY_STRING'], $this->filterable['qstring']);
} else {
$this->filterable['qstring'] = $str;
}
if ( sizeof($this->filterable['qstring']) > 0 ) {
if ( !$append ) {
// Overwrite data
$this->filterable['filters'] = array();
}
foreach ( $this->filterable['qstring'] as $k => $v ) {
if ( $v == '' ) {
continue;
}
$thisColumn = isset($this->filterable['columns'][$k]) ? $this->filterable['columns'][$k] : false;
if ( $thisColumn ) {
// Query string part matches column (or alias)
$this->filterable['filters'][$thisColumn]['val'] = $v;
// Evaluate boolean parameter in query string
$thisBoolData = isset($this->filterable['qstring']['bool'][$k]) ? $this->filterable['qstring']['bool'][$k] : false;
$thisBoolAvailable = $thisBoolData && isset($this->filterable['bools'][$thisBoolData]) ? $this->filterable['bools'][$thisBoolData] : false;
if ( $thisBoolData && $thisBoolAvailable ) {
$this->filterable['filters'][$thisColumn]['boolean'] = $thisBoolAvailable;
|
php
|
{
"resource": ""
}
|
q319
|
FilterableTrait.scopeFilterColumns
|
train
|
public function scopeFilterColumns($query, $columns = array(), $validate = false)
{
if ( sizeof($columns) > 0 ) {
// Set columns that can be filtered
$this->setColumns($columns);
}
// Validate columns
if ( $validate ) {
$this->validateColumns();
}
// Ensure that query string is parsed at least once
if ( sizeof($this->filterable['filters']) == 0 ) {
$this->setQuerystring();
}
// Apply conditions to Eloquent query object
if ( sizeof($this->filterable['filters']) > 0 ) {
foreach ( $this->filterable['filters'] as $k => $v ) {
$where = $v['boolean'];
if ( is_array($v['val']) ) {
if ( isset($v['val']['start']) && isset($v['val']['end']) ) {
// BETWEEN a AND b
$query->whereBetween($k, array($v['val']['start'], $v['val']['end']));
} else {
// a = b OR c = d OR...
$query->{$where}(function($q) use ($k, $v, $query)
{
foreach ( $v['val'] as $key => $val ) {
$q->orWhere($k, $v['operator'], $val);
}
});
}
} else {
// a = b
$query->{$where}($k, $v['operator'], $v['val']);
}
}
}
// Apply callbacks
|
php
|
{
"resource": ""
}
|
q320
|
Environment.getAllBlocks
|
train
|
public function getAllBlocks()
{
$this->load();
$blocks = [];
foreach ($this->blockCache as $blockCache) {
$blocks =
|
php
|
{
"resource": ""
}
|
q321
|
Signature.verify
|
train
|
public function verify(Signer $signer, $payload, $key)
{
|
php
|
{
"resource": ""
}
|
q322
|
FileProvider.buildCreateForm
|
train
|
public function buildCreateForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('files', DropzoneType::class, [
'mapped' => false,
'path' => $this->router->generate('opifer_api_media_upload'),
|
php
|
{
"resource": ""
}
|
q323
|
MailingListRepository.findByIds
|
train
|
public function findByIds($ids)
{
if (!is_array($ids)) {
$ids = explode(',', $ids);
}
return $this->createQueryBuilder('ml')
|
php
|
{
"resource": ""
}
|
q324
|
BlockDiscriminatorListener.getDiscriminatorMap
|
train
|
public function getDiscriminatorMap()
{
$map = array();
foreach ($this->blockManager->getValues() as
|
php
|
{
"resource": ""
}
|
q325
|
ValidJsonValidator.validate
|
train
|
public function validate($value, Constraint $constraint)
{
if (is_array($value)) {
$value = json_encode($value);
|
php
|
{
"resource": ""
}
|
q326
|
ContentManager.createMissingValueSet
|
train
|
public function createMissingValueSet(Content $content)
{
if ($content->getContentType() !== null && $content->getValueSet() === null)
{
$valueSet = new ValueSet();
$this->em->persist($valueSet);
|
php
|
{
"resource": ""
}
|
q327
|
ContentTreePickerType.stripMetadata
|
train
|
protected function stripMetadata(array $array, $stripped = [])
{
$allowed = ['id', '__children'];
foreach ($array as $item) {
if (count($item['__children'])) {
$item['__children']
|
php
|
{
"resource": ""
}
|
q328
|
Typo3DebugBar.var_dump
|
train
|
public function var_dump($item)
{
if ($this->hasCollector('vardump')) {
/** @var VarDumpCollector
|
php
|
{
"resource": ""
}
|
q329
|
ValuesSubscriber.preSetData
|
train
|
public function preSetData(FormEvent $event)
{
$data = $event->getData();
$form = $event->getForm();
$fields = $form->getConfig()->getOption('fields');
if (null === $data || '' === $data) {
$data = [];
}
if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
}
// Sorting values so that they display in sorted order of the attributes
uasort($data, function ($a, $b) {
return $a->getAttribute()->getSort() > $b->getAttribute()->getSort();
});
/**
* @var string $name
* @var Value $value
*/
foreach ($data as $name => $value) {
//Do not add fields when there not in fields value when giving.
if (!empty($fields) && !in_array($name, $fields)) {
continue;
}
// Do not
|
php
|
{
"resource": ""
}
|
q330
|
Api.verifyHash
|
train
|
public function verifyHash(array $params)
{
$result = false;
try {
$this->sdk->CheckOutFeedback($params);
$result =
|
php
|
{
"resource": ""
}
|
q331
|
RedirectController.editAction
|
train
|
public function editAction(Request $request, $id)
{
$manager = $this->get('opifer.redirect.redirect_manager');
$redirect = $manager->getRepository()->find($id);
$form = $this->createForm(RedirectType::class, $redirect);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$manager->save($redirect);
$this->addFlash('success', $this->get('translator')->trans('opifer_redirect.flash.updated'));
|
php
|
{
"resource": ""
}
|
q332
|
RedirectController.deleteAction
|
train
|
public function deleteAction($id)
{
$manager = $this->get('opifer.redirect.redirect_manager');
$redirect = $manager->getRepository()->find($id);
$manager->remove($redirect);
|
php
|
{
"resource": ""
}
|
q333
|
ContentManager.getContentByReference
|
train
|
public function getContentByReference($reference)
{
if (is_numeric($reference)) {
// If the reference is numeric, it must be the content ID from an existing
// content item, which has to be updated.
$nestedContent = $this->getRepository()->find($reference);
} else {
// If not, $reference is a template name for a to-be-created content item.
|
php
|
{
"resource": ""
}
|
q334
|
ContentManager.detachAndPersist
|
train
|
private function detachAndPersist($entity)
{
$this->em->detach($entity);
|
php
|
{
"resource": ""
}
|
q335
|
RelativeSlugHandler.hasChangedParent
|
train
|
private function hasChangedParent(SluggableAdapter $ea, $object, $getter)
{
$relation = $object->$getter();
if (!$relation) {
return false;
}
$changeSet = $ea->getObjectChangeSet($this->om->getUnitOfWork(), $relation);
|
php
|
{
"resource": ""
}
|
q336
|
ContentController.typeAction
|
train
|
public function typeAction($type)
{
$contentType = $this->get('opifer.content.content_type_manager')->getRepository()->find($type);
if (!$contentType) {
throw $this->createNotFoundException(sprintf('Content Type with ID %d could not be found.', $type));
}
$queryBuilder = $this->get('opifer.content.content_manager')->getRepository()->createQueryBuilder('c')
->select('c', 'vs', 'v', 'a')
->leftJoin('c.valueSet', 'vs')
->leftJoin('vs.values', 'v')
->leftJoin('v.attribute', 'a');
$source = new Entity($this->getParameter('opifer_content.content_class'));
$source->initQueryBuilder($queryBuilder);
$tableAlias = $source->getTableAlias();
$source->manipulateQuery(function ($query) use ($tableAlias, $contentType) {
$query->andWhere($tableAlias . '.contentType = :contentType')->setParameter('contentType', $contentType);
$query->andWhere($tableAlias . '.layout = :layout')->setParameter('layout', false);
});
$designAction = new RowAction('button.design', 'opifer_content_contenteditor_design');
$designAction->setRouteParameters(['id', 'owner' => 'content']);
$designAction->setRouteParametersMapping(['id' => 'ownerId']);
$detailsAction = new RowAction('button.details', 'opifer_content_content_edit');
$detailsAction->setRouteParameters(['id']);
//$deleteAction = new RowAction('button.delete', 'opifer_content_content_delete');
//$deleteAction->setRouteParameters(['id']);
/* @var $grid \APY\DataGridBundle\Grid\Grid */
$grid = $this->get('grid');
$grid->setId('content')
->setSource($source)
->addRowAction($detailsAction)
->addRowAction($designAction);
|
php
|
{
"resource": ""
}
|
q337
|
YahooWeatherAPI.getTemperature
|
train
|
public function getTemperature($withUnit = false)
{
if (!$this->lastResponse || !isset($this->lastResponse['item']['condition']['temp'])) {
return '';
}
$return = $this->lastResponse['item']['condition']['temp'];
|
php
|
{
"resource": ""
}
|
q338
|
YahooWeatherAPI.getWind
|
train
|
public function getWind($withUnit = false)
{
if (!$this->lastResponse || !isset($this->lastResponse['wind']['speed'])) {
return array();
}
$response = array(
'chill' => $this->lastResponse['wind']['chill'],
|
php
|
{
"resource": ""
}
|
q339
|
SubscribeBlockService.subscribeAction
|
train
|
public function subscribeAction(Block $block)
{
$response = $this->execute($block);
$properties = $block->getProperties();
if ($this->subscribed && isset($properties['responseType']) && $properties['responseType'] == 'redirect') {
$content
|
php
|
{
"resource": ""
}
|
q340
|
SlugTransformer.transform
|
train
|
public function transform($slug)
{
if (null === $slug) {
return;
}
// If the slug ends with a slash, return just a slash
// so the item is used as the index page of that directory
if (substr($slug, -1) == '/') {
|
php
|
{
"resource": ""
}
|
q341
|
ContentTypeManager.create
|
train
|
public function create()
{
$class = $this->getClass();
$contentType = new $class();
$schema = $this->schemaManager->create();
|
php
|
{
"resource": ""
}
|
q342
|
Ecdsa.createSignatureHash
|
train
|
private function createSignatureHash(Signature $signature)
{
$length = $this->getSignatureLength();
return pack(
'H*',
sprintf(
'%s%s',
str_pad($this->adapter->decHex($signature->getR()), $length, '0',
|
php
|
{
"resource": ""
}
|
q343
|
Ecdsa.extractSignature
|
train
|
private function extractSignature($value)
{
$length = $this->getSignatureLength();
$value = unpack('H*', $value)[1];
return new Signature(
|
php
|
{
"resource": ""
}
|
q344
|
KeyParser.getKeyContent
|
train
|
private function getKeyContent(Key $key, $header)
{
$match = null;
preg_match(
'/^[\-]{5}BEGIN ' . $header . '[\-]{5}(.*)[\-]{5}END ' . $header . '[\-]{5}$/',
str_replace([PHP_EOL, "\n", "\r"], '', $key->getContent()),
$match
|
php
|
{
"resource": ""
}
|
q345
|
MediaExtension.sourceUrl
|
train
|
public function sourceUrl($media)
{
return new \Twig_Markup(
|
php
|
{
"resource": ""
}
|
q346
|
SearchResultsBlockService.getSearchResults
|
train
|
public function getSearchResults()
{
$term = $this->getRequest()->get('search', null);
// Avoid querying ALL content when no search value is provided
if (!$term) {
return [];
}
$host
|
php
|
{
"resource": ""
}
|
q347
|
InstallController.index
|
train
|
public function index()
{
Session::forget('install-module');
$result = [];
foreach ($this->extensions as $ext) {
if (extension_loaded($ext)) {
$result [$ext] = 'true';
} else {
|
php
|
{
"resource": ""
}
|
q348
|
OpiferCmsBundle.build
|
train
|
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new
|
php
|
{
"resource": ""
}
|
q349
|
UserFormType.flattenRoles
|
train
|
public function flattenRoles($data)
{
$result = array();
foreach ($data as $key => $value) {
if (substr($key, 0, 4) === 'ROLE') {
$result[$key] = $key;
}
if (is_array($value)) {
|
php
|
{
"resource": ""
}
|
q350
|
Configuration.addBlocksSection
|
train
|
private function addBlocksSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('blocks')
->addDefaultsIfNotSet()
->children()
->arrayNode('subscribe')
->addDefaultsIfNotSet()
->children()
->scalarNode('view')->defaultValue('OpiferMailingListBundle:Block:subscribe.html.twig')->end()
|
php
|
{
"resource": ""
}
|
q351
|
MailingListController.createAction
|
train
|
public function createAction(Request $request)
{
$mailingList = new MailingList();
$form = $this->createForm(MailingListType::class, $mailingList, [
'action' => $this->generateUrl('opifer_mailing_list_mailing_list_create'),
]);
$form->handleRequest($request);
|
php
|
{
"resource": ""
}
|
q352
|
MailingListController.editAction
|
train
|
public function editAction(Request $request, $id)
{
$mailingList = $this->getDoctrine()->getRepository('OpiferMailingListBundle:MailingList')->find($id);
$form = $this->createForm(MailingListType::class, $mailingList);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
|
php
|
{
"resource": ""
}
|
q353
|
MailingListController.deleteAction
|
train
|
public function deleteAction($id)
{
$mailingList = $this->getDoctrine()->getRepository('OpiferMailingListBundle:MailingList')->find($id);
if (!empty($mailingList)) {
|
php
|
{
"resource": ""
}
|
q354
|
ContentController.idsAction
|
train
|
public function idsAction($ids)
{
$items = $this->get('opifer.content.content_manager')
->getRepository()
->findOrderedByIds($ids);
$stringHelper = $this->container->get('opifer.content.string_helper');
$contents
|
php
|
{
"resource": ""
}
|
q355
|
ContentController.viewAction
|
train
|
public function viewAction(Request $request, $id, $structure = 'tree')
{
$response = new JsonResponse();
/** @var ContentRepository $contentRepository */
$contentRepository = $this->get('opifer.content.content_manager')->getRepository();
$content = $contentRepository->findOneByIdOrSlug($id, true);
if ($content->getSlug() === '404') {
// If the original content was not found and the 404 page was returned, set the correct status code
$response->setStatusCode(404);
}
$version = $request->query->get('_version');
$debug = $this->getParameter('kernel.debug');
$response->setLastModified($content->getLastUpdateDate());
$response->setPublic();
if (null === $version && false == $debug && $response->isNotModified($request)) {
// return the 304 Response immediately
return $response;
}
/** @var Environment $environment */
$environment = $this->get('opifer.content.block_environment');
$environment->setObject($content);
if (null !== $version && $this->isGranted('ROLE_ADMIN')) {
|
php
|
{
"resource": ""
}
|
q356
|
ContentController.deleteAction
|
train
|
public function deleteAction($id)
{
/** @var ContentManager $manager */
$manager = $this->get('opifer.content.content_manager');
$content = $manager->getRepository()->find($id);
//generate new slug so deleted slug can be used again
$hashedSlug = $content->getSlug().'-'.sha1(date('Y-m-d H:i:s'));
|
php
|
{
"resource": ""
}
|
q357
|
ValidationData.setCurrentTime
|
train
|
public function setCurrentTime($currentTime)
{
$this->items['iat'] = (int) $currentTime;
|
php
|
{
"resource": ""
}
|
q358
|
ValidationData.get
|
train
|
public function get($name)
{
return isset($this->items[$name]) ?
|
php
|
{
"resource": ""
}
|
q359
|
LocaleController.createAction
|
train
|
public function createAction(Request $request)
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
$locale = new Locale();
$form = $this->createForm(new LocaleType(), $locale);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($locale);
$em->flush();
|
php
|
{
"resource": ""
}
|
q360
|
LocaleController.editAction
|
train
|
public function editAction(Request $request, $id = null)
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
$em = $this->getDoctrine()->getManager();
if (is_numeric($id)) {
$locale = $em->getRepository(Locale::class)->find($id);
} else {
$locale = $em->getRepository(Locale::class)->findOneByLocale($id);
}
$form = $this->createForm(new LocaleType(),
|
php
|
{
"resource": ""
}
|
q361
|
ContentListValue.getOrdered
|
train
|
public function getOrdered()
{
if (!$this->sort) {
return $this->content;
}
$unordered = [];
foreach ($this->content as $content) {
$unordered[$content->getId()] = $content;
}
$ordered = [];
$sort = json_decode($this->sort, true);
|
php
|
{
"resource": ""
}
|
q362
|
OpiferContentExtension.prepend
|
train
|
public function prepend(ContainerBuilder $container)
{
$configs = $container->getExtensionConfig($this->getAlias());
$config = $this->processConfiguration(new Configuration(), $configs);
$container->setAlias('opifer.content.content_manager', $config['content_manager']);
$container->setDefinition('opifer.content.cache_provider', new Definition($config['cache_provider']));
|
php
|
{
"resource": ""
}
|
q363
|
CollectionToStringTransformer.transform
|
train
|
public function transform($value)
{
if (null === $value || !($value instanceof Collection)) {
return '';
}
$string = '';
foreach ($value as $item) {
$string .= $item->getId();
|
php
|
{
"resource": ""
}
|
q364
|
BlockExclusionStrategy.shouldSkipClass
|
train
|
public function shouldSkipClass(ClassMetadata $metadata, Context $context)
{
$obj = null;
// Get the last item of the visiting set
foreach ($context->getVisitingSet() as $item) {
$obj = $item;
}
|
php
|
{
"resource": ""
}
|
q365
|
PrototypeCollection.add
|
train
|
public function add(Prototype $prototype)
{
if ($this->has($prototype->getKey())) {
throw new \Exception(sprintf('A prototype with the key %s
|
php
|
{
"resource": ""
}
|
q366
|
PrototypeCollection.has
|
train
|
public function has($key)
{
foreach ($this->collection as $prototype) {
|
php
|
{
"resource": ""
}
|
q367
|
Schema.getAttribute
|
train
|
public function getAttribute($name)
{
foreach ($this->attributes as $attribute) {
|
php
|
{
"resource": ""
}
|
q368
|
ContentRepository.findLastUpdated
|
train
|
public function findLastUpdated($limit = 5)
{
$query = $this->createQueryBuilder('c')
->orderBy('c.updatedAt', 'DESC')
|
php
|
{
"resource": ""
}
|
q369
|
ContentRepository.findLastCreated
|
train
|
public function findLastCreated($limit = 5)
{
$query = $this->createQueryBuilder('c')
->orderBy('c.createdAt', 'DESC')
|
php
|
{
"resource": ""
}
|
q370
|
ContentRepository.findIndexable
|
train
|
public function findIndexable()
{
return $this->createQueryBuilder('c')
->where('c.indexable = :indexable')
->Andwhere('c.active = :active')
->Andwhere('c.layout = :layout')
->setParameters([
'active' => true,
|
php
|
{
"resource": ""
}
|
q371
|
Info.summary
|
train
|
protected function summary($signal, $time_start, $time_end, $query_exec_time, $exec_queries)
{
$this->newLine();
$this->text(sprintf(
'<info>%s</info> query process (%s s)', $signal, number_format($query_exec_time, 4)
));
$this->newLine();
$this->text(sprintf('<comment>%s</comment>', str_repeat('-', 30)));
$this->newLine();
|
php
|
{
"resource": ""
}
|
q372
|
CollectionToObjectTransformer.reverseTransform
|
train
|
public function reverseTransform($value)
{
if ($value instanceof Collection) {
return $value;
|
php
|
{
"resource": ""
}
|
q373
|
Serve.configure
|
train
|
protected function configure()
{
parent::configure();
$this
->addOption(
'host',
NULL,
InputOption::VALUE_OPTIONAL,
'The host address to serve the application on.',
'localhost'
)
->addOption(
'docroot',
NULL,
InputOption::VALUE_OPTIONAL,
|
php
|
{
"resource": ""
}
|
q374
|
SitemapController.sitemapAction
|
train
|
public function sitemapAction()
{
/* @var ContentInterface[] $content */
$contents = $this->get('opifer.content.content_manager')->getRepository()->findIndexable();
$event = new SitemapEvent();
foreach ($contents as $content) {
$event->addUrl($this->generateUrl('_content', ['slug' => $content->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL), $content->getUpdatedAt());
}
|
php
|
{
"resource": ""
}
|
q375
|
PointerBlock.getChildren
|
train
|
public function getChildren()
{
$children = new ArrayCollection();
if ($this->reference) {
|
php
|
{
"resource": ""
}
|
q376
|
YoutubeProvider.getUrl
|
train
|
public function getUrl(MediaInterface $media)
{
$metadata = $media->getMetaData();
|
php
|
{
"resource": ""
}
|
q377
|
Command.configure
|
train
|
protected function configure()
{
$this
->setName($this->name)
->setDescription($this->description)
->setAliases($this->aliases)
->addOption(
'env',
null,
|
php
|
{
"resource": ""
}
|
q378
|
Command.initialize
|
train
|
protected function initialize(InputInterface $input, OutputInterface $output)
{
try
{
$this->input = $input;
$this->output = $output;
$this->style = new SymfonyStyle($input, $output);
$file = new \SplFileInfo($this->getOption('env'));
// Create an environment instance
$this->env = new Dotenv(
$file->getPathInfo()->getRealPath(),
$file->getFilename()
|
php
|
{
"resource": ""
}
|
q379
|
ContentRepository.createValuedQueryBuilder
|
train
|
public function createValuedQueryBuilder($entityAlias)
{
return $this->createQueryBuilder($entityAlias)
->select($entityAlias, 'vs', 'v', 'a', 'p', 's')
->leftJoin($entityAlias.'.valueSet', 'vs')
->leftJoin('vs.schema', 's')
|
php
|
{
"resource": ""
}
|
q380
|
ContentRepository.getContentFromRequest
|
train
|
public function getContentFromRequest(Request $request)
{
$qb = $this->createValuedQueryBuilder('c');
if ($request->get('q')) {
$qb->leftJoin('c.template', 't');
$qb->andWhere('c.title LIKE :query OR c.alias LIKE :query OR c.slug LIKE :query OR t.displayName LIKE :query');
$qb->setParameter('query', '%'.$request->get('q').'%');
}
if ($ids = $request->get('ids')) {
$ids = explode(',', $ids);
$qb->andWhere('c.id IN (:ids)')->setParameter('ids', $ids);
}
|
php
|
{
"resource": ""
}
|
q381
|
ContentRepository.findOneById
|
train
|
public function findOneById($id)
{
$query = $this->createValuedQueryBuilder('c')
->where('c.id = :id')
|
php
|
{
"resource": ""
}
|
q382
|
ContentRepository.findOneBySlug
|
train
|
public function findOneBySlug($slug)
{
$query = $this->createQueryBuilder('c')
->where('c.slug = :slug')
->setParameter('slug', $slug)
->andWhere('c.publishAt < :now OR c.publishAt IS NULL')
->andWhere('c.active = :active')
->andWhere('c.layout = :layout')
->setParameter('now',
|
php
|
{
"resource": ""
}
|
q383
|
ContentRepository.findOneByIdOrSlug
|
train
|
public function findOneByIdOrSlug($idOrSlug, $allow404 = false)
{
if (is_numeric($idOrSlug)) {
$content = $this->find($idOrSlug);
} else {
$content = $this->findOneBySlug($idOrSlug);
}
// If no content was found for the passed id, return the 404
|
php
|
{
"resource": ""
}
|
q384
|
ContentRepository.findActiveBySlug
|
train
|
public function findActiveBySlug($slug, $host)
{
$query = $this->createValuedQueryBuilder('c')
->leftJoin('c.site', 'os')
->leftJoin('os.domains', 'd')
->where('c.slug = :slug')
->andWhere('c.active = :active')
->andWhere('c.layout = :layout')
->andWhere('c.publishAt < :now OR c.publishAt IS NULL')
->andWhere('d.domain = :host OR c.site IS NULL')
->setParameters([
'slug' => $slug,
|
php
|
{
"resource": ""
}
|
q385
|
ContentRepository.findActiveByAlias
|
train
|
public function findActiveByAlias($alias, $host)
{
$query = $this->createValuedQueryBuilder('c')
->leftJoin('c.site', 'os')
->leftJoin('os.domains', 'd')
->where('c.alias = :alias')
->andWhere('c.active = :active')
->andWhere('c.layout = :layout')
->andWhere('(c.publishAt < :now OR c.publishAt IS NULL)')
->andWhere('d.domain = :host OR c.site IS NULL')
->setParameters([
'alias' => $alias,
|
php
|
{
"resource": ""
}
|
q386
|
ContentRepository.findByIds
|
train
|
public function findByIds($ids)
{
if (!is_array($ids)) {
$ids = explode(',', $ids);
}
if (!$ids) {
return [];
}
return $this->createValuedQueryBuilder('c')
->andWhere('c.id IN (:ids)')->setParameter('ids', $ids)
|
php
|
{
"resource": ""
}
|
q387
|
ContentRepository.sortByArray
|
train
|
private function sortByArray($items, array $order)
{
$unordered = [];
foreach ($items as $content) {
$unordered[$content->getId()] = $content;
}
$ordered = [];
foreach ($order as $id) {
|
php
|
{
"resource": ""
}
|
q388
|
ContentRepository.findByLevels
|
train
|
public function findByLevels($levels = 1, $ids = array())
{
$query = $this->createQueryBuilder('c');
if ($levels > 0) {
$selects = ['c'];
for ($i = 1; $i <= $levels; ++$i) {
$selects[] = 'c'.$i;
}
$query->select($selects);
for ($i = 1; $i <= $levels; ++$i) {
$previous = ($i - 1 == 0) ? '' : ($i - 1);
$query->leftJoin('c'.$previous.'.children', 'c'.$i, 'WITH', 'c'.$i.'.active = :active AND c'.$i.'.showInNavigation = :show');
}
}
if ($ids) {
$query->andWhere('c.id IN (:ids)')->setParameter('ids', $ids);
|
php
|
{
"resource": ""
}
|
q389
|
ContentRepository.sortSearchResults
|
train
|
public function sortSearchResults($results, $term)
{
$sortedResults = [];
if (!empty($results)) {
foreach ($results as $result) {
if (stripos($result->getTitle(), $term) !== false) {
array_unshift($sortedResults, $result);
|
php
|
{
"resource": ""
}
|
q390
|
Cron.setState
|
train
|
public function setState($newState)
{
if ($newState === $this->state) {
return;
}
switch ($newState) {
case self::STATE_RUNNING:
$this->startedAt = new \DateTime();
break;
case self::STATE_FINISHED:
case self::STATE_FAILED:
case self::STATE_TERMINATED:
|
php
|
{
"resource": ""
}
|
q391
|
Cron.getNextRunDate
|
train
|
public function getNextRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate =
|
php
|
{
"resource": ""
}
|
q392
|
Cron.getPreviousRunDate
|
train
|
public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate =
|
php
|
{
"resource": ""
}
|
q393
|
Cron.getMultipleRunDates
|
train
|
public function getMultipleRunDates($total, $currentTime = 'now', $invert = false, $allowCurrentDate =
|
php
|
{
"resource": ""
}
|
q394
|
SelectValue.getValue
|
train
|
public function getValue()
{
$options = parent::getValue();
if (count($options)) {
if (empty( $options[0] )) {
$collection = $options->getValues();
|
php
|
{
"resource": ""
}
|
q395
|
UserController.editAction
|
train
|
public function editAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$user = $em->getRepository('OpiferCmsBundle:User')->find($id);
$form = $this->createForm(UserFormType::class, $user);
$form->handleRequest($request);
if ($form->isValid()) {
if ($user->isTwoFactorEnabled() == false) {
$user->setGoogleAuthenticatorSecret(null);
}
$this->get('fos_user.user_manager')->updateUser($user, true);
$this->addFlash('success', $this->get('translator')->trans('user.edit.success', [
'%username%' =>
|
php
|
{
"resource": ""
}
|
q396
|
UserController.profileAction
|
train
|
public function profileAction(Request $request)
{
$user = $this->getUser();
$form = $this->createForm(ProfileType::class, $user);
$form->handleRequest($request);
if ($form->isValid()) {
if ($user->isTwoFactorEnabled() == false) {
$user->setGoogleAuthenticatorSecret(null);
}
$this->get('fos_user.user_manager')->updateUser($user, true);
if ($user->isTwoFactorEnabled() == true && empty($user->getGoogleAuthenticatorSecret())) {
return $this->redirectToRoute('opifer_cms_user_activate_2fa');
}
|
php
|
{
"resource": ""
}
|
q397
|
UserController.activateGoogleAuthAction
|
train
|
public function activateGoogleAuthAction(Request $request)
{
$user = $this->getUser();
$secret = $this->container->get("scheb_two_factor.security.google_authenticator")->generateSecret();
$user->setGoogleAuthenticatorSecret($secret);
//Generate QR url
$qrUrl = $this->container->get("scheb_two_factor.security.google_authenticator")->getUrl($user);
$form = $this->createForm(GoogleAuthType::class, $user);
$form->handleRequest($request);
if ($form->isValid()) {
$this->get('fos_user.user_manager')->updateUser($user, true);
$this->addFlash('success', 'Your profile was updated successfully!');
|
php
|
{
"resource": ""
}
|
q398
|
BlockManager.getService
|
train
|
public function getService($block)
{
$blockType = ($block instanceof BlockInterface) ? $block->getBlockType() : $block;
if (!isset($this->services[$blockType])) {
throw new \Exception(sprintf("No BlockService available
|
php
|
{
"resource": ""
}
|
q399
|
BlockManager.find
|
train
|
public function find($id, $draft = false)
{
if ($draft) {
$this->setDraftVersionFilter(! $draft);
}
$block = $this->getRepository()->find($id);
if ($draft) {
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.