Exemple #1
0
 /**
  * Get the instance of Core
  *
  * @since 1.1.1
  *
  * @return I_Core
  */
 protected function getCore()
 {
     if (is_null($this->core)) {
         $this->core = Core::getCore();
     }
     return $this->core;
 }
Exemple #2
0
 /**
  * Initialize the Properties
  *
  * Sadly we must be coupled to Core directly as Widgets are instantiated in the
  * registration process within the Widget Factory itself.  We could use the global
  * to gain access directly to the "public" widget registry within the factory;
  * however,then we are coupled to that implementation, meaning if down the road the
  * process changes within WordPress Core, our widgets will break.
  *
  * A compromise then is to fetch core and then instantiate the config stored
  * in Core's IoC Container here within this method.
  *
  * @since 1.1.1
  *
  * @return null
  * @throws RuntimeException
  */
 protected function init_properties()
 {
     $this->core = Core::getCore();
     $widget_container_key = get_class($this);
     if (!$this->core->has($widget_container_key)) {
         throw new RuntimeException(sprintf('%s %s', __('The specified widget config file is not available in the container.', 'wpdc'), $widget_container_key));
     }
     $this->config = $this->core[$widget_container_key];
 }
Exemple #3
0
 /**
  * Instantiate this Template
  *
  * @since 1.0.0
  *
  * @param I_Config $config Runtime configuration parameters
  * @param I_Core $core Instance of Core
  * @return self
  */
 public function __construct(I_Config $config, I_Core $core = null)
 {
     $this->config = $config;
     $this->core = is_null($core) ? Core::getCore() : $core;
     $this->init_properties();
     $this->init_parameters();
     $this->load_service_providers();
     $this->init_events();
     $this->init();
 }
Exemple #4
0
 /**
  * Instantiate the plugin
  *
  * @since 1.0.0
  *
  * @param I_Config $config Runtime configuration parameters
  * @param I_Core $core Instance of Core
  *
  * @return self
  */
 public function __construct(I_Config $config, I_Core $core = null)
 {
     $this->config = $config;
     $this->core = is_null($core) ? Core::getCore() : $core;
     $this->init_parameters();
     $this->init_service_providers();
     $this->init_events();
     $this->init_addon();
     $this->register_assets();
     $this->register_formatters();
 }
Exemple #5
0
 *
 * @package     WPDevsClub_Core
 * @since       1.0.0
 * @author      WPDevelopersClub and hellofromTonya
 * @link        https://wpdevelopersclub.com/
 * @license     GNU General Public License 2.0+
 */
use WPDevsClub_Core\Config\Arr_Config;
use WPDevsClub_Core\Models\Model;
use WPDevsClub_Core\Structures\Grid;
use WPDevsClub_Core\Structures\Post\Post_Title;
use WPDevsClub_Core\Structures\Post\Post;
use WPDevsClub_Core\Structures\Post\Post_Info;
use WPDevsClub_Core\Structures\Post\Post_Meta;
global $post;
$core = Core::getCore();
return array('initial_parameters' => array('post_id' => $post->ID, 'grid_post_id' => 0, 'site_layout' => '__genesis_return_full_width_content', 'grid_component_prefix' => 'grid.', 'body_classes' => array('wpdevsclub-grid'), 'config' => array('grid' => array('grid_components' => array('post_title', 'post_info', 'post', 'post_meta')))), 'fe_service_providers' => array('model' => array('autoload' => false, 'concrete' => function ($container) {
    return new Model(new Arr_Config($container['config']->model), $container['post_id']);
}), 'grid' => array('autoload' => true, 'concrete' => function ($container) {
    return new Grid(new Arr_Config($container['config']->grid, $container['core_config_defaults_dir'] . 'structures/grid.php'), $container['core'], $container['config']->grid_query_args, $container['config']->terms);
}), 'grid.model' => array('autoload' => false, 'concrete' => $core->factory(function ($container) {
    return new Model(new Arr_Config($container['config']->grid['model']), $container['grid_post_id']);
})), 'grid.post_title' => array('autoload' => false, 'concrete' => $core->factory(function ($container) {
    return new Post_Title(new Arr_Config($container['config']->grid['post_title'], $container['core_config_defaults_dir'] . 'structures/post-title.php'), $container['grid.model'], $container['grid_post_id']);
})), 'grid.post_info' => array('autoload' => false, 'concrete' => $core->factory(function ($container) {
    if (!$container['config']->has('grid.post_info')) {
        return;
    }
    return new Post_Info(new Arr_Config($container['config']->grid['post_info'], $container['core_config_defaults_dir'] . 'structures/post-info.php'), $container['grid.model'], $container['grid_post_id'], get_post_field('post_author', $container['grid_post_id']));
})), 'grid.post' => array('autoload' => false, 'concrete' => $core->factory(function ($container) {
    return new Post(new Arr_Config($container['config']->grid['post'], $container['core_config_defaults_dir'] . 'structures/post.php'), $container['grid.model'], $container['grid_post_id'], $container['core']);