Skip to content

Commit

Permalink
Merge pull request #2 from pafnuty/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
pafnuty committed May 30, 2015
2 parents 261cdb5 + e499ace commit 3181095
Show file tree
Hide file tree
Showing 11 changed files with 752 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/.gitkeep

This file was deleted.

64 changes: 64 additions & 0 deletions src/Fenom/Console/CacheClearCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
namespace Panfuty\Fenom\Console;

use Fenom;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;

/**
* Class CacheClearCommand
*
* @author Pavel Belousov [email protected]
* @author Max Kostjukevich [email protected]
* @license http://opensource.org/licenses/MIT MIT
*/
class CacheClearCommand extends Command
{

/** @var Fenom */
protected $fenom;

/**
* @param Fenom $fenom
*/
public function __construct(Fenom $fenom)
{
parent::__construct();
$this->fenom = $fenom;
}

/**
* The console command name.
* @var string
*/
protected $name = 'panfuty:fenom-clear-cache';

/**
* The console command description.
* @var string
*/
protected $description = 'Flush the fenom cache';

/**
* Execute the console command.
* @return void
*/
public function fire()
{
$this->info('specified file was cache cleared!');
return;
}

/**
* Get the console command options.
* @return array
*/
protected function getOptions()
{
return [
['file', 'f', InputOption::VALUE_OPTIONAL, 'specify file'],
['time', 't', InputOption::VALUE_OPTIONAL, 'clear all of the files that are specified duration time'],
['cache_id', 'cache', InputOption::VALUE_OPTIONAL, 'specified cache_id groups'],
];
}
}
59 changes: 59 additions & 0 deletions src/Fenom/Console/CompiledClearCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace Panfuty\Fenom\Console;

use Fenom;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;

/**
* Class CompiledClearCommand
*
* @author Pavel Belousov [email protected]
* @author Max Kostjukevich [email protected]
* @license http://opensource.org/licenses/MIT MIT
*/
class CompiledClearCommand extends Command
{
/** @var Fenom */
protected $fenom;
/**
* @param Fenom $fenom
*/
public function __construct(Fenom $fenom)
{
parent::__construct();
$this->fenom = $fenom;
}
/**
* The console command name.
* @var string
*/
protected $name = 'panfuty:fenom-clear-compiled';
/**
* The console command description.
* @var string
*/
protected $description = 'Remove the compiled fenom file';
/**
* Execute the console command.
* @return void
*/
public function fire()
{
$this->info('done.');

return;
}
/**
* Get the console command options.
* @return array
*/
protected function getOptions()
{
return [
['file', 'f', InputOption::VALUE_OPTIONAL, 'specify file'],
['compile_id', 'compile', InputOption::VALUE_OPTIONAL, 'specified compile_id'],
];
}
}
62 changes: 62 additions & 0 deletions src/Fenom/Console/CompiledCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
namespace Panfuty\Fenom\Console;

use Fenom;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Illuminate\Contracts\Config\Repository as ConfigContract;

/**
* Class CompiledCommand
*
* @author Pavel Belousov [email protected]
* @author Max Kostjukevich [email protected]
* @license http://opensource.org/licenses/MIT MIT
*/
class CompiledCommand extends Command
{
/** @var Fenom */
protected $fenom;

/** @var ConfigContract */
protected $config;
/**
* @param Fenom $Fenom
* @param ConfigContract $config
*/
public function __construct(Fenom $fenom, ConfigContract $config)
{
parent::__construct();
$this->femom = $femom;
$this->config = $config;
}
/**
* The console command name.
* @var string
*/
protected $name = 'panfuty:fenom-optimize';
/**
* The console command description.
* @var string
*/
protected $description = 'compiles all known templates';
/**
* Execute the console command.
* @return void
*/
public function fire()
{
return;
}
/**
* Get the console command options.
* @return array
*/
protected function getOptions()
{
return [
['extension', 'e', InputOption::VALUE_OPTIONAL, 'specified fenom file extension'],
['force', null, InputOption::VALUE_NONE, 'compiles template files found in views directory'],
];
}
}
37 changes: 37 additions & 0 deletions src/Fenom/Console/PackageInfoCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Pafnuty\Fenom\Console;

use Fenom;
use Illuminate\Console\Command;
use Pafnuty\Fenom\FenomFactory;

/**
* Class FenomInfoCommand
*
* @author Pavel Belousov [email protected]
* @author Max Kostjukevich [email protected]
* @license http://opensource.org/licenses/MIT MIT
*/
class PackageInfoCommand extends Command
{
/**
* The console command name.
* @var string
*/
protected $name = 'panfuty:fenom-package-info';
/**
* The console command description.
* @var string
*/
protected $description = 'information about panfuty/laravel-fenom';
/**
* Execute the console command.
* @return void
*/
public function fire()
{
$this->line('<info>Fenom</info> version <comment>' . Fenom::VERSION . '</comment>');
$this->line('<info>panfuty/laravel-fenom</info> version <comment>' . FenomFactory::VERSION . '</comment>');
}
}
161 changes: 161 additions & 0 deletions src/Fenom/FenomFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<?php

namespace Pafnuty\Fenom;

use Illuminate\Contracts\View\Factory as FactoryContract;
use Illuminate\Foundation\Application;

/**
* Class FenomFactory
*
* @author Pavel Belousov [email protected]
* @author Max Kostjukevich [email protected]
* @license http://opensource.org/licenses/MIT MIT
*/
class FenomFactory implements FactoryContract
{

/**
* @var string version
*/
const VERSION = '0.1.0-dev';

/**
* Fenom environment
*
* @var Fenom_Environment
* */
private $fenom;

/**
* @param \Illuminate\Foundation\Application $app
*/
public function __construct(Application $app)
{
$this->fenom = $app['fenom'];
$this->config = $app['config'];
}

/**
* @return string
*/
public function getVersion()
{
return self::VERSION;
}

/**
* @param string $path
*
* @return bool
*/
public function exists($path)
{
if (!file_exists($path)) {
return false;
}

return true;
}

/**
* Get the evaluated view contents for the given path.
*
* @param string $path
* @param array $data
* @param array $mergeData
* @return \Illuminate\Contracts\View\View
*/
public function file($path, $data = [], $mergeData = [])
{
// or maybe use the String loader
if (!file_exists($path)) {
return false;
}

$filePath = dirname($path);
$fileName = basename($path);

return new FenomView($this, $fileName, $data);
}

/**
* @param string $view
* @param array $data
* @param array $mergeData
*
* @return \Pafnuty\Fenom\FenomView
*/
public function make($view, $data = [], $mergeData = [])
{
$data = array_merge($mergeData, $data);

return new FenomView($this, $view, $data);
}

/**
* @param string $key
* @param null $value
*/
public function share($key, $value = null)
{
$this->fenom->addAccessor($key, $value);
}

/**
* @param $view
* @param $data
*
* @return mixed
*/
public function render($view, $data)
{
$syntax = $this->config->get('view-fenom.controller_syntax');
if ($syntax == 'blade') {
$view = str_replace('.','/',$view).'.'.$this->config->get('view-fenom.extension');
}

return $this->fenom->fetch($view, $data);
}

/**
* Register a view composer event.
*
* @param array|string $views
* @param \Closure|string $callback
* @param int|null $priority
*
* @return array
*/
public function composer($views, $callback, $priority = null)
{

}

/**
* Register a view creator event.
*
* @param array|string $views
* @param \Closure|string $callback
*
* @return array
*/
public function creator($views, $callback)
{

}

/**
* Add a new namespace to the loader.
*
* @param string $namespace
* @param string|array $hints
*
* @return void
*/
public function addNamespace($namespace, $hints)
{

}

}
Loading

0 comments on commit 3181095

Please sign in to comment.