Skip to content

Commit

Permalink
replace noni static identifier() method of filters by static method
Browse files Browse the repository at this point in the history
identifier() #940
  • Loading branch information
nadar committed Aug 8, 2016
1 parent 9993c6c commit 145da7c
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 19 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ The changelog contains informations about bug fixes, new features or bc breaking
1.0.0-beta8 (in progress)
-------------------------

- `#907`: **[BC BREAK]** Removed the public attribute `$extraFields` in order to prevent confusings. Override `extraFields()` instead in `admin\ngrest\base\Model`.
- `#940` **[BC BREAK]** Making filter class method `identifier()` static to allow IDE Automplete usage of filters.
- `#907` **[BC BREAK]** Removed the public attribute `$extraFields` in order to prevent confusings. Override `extraFields()` instead in `admin\ngrest\base\Model`.
- `#836` Fixed slow processing of unneeded/orphaned files and database storage entries in StorageImporter
- `#742` Fixed parsing bug for youtube URLs with additional parameters in video block
- `#882` Added information to documentation about the 'only' publish options
Expand Down
3 changes: 2 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ This document will help you upgrading from a LUYA Version into another.
1.0.0-beta8 (in progress)
-----------

* `#907`: Removed the public attribute `$extraFields` in order to prevent confusings. Override `extraFields()` instead in `admin\ngrest\base\Model`.
* [#940](https://github.com/luyadev/luya/issues/940): The `admin\base\Filter` class for all filters requers now a **public static identifier()** method instead of a *none static* method.
* [#907](https://github.com/luyadev/luya/issues/907): Removed the public attribute `$extraFields` in order to prevent confusings. Override `extraFields()` instead in `admin\ngrest\base\Model`.


1.0.0-beta7 (released 20.06.2016)
Expand Down
12 changes: 11 additions & 1 deletion docs/guide1.0/app-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Image Filters

> since `1.0.0-beta7` we use the [Yii2 Imagine Extension](https://github.com/yiisoft/yii2-imagine) which strongly improves the behavior of creating thumbnails by auto calculating values.
> since `1.0.0-beta8` filter `identifier()` method is a **static** method.
With *Filters* you can modify, crop, resize use effects on any image provided from the storage component. To add a filter just create a filter class within the `filters` directory of your project or module and run the import command to add the filter into the system. When you change the effect chain of your filter you have to run the import command again in ordner to update all the images which are using your filter.

The basic concept behind filter classes, is to track filters in VCS system, so you can add a filter and push it into git, and your project members does have the same environement as you.
Expand All @@ -19,7 +21,7 @@ namespace app\filters;

class MyFilter extends \admin\base\Filter
{
public function identifier()
public static function identifier()
{
return 'my-filter';
}
Expand Down Expand Up @@ -84,6 +86,14 @@ Where *139* coult be the image id from your database source active record. If yo
<? endforeach; ?>
```

Since beta8 you can alos directly use the identifier method to apply filters:

```php
<? foreach($newsData as $item): ?>
<img src="<?= yii::$app->storage->getImage($item['imageId'])->applyFilter(\app\filters\MyFilter::identifier())->source; ?>" border="0" />
<? endforeach; ?>
```

the filter must be exact name like the method identifier() returns from the filter class.

> The applyFilter returns the new genearted \admin\image\Item Object where you can access other methods and informations.
Expand Down
2 changes: 1 addition & 1 deletion envs/dev/filters/TestFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class TestFilter extends Filter
{
public function identifier()
public static function identifier()
{
return 'test-filter';
}
Expand Down
10 changes: 5 additions & 5 deletions modules/admin/src/base/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract class Filter extends Object
*
* @return string The identifier must match [a-zA-Z0-9\-]
*/
abstract public function identifier();
abstract static public function identifier();

/**
* Understandable Name expression for the effect.
Expand Down Expand Up @@ -100,16 +100,16 @@ public function getLog()
public function findModel()
{
// find filter model based on the identifier
$model = StorageFilter::find()->where(['identifier' => $this->identifier()])->one();
$model = StorageFilter::find()->where(['identifier' => static::identifier()])->one();
// if no model exists, create new record
if (!$model) {
$model = new StorageFilter();
$model->setAttributes([
'name' => $this->name(),
'identifier' => $this->identifier(),
'identifier' => static::identifier(),
]);
$model->insert(false);
$this->addLog("added new filter '".$this->identifier()."' to database.");
$this->addLog("added new filter '".static::identifier()."' to database.");
}

return $model;
Expand Down Expand Up @@ -203,7 +203,7 @@ public function save()
if ($filterModel->name !== $this->name()) {
$filterModel->setAttribute('name', $this->name());
$filterModel->update(false);
$this->addLog("Filter name '".$this->name()."' have been updated for identifier '".$this->identifier()."'.");
$this->addLog("Filter name '".$this->name()."' have been updated for identifier '".static::identifier()."'.");
}
// array containing the processed chain ids
$processed = [];
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/src/filters/LargeCrop.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class LargeCrop extends \admin\base\Filter
{
public function identifier()
public static function identifier()
{
return 'large-crop';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/src/filters/LargeThumbnail.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class LargeThumbnail extends \admin\base\Filter
{
public function identifier()
public static function identifier()
{
return 'large-thumbnail';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/src/filters/MediumCrop.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class MediumCrop extends \admin\base\Filter
{
public function identifier()
public static function identifier()
{
return 'medium-crop';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/src/filters/MediumThumbnail.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class MediumThumbnail extends \admin\base\Filter
{
public function identifier()
public static function identifier()
{
return 'medium-thumbnail';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/src/filters/SmallCrop.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class SmallCrop extends \admin\base\Filter
{
public function identifier()
public static function identifier()
{
return 'small-crop';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/src/filters/SmallLandscape.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class SmallLandscape extends \admin\base\Filter
{
public function identifier()
public static function identifier()
{
return 'small-landscape';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/src/filters/SmallThumbnail.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class SmallThumbnail extends \admin\base\Filter
{
public function identifier()
public static function identifier()
{
return 'small-thumbnail';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/src/filters/TinyCrop.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class TinyCrop extends \admin\base\Filter
{
public function identifier()
public static function identifier()
{
return 'tiny-crop';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/src/filters/TinyThumbnail.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class TinyThumbnail extends \admin\base\Filter
{
public function identifier()
public static function identifier()
{
return 'tiny-thumbnail';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/tests/admin/base/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class MyFilter extends Filter
{
public function identifier()
public static function identifier()
{
return 'my-test-filter';
}
Expand Down

0 comments on commit 145da7c

Please sign in to comment.