コード例 #1
0
ファイル: AllTest.php プロジェクト: crodas/dispatcher
 public function testCompile()
 {
     define('file', __DIR__ . '/generated/' . __CLASS__ . '.php');
     $gen = new Generator();
     $this->assertFalse(file_Exists(file));
     $gen->addDirectory(__DIR__ . '/input');
     $gen->setOutput(file);
     $gen->generate();
     $this->assertTrue(file_Exists(file));
     // add mockup cache class
     require __DIR__ . "/input/cache_class.php";
 }
コード例 #2
0
ファイル: AllTest.php プロジェクト: agpmedia/dispatcher
 public function testCompile()
 {
     $gen = new Generator();
     $file = __DIR__ . '/generated/' . __CLASS__ . '.php';
     $this->assertFalse(file_Exists($file));
     $gen->addDirectory(__DIR__ . '/input');
     $gen->setNamespace(__CLASS__);
     $gen->setOutput($file);
     $gen->generate();
     $this->assertTrue(file_Exists($file));
     require $file;
     // add mockup cache class
     require __DIR__ . "/input/cache_class.php";
 }
コード例 #3
0
ファイル: cli.php プロジェクト: agpmedia/dispatcher
  | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES      |
  | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    |
  | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND     |
  | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT      |
  | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS   |
  | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE                     |
  +---------------------------------------------------------------------------------+
  | Authors: César Rodas <*****@*****.**>                                           |
  +---------------------------------------------------------------------------------+
*/
require "packages/autoload.php";
use Dispatcher\Generator;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
$console = new Application();
$console->register('generate')->setDescription('Generate bootstrap files for your project')->setDefinition(array(new InputArgument('dir', InputArgument::REQUIRED, 'Directory name'), new InputArgument('output', InputArgument::REQUIRED, 'Output file'), new InputArgument('namespace', InputArgument::OPTIONAL, 'Put the generated file in a given namespace')))->setCode(function (InputInterface $input, OutputInterface $output) {
    $dir = $input->getArgument('dir');
    if (!is_dir($dir)) {
        $dir = getcwd() . '/' . $dir;
    }
    $dispatcher = new Generator();
    $dispatcher->addDirectory($dir)->setOutput($input->getArgument('output'));
    if ($ns = $input->getArgument('namespace')) {
        $dispatcher->setNamespace($ns);
    }
    $dispatcher->generate();
});
$console->run();