factory() публичный статический Метод

Create a new container of type $type and name $name and label $label.
public static factory ( string $type, string $name ) : object
$type string
$name string Human-readable name of the container
Результат object $container
Пример #1
0
 /**
  * Outputs the settings update form.
  *
  * @param array $instance Current settings.
  */
 public function form($instance)
 {
     $this->store_data = $instance;
     $custom_fields = array();
     foreach ($this->custom_fields as $field) {
         $tmp_field = clone $field;
         $tmp_field->load();
         $field_name = $this->get_field_name($tmp_field->get_name());
         $tmp_field->set_name($field_name);
         $custom_fields[] = $tmp_field;
     }
     Container::factory('widget', $this->id)->add_fields($custom_fields)->init();
 }
 /**
  * Render attribute prevents field containers showing on menu save
  */
 public static function set_instance_for_id($current_menu_item_id, $render = true)
 {
     $active_containers = self::get_containers();
     $suffix = '-' . $current_menu_item_id;
     foreach ($active_containers as $container) {
         if ($container->type != 'Nav_Menu') {
             continue;
         }
         $custom_fields = array();
         $fields = $container->get_fields();
         foreach ($fields as $field) {
             $tmp_field = clone $field;
             // Setup Public properties
             $tmp_field->current_menu_item_id = $current_menu_item_id;
             $tmp_field->initial_name = $tmp_field->get_name();
             // Setup Field ID and Name
             $tmp_field->set_id($tmp_field->get_id() . $suffix);
             $tmp_field->set_name($tmp_field->get_name() . $suffix);
             // Update Datastore instance
             $new_datastore = new Nav_Menu_Datastore();
             $new_datastore->set_id($current_menu_item_id);
             $tmp_field->set_datastore($new_datastore);
             $custom_fields[] = $tmp_field;
         }
         self::$instances[$current_menu_item_id] = Container::factory('nav_menu', $container->id . $suffix)->add_fields($custom_fields)->init($current_menu_item_id, $render);
     }
     return self::$instances[$current_menu_item_id];
 }
Пример #3
0
 /**
  * A proxy for the abstract container factory method.
  *
  * @see Carbon_Fields\Container\Container::factory()
  **/
 public static function factory($type, $name)
 {
     return Abstract_Container::factory($type, $name);
 }