Apple_Exporter\Exporter::initialize_builders PHP Метод

initialize_builders() публичный Метод

An ordered hash of builders. They will be executed in order when building the JSON array.
С версии: 0.4.0
public initialize_builders ( array $builders = null )
$builders array
    public function initialize_builders($builders = null)
    {
        if ($builders) {
            $this->builders = $builders;
        } else {
            $this->register_builder('layout', new Builders\Layout($this->content, $this->settings));
            $this->register_builder('components', new Builders\Components($this->content, $this->settings));
            $this->register_builder('componentTextStyles', new Builders\Component_Text_Styles($this->content, $this->settings));
            $this->register_builder('componentLayouts', new Builders\Component_Layouts($this->content, $this->settings));
            $this->register_builder('metadata', new Builders\Metadata($this->content, $this->settings));
            $this->register_builder('advertisingSettings', new Builders\Advertising_Settings($this->content, $this->settings));
        }
        Component_Factory::initialize($this->workspace, $this->settings, $this->get_builder('componentTextStyles'), $this->get_builder('componentLayouts'));
    }

Usage Example

 public function testBuildersGetCalled()
 {
     $workspace = $this->prophet->prophesize('\\Apple_Exporter\\Workspace');
     // Cleans up workspace
     $workspace->clean_up()->shouldBeCalled();
     // Writes JSON
     $workspace->write_json(Argument::that(array($this, 'isValidJSON')))->shouldBeCalled();
     // Get JSON
     $workspace->get_json()->shouldBeCalled();
     $builder1 = $this->prophet->prophesize('\\Apple_Exporter\\Builders\\Builder');
     $builder1->to_array()->shouldBeCalled();
     $builder2 = $this->prophet->prophesize('\\Apple_Exporter\\Builders\\Builder');
     $builder2->to_array()->shouldBeCalled();
     $content = new Apple_Exporter\Exporter_Content(3, 'Title', '<p>Example content</p>');
     $exporter = new Exporter($content, $workspace->reveal());
     $exporter->initialize_builders(array('componentTextStyles' => $builder1->reveal(), 'componentLayouts' => $builder2->reveal()));
     $exporter->export();
 }