/** * Load & return the content for this page. * * This is not the preferred way of doing this, it is better to use the * `ContentLoader` directly within the controller. However, sometimes this * method makes view building for listings far less complex. * * @todo Figure out a way to not statically call the service container to * adhere to our coding standards. * * @return Content */ public function getContent() { if (!$this->_content) { $this->_content = Container::get('cms.page.content_loader')->load($this); } return $this->_content; }
public function testStaticGetAccessor() { $container = Container::instance(); $container['test'] = function () { return 'hello'; }; $this->assertEquals($container['test'], Container::get('test')); $this->assertEquals('hello', Container::get('test')); }
/** * @todo investigate whether or not it's possible to inject the heading columns rather than call * it statically */ public function __construct() { $this->_heading = array_values(Container::get('product.upload.csv_heading')->getSimpleColumns()); }
/** * Get the user loader from the service container. This is a pretty dirty * fix to let us access the user's properties instead of just an id number * in the $this->_createdBy property. * * @see https://github.com/messagedigital/cog/issues/179 * * @return unknown The user loader */ protected function _getUserLoader() { if (null === self::$_userLoader) { // Get the user loader statically from the service container. Sorry about this :( self::$_userLoader = Container::get('user.loader'); } return self::$_userLoader; }
/** * Get the unit associated with this order. * * The unit is loaded with the revision ID stored on this item, so the * options should match. * * The unit is only loaded once per Item instance, unless `$reload` is * passed as true. * * @todo Make this not access the service container statically! * * @param boolean $reload True to force a reload of the Unit instance * * @return \Message\Mothership\Commerce\Product\Unit\Unit */ public function getUnit($reload = false) { if (!$this->_unit || $reload) { $this->_unit = Container::get('product.unit.loader')->includeInvisible(true)->includeOutOfStock(true)->getByID($this->unitID, $this->unitRevision); } return $this->_unit; }
/** * Get a new instance of a field. * * @param string $type The field type to get * @param string $name The name to use for the field * @param string|null $label The optional label for the field * * @return Group * * @throws \InvalidArgumentException If the field type does not exist */ public function getField($type, $name, $label = null) { $label = $label ?: ucfirst($name); $field = clone Container::get('field.collection')->get($type); $field->setName($name)->setLabel($label); $field->setTranslationKey($this->_baseTransKey); return $field; }
/** * Short form function for dumping all queries that are run up to the point it is called, and then * quitting execution * * @return \Message\Cog\Debug\Dumper The variable dumper */ function deQueries() { return de(\Message\Cog\Service\Container::get('db.connection')->getQueryList()); }