public function approve($sourceDir, array $options, $username)
    {
        $this->init($sourceDir, $options, $username);

        $sourceFilename = sprintf('%s/blocks/%s.json', $this->contributorDir, $options['blockname']);
        $targetFilename = sprintf('%s/blocks/%s.json', $this->productionDir, $options['blockname']);

        Dispatcher::dispatch(
            BlockEvents::BLOCK_APPROVING,
            new BlockApprovingEvent($this->serializer, $sourceFilename, $targetFilename)
        );

        $blockValues = JsonTools::jsonDecode(FilesystemTools::readFile($sourceFilename));
        $blockValues["history"] = array();
        FilesystemTools::writeFile($targetFilename, json_encode($blockValues));

        $slotDefinitionContribution = $this->getSlotDefinition($this->getContributorDir());
        $this->saveSlotDefinition($this->productionDir, $slotDefinitionContribution);

        Dispatcher::dispatch(
            BlockEvents::BLOCK_APPROVED,
            new BlockApprovedEvent($this->serializer, $sourceFilename, $targetFilename)
        );

        DataLogger::log(
            sprintf(
                'Block "%s" has been approved on the "%s" slot on page "%s" for the "%s_%s" language',
                $options["blockname"],
                $options["slot"],
                $options["page"],
                $options["language"],
                $options["country"]
            )
        );

        return $blockValues;
    }
public function approve($sourceDir, array $options, $username)
    {
        $this->init($sourceDir, $options, $username);

        $sourceFilename = sprintf('%s/blocks/%s.json', $this->contributorDir, $options['blockname']);
        $targetFilename = sprintf('%s/blocks/%s.json', $this->productionDir, $options['blockname']);

        Dispatcher::dispatch(
            BlockEvents::BLOCK_APPROVING,
            new BlockApprovingEvent($this->serializer, $sourceFilename, $targetFilename)
        );

        $blockValues = JsonTools::jsonDecode(FilesystemTools::readFile($sourceFilename));
        $blockValues["history"] = array();
        FilesystemTools::writeFile($targetFilename, json_encode($blockValues));

        $slotDefinitionContribution = $this->getSlotDefinition($this->getContributorDir());
        $this->saveSlotDefinition($this->productionDir, $slotDefinitionContribution);

        Dispatcher::dispatch(
            BlockEvents::BLOCK_APPROVED,
            new BlockApprovedEvent($this->serializer, $sourceFilename, $targetFilename)
        );

        DataLogger::log(
            sprintf(
                'Block "%s" has been approved on the "%s" slot on page "%s" for the "%s_%s" language',
                $options["blockname"],
                $options["slot"],
                $options["page"],
                $options["language"],
                $options["country"]
            )
        );

        return $blockValues;
    }
public function approve ( $ sourceDir , array $ options , $ username ) { $ this -> init ( $ sourceDir , $ options , $ username ) ; $ sourceFilename = sprintf ( '%s/blocks/%s.json' , $ this -> contributorDir , $ options [ 'blockname' ] ) ; $ targetFilename = sprintf ( '%s/blocks/%s.json' , $ this -> productionDir , $ options [ 'blockname' ] ) ; Dispatcher :: dispatch ( BlockEvents :: BLOCK_APPROVING , new BlockApprovingEvent ( $ this -> serializer , $ sourceFilename , $ targetFilename ) ) ; $ blockValues = JsonTools :: jsonDecode ( FilesystemTools :: readFile ( $ sourceFilename ) ) ; $ blockValues [ "history" ] = array ( ) ; FilesystemTools :: writeFile ( $ targetFilename , json_encode ( $ blockValues ) ) ; $ slotDefinitionContribution = $ this -> getSlotDefinition ( $ this -> getContributorDir ( ) ) ; $ this -> saveSlotDefinition ( $ this -> productionDir , $ slotDefinitionContribution ) ; Dispatcher :: dispatch ( BlockEvents :: BLOCK_APPROVED , new BlockApprovedEvent ( $ this -> serializer , $ sourceFilename , $ targetFilename ) ) ; DataLogger :: log ( sprintf ( 'Block "%s" has been approved on the "%s" slot on page "%s" for the "%s_%s" language' , $ options [ "blockname" ] , $ options [ "slot" ] , $ options [ "page" ] , $ options [ "language" ] , $ options [ "country" ] ) ) ; return $ blockValues ; }
Approves a contribution

@param string $sourceDir
@param array $options
@param string $username

@return array The approved block
Approves a contribution