Skip to content

Commit

Permalink
Api docs for IDE
Browse files Browse the repository at this point in the history
  • Loading branch information
vnenkpet committed May 21, 2015
1 parent b4e051d commit 4d16b99
Show file tree
Hide file tree
Showing 17 changed files with 142 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea

vendor
composer.lock
Thumbs.db
4 changes: 4 additions & 0 deletions components/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

use Yii;

/**
* Base API class
* @package yii\easyii\components
*/
class API extends \yii\base\Object
{
static $classes;
Expand Down
4 changes: 4 additions & 0 deletions components/ActiveQuery.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace yii\easyii\components;

/**
* Base ActiveQuery class
* @package yii\easyii\components
*/
class ActiveQuery extends \yii\db\ActiveQuery
{
public function status($status)
Expand Down
8 changes: 8 additions & 0 deletions components/ActiveRecord.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<?php
namespace yii\easyii\components;

/**
* Base ActiveRecord class
* @package yii\easyii\components
*/
class ActiveRecord extends \yii\db\ActiveRecord
{
/**
* Slug regex pattern for validation
* @var string
*/
public static $SLUG_PATTERN = '/^[0-9a-z-]{0,128}$/';

public static function find()
Expand Down
8 changes: 8 additions & 0 deletions components/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
use yii\easyii\models;
use yii\helpers\Url;

/**
* Base controller class
* @package yii\easyii\components
*/
class Controller extends \yii\web\Controller
{
public $enableCsrfValidation = false;
Expand Down Expand Up @@ -41,6 +45,10 @@ public function flash($type, $message)
Yii::$app->getSession()->setFlash($type=='error'?'danger':$type, $message);
}

/**
* Redirect user back one step
* @return \yii\web\Response
*/
public function back()
{
return $this->redirect(Yii::$app->request->referrer);
Expand Down
10 changes: 10 additions & 0 deletions components/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
use Yii;
use yii\easyii\models\Module as ModuleModel;

/**
* Base Module class
* @package yii\easyii\components
*/
class Module extends \yii\base\Module
{
public $defaultRoute = 'a';
Expand Down Expand Up @@ -49,6 +53,12 @@ public static function registerTranslations($moduleName)
}
}

/**
* Returns a module name based on namespace
*
* @param $namespace
* @return string|bool
*/
public static function getModuleName($namespace)
{
foreach(ModuleModel::findAllActive() as $module)
Expand Down
12 changes: 11 additions & 1 deletion modules/article/api/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
use yii\easyii\modules\article\models\Category;
use yii\easyii\modules\article\models\Item;

/**
* Class Article
* @package yii\easyii\modules\article\api
*
* @method static \stdClass cat(mixed $id_slug) Get article category by id or slug
* @method static array cats(array $options = []) Get article categories
* @method static \stdClass item(mixed $id_slug) Get article item by id or slug
* @method static string pages() returns pagination html generated by yii\widgets\LinkPager widget.
* @method static \stdClass pagination() returns yii\data\Pagination object.
*/
class Article extends \yii\easyii\components\API
{
private $_cats;
Expand Down Expand Up @@ -210,7 +220,7 @@ private function notFound($id_slug)

elseif(preg_match(Category::$SLUG_PATTERN, $id_slug)){

return $this->createCatObject('<a href="' . Url::to(['/admin/article/a/create', 'slug' => $id_slug] . '" target="_blank">'.Yii::t('easyii/article/api', 'Create category').'</a>');
return $this->createCatObject('<a href="' . Url::to(['/admin/article/a/create', 'slug' => $id_slug]) . '" target="_blank">'.Yii::t('easyii/article/api', 'Create category').'</a>');
}
else{
return $this->createCatObject($this->errorText('WRONG CATEGORY IDENTIFIER'));
Expand Down
5 changes: 5 additions & 0 deletions modules/carousel/api/Carousel.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
use yii\easyii\helpers\Data;
use yii\easyii\modules\carousel\models\Carousel as CarouselModel;

/**
* Carousel API
* @package yii\easyii\modules\carousel\api
* @method static string widgets(array $options = []) Bootstrap carousel widget
*/
class Carousel extends \yii\easyii\components\API
{
public $clientOptions = ['interval' => 5000];
Expand Down
12 changes: 12 additions & 0 deletions modules/catalog/api/Catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
use yii\easyii\modules\catalog\models\Category;
use yii\easyii\modules\catalog\models\Item;

/**
* Class Catalog
* @package yii\easyii\modules\catalog\api
*
* @method static \stdClass cat(mixed $id_slug) Get catalog category by id or slug
* @method static array cats(array $options = []) Get catalog categories
* @method static \stdClass item(mixed $id_slug) Get catalog item by id or slug
* @method static string photo(int $id) Get catalog photo by ID
* @method static void plugin(array $options = []) On all your photos, called as $photo->box, will be apply Fancybox plugin.
* @method static string pages() returns pagination html generated by yii\widgets\LinkPager widget.
* @method static \stdClass pagination() returns yii\data\Pagination object.
*/
class Catalog extends \yii\easyii\components\API
{
private $_cats;
Expand Down
6 changes: 6 additions & 0 deletions modules/faq/api/Faq.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
use yii\easyii\helpers\Data;
use yii\easyii\modules\faq\models\Faq as FaqModel;

/**
* FAQ API
* @package yii\easyii\modules\faq\api
*
* @method static array all() array of all FAQ as stdClass objects
*/
class Faq extends \yii\easyii\components\API
{
public function api_all()
Expand Down
7 changes: 7 additions & 0 deletions modules/feedback/api/Feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
use yii\bootstrap\Alert;
use yii\easyii\widgets\ReCaptcha;

/**
* Feedback module API
* @package yii\easyii\modules\feedback\api
*
* @method static string form() Returns fully worked standalone html form.
* @method static array create(array $attributes) If you using your own form, this function will be useful for manual saving feedback's.
*/
class Feedback extends \yii\easyii\components\API
{
public function api_form()
Expand Down
10 changes: 10 additions & 0 deletions modules/file/api/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
use yii\easyii\modules\file\models\File as FileModel;
use yii\widgets\LinkPager;

/**
* File module API
* @package yii\easyii\modules\file\api
*
* @method static \stdClass get(mixed $id_slug) Get a file by ID or slug
* @method static array all(array $options = []) Get all files
* @method static mixed last(int $limit = 1) Get last files
* @method static string pages() returns pagination html generated by yii\widgets\LinkPager widget.
* @method static \stdClass pagination() returns yii\data\Pagination object.
*/
class File extends \yii\easyii\components\API
{
private $_files = [];
Expand Down
11 changes: 11 additions & 0 deletions modules/gallery/api/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
use yii\easyii\widgets\Fancybox;
use yii\easyii\modules\gallery\models\Album;

/**
* Gallery module API
* @package yii\easyii\modules\gallery\api
*
* @method static \stdClass album(mixed $id_slug) Get album by id or slug
* @method static array albums(array $options = []) Get albums
* @method static string photo(int $id) Get catalog photo by ID
* @method static void plugin(array $options = []) On all your photos, called as $photo->box, will be apply Fancybox plugin.
* @method static string pages() returns pagination html generated by yii\widgets\LinkPager widget.
* @method static \stdClass pagination() returns yii\data\Pagination object.
*/
class Gallery extends \yii\easyii\components\API
{
private $_albums;
Expand Down
12 changes: 11 additions & 1 deletion modules/guestbook/api/Guestbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@
use yii\easyii\modules\guestbook\models\Guestbook as GuestbookModel;
use yii\easyii\widgets\ReCaptcha;


/**
* Guestbook module API
* @package yii\easyii\modules\guestbook\api
*
* @method static string form() Returns fully worked standalone html form.
* @method static array all(array $options = []) Get all posts
* @method static array create(array $attributes) If you using your own form, this function will be useful for manual saving guestbook posts.
* @method static mixed last(int $limit = 1) Get last posts
* @method static string pages() returns pagination html generated by yii\widgets\LinkPager widget.
* @method static \stdClass pagination() returns yii\data\Pagination object.
*/
class Guestbook extends \yii\easyii\components\API
{
private $_adp;
Expand Down
10 changes: 10 additions & 0 deletions modules/news/api/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@

use yii\easyii\modules\news\models\News as NewsModel;

/**
* Class News
* @package yii\easyii\modules\news\api
*
* @method static \stdClass get(mixed $id_slug) Get news object by id or slug
* @method static array all(array $options = []) Get all news
* @method static mixed last(int $limit = 1) Get last posts
* @method static string pages() returns pagination html generated by yii\widgets\LinkPager widget.
* @method static \stdClass pagination() returns yii\data\Pagination object.
*/
class News extends \yii\easyii\components\API
{
private $_adp;
Expand Down
16 changes: 16 additions & 0 deletions modules/page/api/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@
use yii\helpers\Url;
use yii\easyii\modules\page\models\Page as PageModel;

/**
* Page API
* @package yii\easyii\modules\page\api
*
* @method static \stdClass get(mixed $id_slug) Get page object by id or slug
*/
class Page extends \yii\easyii\components\API
{
private $_pages = [];

/**
* @param $id_slug
* @return mixed
*/
public function api_get($id_slug)
{
if(!isset($this->_pages[$id_slug])){
Expand All @@ -17,6 +27,12 @@ public function api_get($id_slug)
return $this->_pages[$id_slug];
}

/**
* Find page by id or slug
*
* @param $id_slug
* @return object
*/
private function findPage($id_slug)
{
$page = PageModel::find()->where(['or', 'page_id=:id_slug', 'slug=:id_slug'], [':id_slug' => $id_slug])->one();
Expand Down
7 changes: 7 additions & 0 deletions modules/subscribe/api/Subscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
use yii\helpers\Url;
use yii\bootstrap\ActiveForm;

/**
* Class Subscribe
* @package yii\easyii\modules\subscribe\api
*
* @method static string form() Returns fully working standalone html form.
* @method static array create(array $attributes) If you are using your own form, this function will be useful for manual saving of subscribers.
*/
class Subscribe extends \yii\easyii\components\API
{
public $options = [
Expand Down

0 comments on commit 4d16b99

Please sign in to comment.