-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from pafnuty/dev
Dev
- Loading branch information
Showing
11 changed files
with
752 additions
and
1 deletion.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.