Skip to content
Browse files

Map the Pyro\Streams\Model namespace to the sire ref

  • Loading branch information...
1 parent 766c27b commit 5ede82149b8136c481fcae2e45aa762e207c018c @obrignoni obrignoni committed
View
2 .gitignore
@@ -58,4 +58,4 @@ addons/shared_addons/plugins/*
addons/shared_addons/field_types/*
!addons/shared_addons/field_types/index.html
system/cms/config/config.php
-system/cms/modules/streams_core/src/Pyro/Module/Streams_core/Data/*
+system/cms/modules/streams_core/models/*
View
2 .htaccess
@@ -39,7 +39,7 @@
#RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
# Keep people out of codeigniter directory and Git/Mercurial data
- RedirectMatch 403 ^/.*/(composer\.json|composer\.lock|system/cms/cache|system/codeigniter|system/vendor|system/cms/config|system/cms/logs|system/cms/modules/streams_core/src/Pyro/Module/Streams_core/Data|\.git|\.hg).*$
+ RedirectMatch 403 ^/.*/(composer\.json|composer\.lock|system/cms/cache|system/codeigniter|system/vendor|system/cms/config|system/cms/logs|system/cms/modules/streams_core/models|\.git|\.hg).*$
# Send request via index.php (again, not if its a real file or folder)
RewriteCond %{REQUEST_FILENAME} !-f
View
2 installer/controllers/installer.php
@@ -40,7 +40,7 @@ class Installer extends CI_Controller
'addons',
'assets/cache',
'uploads',
- 'system/cms/modules/streams_core/src/Pyro/Module/Streams_core/Data',
+ 'system/cms/modules/streams_core/models',
);
/** @var array Files that need to be writable */
View
5 system/cms/core/MY_Controller.php
@@ -75,6 +75,11 @@ public function __construct()
$loader->add('Pyro\\Module\\Addons', realpath(APPPATH).'/modules/addons/src/');
$loader->add('Pyro\\Module\\Streams_core', realpath(APPPATH).'/modules/streams_core/src/');
$loader->add('Pyro\\Module\\Users', realpath(APPPATH).'/modules/users/src/');
+
+ // Map the streams model namespace to the site ref
+ $siteRef = str_replace(' ', '', ucwords(str_replace(array('-', '_'), ' ', SITE_REF)));
+
+ $loader->add('Pyro\\Streams\\Model', realpath(APPPATH).'/modules/streams_core/models/'.$siteRef.'Site/');
// activate the autoloader
$loader->register();
View
47 system/cms/modules/streams_core/src/Pyro/Module/Streams_core/EntryModelGenerator.php
@@ -18,28 +18,39 @@ class EntryModelGenerator extends Generator
*/
protected function getTemplate($className, $data = array())
{
- $basePath = dirname(__FILE__);
-
- $this->template = file_get_contents($basePath.'/templates/'.$this->templateFilename);
+ $this->template = file_get_contents($this->getBasePath(
+ 'src'.DIRECTORY_SEPARATOR.
+ 'Pyro'.DIRECTORY_SEPARATOR.
+ 'Module'.DIRECTORY_SEPARATOR.
+ 'Streams_core'.DIRECTORY_SEPARATOR.
+ 'templates'.DIRECTORY_SEPARATOR.$this->templateFilename
+ ));
$data['className'] = $className;
return '<?php '.$this->parser->parse($this->template, $data, null);
}
+ protected function getBasePath($path = null)
+ {
+ if ($path) {
+ $path = DIRECTORY_SEPARATOR.$path;
+ }
+
+ return APPPATH.'modules'.DIRECTORY_SEPARATOR.'streams_core'.$path;
+ }
+
/**
* Data path
* @return string
*/
public function dataPath($path = null)
{
- $basePath = dirname(__FILE__);
-
if ($path) {
$path = DIRECTORY_SEPARATOR.$path;
}
- return $basePath.DIRECTORY_SEPARATOR.'Data'.$path;
+ return $this->getBasePath('models'.$path);
}
/**
@@ -48,7 +59,7 @@ public function dataPath($path = null)
*/
public function siteRefPath($path = null)
{
- $basePath = dirname(__FILE__);
+ $basePath = $this->getBasePath();
if ($path) {
$path = DIRECTORY_SEPARATOR.$path;
@@ -59,11 +70,31 @@ public function siteRefPath($path = null)
public function getPath($path)
{
+
+
if (! is_dir($this->siteRefPath())) {
mkdir($this->siteRefPath(), 0777);
}
- return $this->siteRefPath($path);
+ $pyro = 'Pyro';
+
+ if (! is_dir($this->siteRefPath($pyro))) {
+ mkdir($this->siteRefPath($pyro), 0777);
+ }
+
+ $streams = $pyro.DIRECTORY_SEPARATOR.'Streams';
+
+ if (! is_dir($this->siteRefPath($streams))) {
+ mkdir($this->siteRefPath($streams), 0777);
+ }
+
+ $data = $streams.DIRECTORY_SEPARATOR.'Model'.DIRECTORY_SEPARATOR;
+
+ if (! is_dir($this->siteRefPath($data))) {
+ mkdir($this->siteRefPath($data), 0777);
+ }
+
+ return $this->siteRefPath($data.$path);
}
public function compile(StreamModel $stream)
View
2 system/cms/modules/streams_core/src/Pyro/Module/Streams_core/EntryUi.php
@@ -58,7 +58,7 @@ public static function table($stream_slug, $stream_namespace = null)
$model = new $class;
}
- if ( ! ($model instanceof EntryDataModel) and ! ($model instanceof EntryModel)) {
+ if (! ($model instanceof EntryModel)) {
throw new ClassNotInstanceOfEntryException;
}
View
2 system/cms/modules/streams_core/src/Pyro/Module/Streams_core/StreamModel.php
@@ -62,7 +62,7 @@ public static function getEntryModelClass($stream_slug, $stream_namespace)
*/
public static function getEntryModelNamespace()
{
- return 'Pyro\\Module\\Streams_core\\Data\\'.Str::studly(SITE_REF).'Site';
+ return 'Pyro\\Streams\\Model';
}
/**
View
2 system/cms/modules/streams_core/src/Pyro/Module/Streams_core/templates/EntryModel.txt
@@ -1,4 +1,4 @@
-namespace {{ namespace }};
+namespace Pyro\Streams\Model;
use Pyro\Module\Streams_core\EntryModel;

0 comments on commit 5ede821

Please sign in to comment.
Something went wrong with that request. Please try again.