public function __construct(Application $app, $config, Block $b, Page $c, Area $a) { parent::__construct(); $p = new \Permissions($b); $this->permissions = $p; $this->block = $b; $this->page = $c; $this->area = $a; $this->setAttribute('data-block-menu', 'block-menu-b' . $b->getBlockID()); $this->setAttribute('class', 'ccm-edit-mode-block-menu'); $btw = $b->getBlockTypeObject(); $btOriginal = $btw; $bID = $b->getBlockID(); $aID = $a->getAreaID(); $heightPlus = 20; $btHandle = $btw->getBlockTypeHandle(); $editInline = false; if ($btw->supportsInlineEdit()) { $editInline = true; } if ($btw->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) { $_bi = $b->getInstance(); $_bo = Block::getByID($_bi->getOriginalBlockID()); $btOriginal = BlockType::getByHandle($_bo->getBlockTypeHandle()); $btHandle = $btOriginal->getBlockTypeHandle(); $heightPlus = 80; if ($btOriginal->supportsInlineEdit()) { $editInline = true; } } $canDesign = $p->canEditBlockDesign() && $config->get('concrete.design.enable_custom') == true; $canModifyGroups = $p->canEditBlockPermissions() && $config->get('concrete.permissions.model') != 'simple' && !$a->isGlobalArea(); $canEditName = $p->canEditBlockName(); $canEditCacheSettings = $p->canEditBlockCacheSettings(); $canEditCustomTemplate = $p->canEditBlockCustomTemplate(); $canScheduleGuestAccess = $config->get('concrete.permissions.model') != 'simple' && $p->canGuestsViewThisBlock() && $p->canScheduleGuestAccess() && !$a->isGlobalArea(); $canAliasBlockOut = $c->isMasterCollection() && !$a->isGlobalArea(); if ($canAliasBlockOut) { $ct = Type::getByID($c->getPageTypeID()); } $isAlias = $b->isAlias(); $u = new \User(); $numChildren = !$isAlias ? $b->getNumChildren() : 0; if ($isAlias) { $deleteMessage = t('Do you want to delete this block?'); } elseif ($numChildren) { $deleteMessage = t('Do you want to delete this block? This item is an original. If you delete it, you will delete all blocks aliased to it'); } else { $deleteMessage = t('Do you want to delete this block?'); } if ($btOriginal->getBlockTypeHandle() == BLOCK_HANDLE_STACK_PROXY) { if (is_object($_bo)) { $bi = $_bo->getInstance(); } else { $bi = $b->getInstance(); } $stack = \Stack::getByID($bi->stID); if (is_object($stack)) { $sp = new \Permissions($stack); if ($sp->canWrite()) { $this->addItem(new LinkItem(\URL::to('/dashboard/blocks/stacks', 'view_details', $stack->getCollectionID()), t('Manage Stack Contents'))); } } } else { if ($p->canEditBlock() && $b->isEditable()) { if ($editInline) { if ($b->getBlockTypeHandle() == BLOCK_HANDLE_LAYOUT_PROXY) { $this->addItem(new LinkItem('javascript:void(0)', t('Edit Layout'), ['data-menu-action' => 'edit_inline', 'data-area-enable-grid-container' => $a->isGridContainerEnabled(), 'data-area-grid-maximum-columns' => $a->getAreaGridMaximumColumns()])); } else { $this->addItem(new LinkItem('javascript:void(0)', t('Edit Block'), ['data-menu-action' => 'edit_inline', 'data-area-enable-grid-container' => $a->isGridContainerEnabled(), 'data-area-grid-maximum-columns' => $a->getAreaGridMaximumColumns()])); } } else { $this->addItem(new LinkItem('javascript:void(0)', t('Edit Block'), ['data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/edit'), 'dialog-title' => t('Edit %s', t($btOriginal->getBlockTypeName())), 'dialog-width' => $btOriginal->getBlockTypeInterfaceWidth(), 'dialog-height' => $btOriginal->getBlockTypeInterfaceHeight() + $heightPlus])); } } } if ($b->getBlockTypeHandle() != BLOCK_HANDLE_LAYOUT_PROXY && $b->getBlockTypeHandle() != BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY) { $this->addItem(new LinkItem('javascript:void(0)', t('Copy to Clipboard'), ['data-menu-action' => 'block_scrapbook', 'data-token' => $app->make('token')->generate('tools/clipboard/to')])); } if ($p->canDeleteBlock()) { $this->addItem(new LinkItem('javascript:void(0)', t('Delete'), ['data-menu-action' => 'delete_block', 'data-menu-delete-message' => $deleteMessage])); } if ($b->getBlockTypeHandle() != BLOCK_HANDLE_LAYOUT_PROXY) { if ($canDesign || $canEditCustomTemplate || $canEditName || $canEditCacheSettings) { $this->addItem(new DividerItem()); if ($canDesign || $canEditCustomTemplate) { $this->addItem(new LinkItem('#', t('Design & Custom Template'), ['data-menu-action' => 'block_design'])); } if ($b->getBlockTypeHandle() != BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY && ($canEditName || $canEditCacheSettings)) { $this->addItem(new LinkItem('#', t('Advanced'), ['dialog-title' => t('Advanced Block Settings'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/cache'), 'dialog-width' => 500, 'dialog-height' => 320])); } } } if ($b->getBlockTypeHandle() != BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY && ($canModifyGroups || $canScheduleGuestAccess || $canAliasBlockOut)) { $this->addItem(new DividerItem()); if ($canModifyGroups) { $this->addItem(new LinkItem('#', t('Permissions'), ['dialog-title' => t('Block Permissions'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/permissions/list'), 'dialog-width' => 350, 'dialog-height' => 450])); } if ($canScheduleGuestAccess) { $this->addItem(new LinkItem('#', t('Schedule Guest Access'), ['dialog-title' => t('Schedule Guest Access'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/permissions/guest_access'), 'dialog-width' => 500, 'dialog-height' => 320])); } if ($canAliasBlockOut) { $this->addItem(new LinkItem('#', t('Setup on Child Pages'), ['dialog-title' => t('Setup on Child Pages'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/aliasing'), 'dialog-width' => 500, 'dialog-height' => 'auto'])); } } }
/** * From bootstrap/start.php, pass in an instance of $app to this method to * override C5's default method of persisting config settings to flat file * storage. * * @param \Concrete\Core\Application\Application $app */ public static function bindToApp(\Concrete\Core\Application\Application $app) { $fileSystem = new FileSystem(); $configLoader = new FileLoader($fileSystem); $configSaver = new self(); $app->instance('config', new ConfigRepository($configLoader, $configSaver, $app->environment())); }
/** * Returns a callable for the given controller. * * @param string $controller A Controller string * * @return mixed A PHP callable * * @throws \InvalidArgumentException */ protected function createController($controller) { if (false === strpos($controller, '::')) { throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller)); } list($class, $method) = explode('::', $controller, 2); if (!class_exists($class)) { throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); } return array($this->app->make($class), $method); }
public function testBindings() { $app = new Application(); $provider = new ServiceProvider($app); $provider->register(); $service = new \Concrete\Tests\Core\Authentication\Fixtures\ServiceFixture(); /** @var \OAuth\UserData\ExtractorFactory $extractor_factory */ $extractor_factory = $app['oauth/factory/extractor']; $this->assertInstanceOf('OAuth\\UserData\\ExtractorFactoryInterface', $extractor_factory); $extractor_factory->addExtractorMapping('Concrete\\Tests\\Core\\Authentication\\Fixtures\\ServiceFixture', 'Concrete\\Tests\\Core\\Authentication\\Fixtures\\ExtractorFixture'); $this->assertInstanceOf('OAuth\\UserData\\Extractor\\ExtractorInterface', $app->make('oauth_extractor', array($service))); }
/** * @param Repository $config * @param Application $app */ private function initializeLegacyURLDefinitions(Application $app) { if (!defined('BASE_URL')) { try { define('BASE_URL', rtrim((string) $app->make('url/canonical'), '/')); } catch (\Exception $x) { echo $x->getMessage(); die(1); } } }
/** * Build a service from an abstract. * * @param string|callable $abstract * @param string $version * * @return ServiceInterface|null */ private function buildService($abstract, $version = '') { $resolved = null; if (is_string($abstract)) { // If it's a string, throw it at the IoC container $resolved = $this->app->make($abstract, array($version)); } elseif (is_callable($abstract)) { // If it's a callable, lets call it with the application and $this $resolved = $abstract($version, $this->app, $this); } return $resolved; }
/** * Return the correct MappingDriver base on the application config * * @return XmlDriver|YamlDriver|AnnotationDriver */ public function getDriver() { $config = $this->config; if ($this->isLegacy()) { $appEntityPath = DIR_APPLICATION . DIRECTORY_SEPARATOR . DIRNAME_CLASSES; $reader = $this->app->make('orm/cachedSimpleAnnotationReader'); } else { $appEntityPath = DIR_APPLICATION . DIRECTORY_SEPARATOR . DIRNAME_CLASSES . DIRECTORY_SEPARATOR . DIRNAME_ENTITIES; $reader = $this->app->make('orm/cachedAnnotationReader'); } $appDriverSettings = $config->get(CONFIG_ORM_METADATA_APPLICATION); $xmlConfig = DIR_APPLICATION . DIRECTORY_SEPARATOR . REL_DIR_METADATA_XML; $ymlConfig = DIR_APPLICATION . DIRECTORY_SEPARATOR . REL_DIR_METADATA_YAML; // Default setting so it comes first if (empty($appDriverSettings) && is_dir($appEntityPath)) { return new AnnotationDriver($reader, $appEntityPath); } else { if ($appDriverSettings === 'xml') { if (is_dir($xmlConfig)) { return new XmlDriver($xmlConfig); } else { // Fallback to default return new AnnotationDriver($reader, $appEntityPath); } } else { if ($appDriverSettings === 'yaml' || $appDriverSettings === 'yml') { if (is_dir($ymlConfig)) { return new YamlDriver($ymlConfig); } else { // Fallback to default return new AnnotationDriver($reader, $appEntityPath); } } } } }
private function handleDispatch($request) { $collection = $this->router->getList(); $context = new RequestContext(); $context->fromRequest($request); $matcher = new UrlMatcher($collection, $context); $path = rtrim($request->getPathInfo(), '/') . '/'; try { $request->attributes->add($matcher->match($path)); $matched = $matcher->match($path); $route = $collection->get($matched['_route']); $this->router->setRequest($request); $response = $this->router->execute($route, $matched); } catch (ResourceNotFoundException $e) { $callback = $this->app->make(DispatcherRouteCallback::class, ['dispatcher']); $response = $callback->execute($request); } return $response; }
/** * Create a entity manager used for the package installation, * update and unistall process. * * @return \Doctrine\ORM\EntityManager */ public function getPackageEntityManager() { $providerFactory = new PackageProviderFactory($this->app, $this); $provider = $providerFactory->getEntityManagerProvider(); $drivers = $provider->getDrivers(); if (count($drivers)) { $config = Setup::createConfiguration(true, $this->app->make('config')->get('database.proxy_classes')); $driverImpl = new MappingDriverChain(); $coreDriver = new CoreDriver($this->app); // Add the core driver to it so packages can extend the core and not break. $driverImpl->addDriver($coreDriver->getDriver(), $coreDriver->getNamespace()); foreach ($drivers as $driver) { $driverImpl->addDriver($driver->getDriver(), $driver->getNamespace()); } $config->setMetadataDriverImpl($driverImpl); $em = EntityManager::create(\Database::connection(), $config); return $em; } }
/** * Resolve url's from any type of input. * * This method MUST either return a `\League\URL\URL` when a url is resolved * or null when a url cannot be resolved. * * If the first argument provided is a page object, we will use that object to determine the site tree * (and thus the canonical url) to use. * * @param array $arguments A list of the arguments * @param \League\URL\URLInterface $resolved * * @return \League\URL\URLInterface */ public function resolve(array $arguments, $resolved = null) { $config = null; $page = null; // Canonical urls for pages can be different than for the entire site if (count($arguments) && head($arguments) instanceof Page) { /** @var Page $page */ $page = head($arguments); $tree = $page->getSiteTreeObject(); if ($tree instanceof SiteTree && ($site = $tree->getSite())) { $config = $site->getConfigRepository(); } } elseif ($this->cached) { return $this->cached; } // Get the config from the current site tree if ($config === null && $this->app->isInstalled()) { $site = $this->app['site']->getSite(); if (is_object($site)) { $config = $site->getConfigRepository(); } } // Determine trailing slash setting $trailing_slashes = $config && $config->get('seo.trailing_slash') ? Url::TRAILING_SLASHES_ENABLED : Url::TRAILING_SLASHES_DISABLED; $url = UrlImmutable::createFromUrl('', $trailing_slashes); $url = $url->setHost(null); $url = $url->setScheme(null); if ($config && ($configUrl = $site->getSiteCanonicalURL())) { $canonical = UrlImmutable::createFromUrl($configUrl, $trailing_slashes); if ($configSslUrl = $config->get('seo.canonical_ssl_url')) { $canonical_ssl = UrlImmutable::createFromUrl($configSslUrl, $trailing_slashes); } $url = $url->setHost($canonical->getHost()); $url = $url->setScheme($canonical->getScheme()); // If the request is over https if (strtolower($this->request->getScheme()) == 'https') { // If the canonical ssl url is set, respect the canonical ssl url. if (isset($canonical_ssl)) { $url = $url->setHost($canonical_ssl->getHost()); $url = $url->setScheme($canonical_ssl->getScheme()); if (intval($canonical_ssl->getPort()->get()) > 0) { $url = $url->setPort($canonical_ssl->getPort()); } } else { // If the canonical url is http, lets just say https for the canonical url. if (strtolower($canonical->getScheme()) == 'http') { $url = $url->setScheme('https'); } if (intval($canonical->getPort()->get()) > 0) { $url = $url->setPort($canonical->getPort()); } } } elseif (intval($canonical->getPort()->get()) > 0) { $url = $url->setPort($canonical->getPort()); } } if ($relative_path = $this->app['app_relative_path']) { $url = $url->setPath($relative_path); } // Don't cache page specific canonical urls if (!$page) { $this->cached = $url; } return $url; }
/** * Get StandardAnnotationReader * * @return \Doctrine\Common\Annotations\CachedReader with a * \Doctrine\Common\Annotations\AnnotationReader */ protected function getStandardAnnotationReader() { return $this->app->make('orm/cachedAnnotationReader'); }
/** * @param \Symfony\Component\HttpFoundation\Session\Session $session * * @deprecated Use \Concrete\Core\Session\SessionValidator */ public static function testSessionFixation(SymfonySession $session) { $validator = self::$app->make('Concrete\\Core\\Session\\SessionValidatorInterface'); $validator->handleSessionValidation($session); }
<?php $DIR_BASE_CORE = dirname(__DIR__); define('DIR_BASE', dirname($DIR_BASE_CORE)); require $DIR_BASE_CORE . '/bootstrap/configure.php'; require $DIR_BASE_CORE . '/bootstrap/autoload.php'; if (!\Concrete\Core\Application\Application::isRunThroughCommandLineInterface()) { return false; } $cms = (require $DIR_BASE_CORE . '/bootstrap/start.php'); $app = new \Concrete\Core\Console\Application(); $cms->instance('console', $app); if ($cms->isInstalled()) { $cms->setupPackageAutoloaders(); $cms->setupPackages(); } $app->setupDefaultCommands(); \Events::dispatch('on_before_console_run'); $app->run(); \Events::dispatch('on_after_console_run');
/** * Get the AnnotationDriver * * @return AnnotationDriver */ public function getDriver() { $annotationDriver = new AnnotationDriver($this->app->make('orm/cachedAnnotationReader'), [DIR_BASE_CORE . DIRECTORY_SEPARATOR . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES]); return $annotationDriver; }
<?php use Concrete\Core\Application\Application; /* * ---------------------------------------------------------------------------- * Instantiate concrete5 * ---------------------------------------------------------------------------- */ $app = new Application(); /* * ---------------------------------------------------------------------------- * Detect the environment based on the hostname of the server * ---------------------------------------------------------------------------- */ $app->detectEnvironment(array('local' => array('hostname'), 'production' => array('live.site'))); return $app;
<?php use Concrete\Core\Application\Application; /** * ---------------------------------------------------------------------------- * Instantiate concrete5 * ---------------------------------------------------------------------------- */ $app = new Application(); /** * ---------------------------------------------------------------------------- * Detect the environment based on the hostname of the server * ---------------------------------------------------------------------------- */ $app->detectEnvironment(array('local' => array('hostname'), 'production' => array('live.site'))); /** * Override Concrete5's config persistence method. */ \Application\Src\Config\Ephemeral::bindToApp($app); return $app;
/** * Returns the settings for all defined filters in the filter * settings repository. * * @return array */ protected function getFilterSettings() { $rep = $this->app->make('Concrete\\Package\\AssetPipeline\\Src\\Asset\\Filter\\SettingsRepositoryInterface'); return $rep->getAllFilterSettings(); }
/** * {@inheritdoc} * * @see \Concrete\Core\Service\ServiceInterface::getConfigurator() */ public function getConfigurator() { return $this->app->make($this->configurator_class); }
public function entityManager() { return $this->app->make('Doctrine\\ORM\\EntityManager'); }
/** * @param \Concrete\Core\Application\Application $app */ private function initializePackages(Application $app) { $app->setupPackageAutoloaders(); }
public function __construct(Application $app) { $this->app = $app; $this->config = $app->make('config'); }