mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 10:23:17 +00:00
#PHRAS-741 #time 15m
added 2 events
This commit is contained in:
18
lib/Alchemy/Phrasea/Core/Event/CollectionLabelChanged.php
Normal file
18
lib/Alchemy/Phrasea/Core/Event/CollectionLabelChanged.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Core\Event;
|
||||||
|
|
||||||
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
|
|
||||||
|
class CollectionLabelChanged extends CollectionRelated
|
||||||
|
{
|
||||||
|
public function getLng()
|
||||||
|
{
|
||||||
|
return $this->args['lng'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLabelBefore()
|
||||||
|
{
|
||||||
|
return $this->args['label_before'];
|
||||||
|
}
|
||||||
|
}
|
||||||
13
lib/Alchemy/Phrasea/Core/Event/CollectionNameChanged.php
Normal file
13
lib/Alchemy/Phrasea/Core/Event/CollectionNameChanged.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Core\Event;
|
||||||
|
|
||||||
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
|
|
||||||
|
class CollectionNameChanged extends CollectionRelated
|
||||||
|
{
|
||||||
|
public function getNameBefore()
|
||||||
|
{
|
||||||
|
return $this->args['name_before'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -58,4 +58,6 @@ final class PhraseaEvents
|
|||||||
const COLLECTION_MOUNTED = 'collection.mounted';
|
const COLLECTION_MOUNTED = 'collection.mounted';
|
||||||
const COLLECTION_UNMOUNTED = 'collection.unmounted';
|
const COLLECTION_UNMOUNTED = 'collection.unmounted';
|
||||||
const COLLECTION_SETTING_CHANGED = 'collection.settings.changed';
|
const COLLECTION_SETTING_CHANGED = 'collection.settings.changed';
|
||||||
|
const COLLECTION_NAME_CHANGED = 'collection.name.changed';
|
||||||
|
const COLLECTION_LABEL_CHANGED = 'collection.label.changed';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ use Alchemy\Phrasea\Core\Event\CollectionCreated;
|
|||||||
use Alchemy\Phrasea\Core\Event\CollectionDisabled;
|
use Alchemy\Phrasea\Core\Event\CollectionDisabled;
|
||||||
use Alchemy\Phrasea\Core\Event\CollectionEmptied;
|
use Alchemy\Phrasea\Core\Event\CollectionEmptied;
|
||||||
use Alchemy\Phrasea\Core\Event\CollectionEnabled;
|
use Alchemy\Phrasea\Core\Event\CollectionEnabled;
|
||||||
|
use Alchemy\Phrasea\Core\Event\CollectionLabelChanged;
|
||||||
use Alchemy\Phrasea\Core\Event\CollectionMounted;
|
use Alchemy\Phrasea\Core\Event\CollectionMounted;
|
||||||
|
use Alchemy\Phrasea\Core\Event\CollectionNameChanged;
|
||||||
use Alchemy\Phrasea\Core\Event\CollectionSettingsChanged;
|
use Alchemy\Phrasea\Core\Event\CollectionSettingsChanged;
|
||||||
use Alchemy\Phrasea\Core\Event\CollectionUnmounted;
|
use Alchemy\Phrasea\Core\Event\CollectionUnmounted;
|
||||||
|
|
||||||
@@ -271,6 +273,8 @@ class collection implements cache_cacheableInterface
|
|||||||
|
|
||||||
public function set_name($name)
|
public function set_name($name)
|
||||||
{
|
{
|
||||||
|
$old_name = $this->get_name();
|
||||||
|
|
||||||
$name = trim(strip_tags($name));
|
$name = trim(strip_tags($name));
|
||||||
|
|
||||||
if ($name === '')
|
if ($name === '')
|
||||||
@@ -288,6 +292,14 @@ class collection implements cache_cacheableInterface
|
|||||||
|
|
||||||
phrasea::reset_baseDatas($this->databox->get_appbox());
|
phrasea::reset_baseDatas($this->databox->get_appbox());
|
||||||
|
|
||||||
|
$this->app['dispatcher']->dispatch(
|
||||||
|
PhraseaEvents::COLLECTION_NAME_CHANGED,
|
||||||
|
new CollectionNameChanged(
|
||||||
|
$this,
|
||||||
|
array("name_before"=>$old_name)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,6 +309,8 @@ class collection implements cache_cacheableInterface
|
|||||||
throw new InvalidArgumentException(sprintf('Code %s is not defined', $code));
|
throw new InvalidArgumentException(sprintf('Code %s is not defined', $code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$old_label = $this->labels[$code];
|
||||||
|
|
||||||
$sql = "UPDATE coll SET label_$code = :label
|
$sql = "UPDATE coll SET label_$code = :label
|
||||||
WHERE coll_id = :coll_id";
|
WHERE coll_id = :coll_id";
|
||||||
$stmt = $this->get_connection()->prepare($sql);
|
$stmt = $this->get_connection()->prepare($sql);
|
||||||
@@ -309,6 +323,14 @@ class collection implements cache_cacheableInterface
|
|||||||
|
|
||||||
phrasea::reset_baseDatas($this->databox->get_appbox());
|
phrasea::reset_baseDatas($this->databox->get_appbox());
|
||||||
|
|
||||||
|
$this->app['dispatcher']->dispatch(
|
||||||
|
PhraseaEvents::COLLECTION_LABEL_CHANGED,
|
||||||
|
new CollectionLabelChanged(
|
||||||
|
$this,
|
||||||
|
array("lng"=>$code, "label_before"=>$old_label)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user