diff --git a/composer.json b/composer.json
index 5f2efa4..dba74d4 100644
--- a/composer.json
+++ b/composer.json
@@ -1,5 +1,5 @@
{
- "name": "keyteqlabs/keymediabundle",
+ "name": "keyteqlabs/keymedia-ezpublish-bundle",
"autoload" : {
"psr-0":{
"KTQ": "src/"
diff --git a/src/KTQ/Bundle/KeyMediaBundle/Controller/DefaultController.php b/src/KTQ/Bundle/KeyMediaBundle/Controller/DefaultController.php
deleted file mode 100755
index c0fa470..0000000
--- a/src/KTQ/Bundle/KeyMediaBundle/Controller/DefaultController.php
+++ /dev/null
@@ -1,10 +0,0 @@
-dataText = $fieldValue->data;
- $value->sortKeyString = $fieldValue->sortKey;
+ $value->dataText = $value->data;
+ $value->sortKeyString = $value->sortKey;
}
/**
* Converts data from $value to $fieldValue
*
- * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $value
- * @param \eZ\Publish\SPI\Persistence\Content\FieldValue $fieldValue
+ * @param StorageFieldValue $value
+ * @param FieldValue $fieldValue
*/
public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue)
{
@@ -50,8 +50,8 @@ public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue)
/**
* Converts field definition data in $fieldDef into $storageFieldDef
*
- * @param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDef
- * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageDef
+ * @param FieldDefinition $fieldDef
+ * @param StorageFieldDefinition $storageDef
*/
public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
{
@@ -61,8 +61,8 @@ public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageField
/**
* Converts field definition data in $storageDef into $fieldDef
*
- * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageDef
- * @param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDef
+ * @param StorageFieldDefinition $storageDef
+ * @param FieldDefinition $fieldDef
*/
public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
{
diff --git a/src/KTQ/Bundle/KeyMediaBundle/FieldType/KeyMedia/Type.php b/src/KTQ/Bundle/KeyMediaBundle/FieldType/KeyMedia/Type.php
index e99916b..aa0b3cf 100755
--- a/src/KTQ/Bundle/KeyMediaBundle/FieldType/KeyMedia/Type.php
+++ b/src/KTQ/Bundle/KeyMediaBundle/FieldType/KeyMedia/Type.php
@@ -12,6 +12,8 @@
namespace KTQ\Bundle\KeyMediaBundle\FieldType\KeyMedia;
use eZ\Publish\Core\FieldType\FieldType;
+use eZ\Publish\Core\FieldType\Value as CoreValue;
+use eZ\Publish\SPI\FieldType\Value as SpiValue;
use eZ\Publish\SPI\Persistence\Content\FieldValue;
use eZ\Publish\Core\Base\Exceptions\InvalidArgumentType;
@@ -44,7 +46,7 @@ public function getFieldTypeIdentifier()
*
* @return mixed
*/
- public function getName($value)
+ public function getName(SpiValue $value)
{
if ($value === null) {
return '';
@@ -57,11 +59,11 @@ public function getName($value)
* Returns the fallback default value of field type when no such default
* value is provided in the field definition in content types.
*
- * @return KTQ\Bundle\KeyMediaBundle\FieldType\KeyMedia\Value
+ * @return Value
*/
public function getEmptyValue()
{
- return new Value;
+ return new Value();
}
/**
@@ -69,7 +71,8 @@ public function getEmptyValue()
*
* @param mixed $inputValue
*
- * @return KTQ\Bundle\KeyMediaBundle\FieldType\KeyMedia\Value The potentially converted and structurally plausible value.
+ * @throws InvalidArgumentType
+ * @return Value The potentially converted and structurally plausible value.
*/
protected function internalAcceptValue($inputValue)
{
@@ -100,9 +103,11 @@ protected function internalAcceptValue($inputValue)
*
* @todo Sort seems to not be supported by this FieldType, is this handled correctly?
*
+ * @param CoreValue $value
+ *
* @return array
*/
- protected function getSortInfo($value)
+ protected function getSortInfo(CoreValue $value)
{
return false;
}
@@ -112,7 +117,7 @@ protected function getSortInfo($value)
*
* @param mixed $hash
*
- * @return KTQ\Bundle\KeyMediaBundle\FieldType\KeyMedia\Value $value
+ * @return Value $value
*/
public function fromHash($hash)
{
@@ -128,11 +133,11 @@ public function fromHash($hash)
/**
* Converts a Value to a hash
*
- * @param KTQ\Bundle\KeyMediaBundle\FieldType\KeyMedia\Value $value
+ * @param SpiValue $value
*
* @return mixed
*/
- public function toHash($value)
+ public function toHash(SpiValue $value)
{
if ($this->isEmptyValue($value))
return null;
@@ -162,7 +167,7 @@ public function toHash($value)
*
* @return \eZ\Publish\SPI\Persistence\Content\FieldValue the value processed by the storage engine
*/
- public function toPersistenceValue($value)
+ public function toPersistenceValue(SpiValue $value)
{
if ($value === null) {
return new FieldValue(
@@ -204,4 +209,62 @@ public function fromPersistenceValue(FieldValue $fieldValue)
);
return $v;
}
+
+ /**
+ * Inspects given $inputValue and potentially converts it into a dedicated value object.
+ *
+ * If given $inputValue could not be converted or is already an instance of dedicate value object,
+ * the method should simply return it.
+ *
+ * This is an operation method for {@see acceptValue()}.
+ *
+ * Example implementation:
+ *
+ * protected function createValueFromInput( $inputValue )
+ * {
+ * if ( is_array( $inputValue ) )
+ * {
+ * $inputValue = \eZ\Publish\Core\FieldType\CookieJar\Value( $inputValue );
+ * }
+ *
+ * return $inputValue;
+ * }
+ *
+ *
+ * @param mixed $inputValue
+ *
+ * @return mixed The potentially converted input value.
+ */
+ protected function createValueFromInput($inputValue)
+ {
+ return $inputValue;
+ }
+
+ /**
+ * Throws an exception if value structure is not of expected format.
+ *
+ * Note that this does not include validation after the rules
+ * from validators, but only plausibility checks for the general data
+ * format.
+ *
+ * This is an operation method for {@see acceptValue()}.
+ *
+ * Example implementation:
+ *
+ * protected function checkValueStructure( Value $value )
+ * {
+ * if ( !is_array( $value->cookies ) )
+ * {
+ * throw new InvalidArgumentException( "An array of assorted cookies was expected." );
+ * }
+ * }
+ *
+ *
+ * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the value does not match the expected structure.
+ *
+ * @param \eZ\Publish\Core\FieldType\Value $value
+ *
+ * @return void
+ */
+ protected function checkValueStructure(CoreValue $value) {}
}
diff --git a/src/KTQ/Bundle/KeyMediaBundle/FieldType/KeyMedia/Value.php b/src/KTQ/Bundle/KeyMediaBundle/FieldType/KeyMedia/Value.php
index 8d90aba..77c1944 100755
--- a/src/KTQ/Bundle/KeyMediaBundle/FieldType/KeyMedia/Value.php
+++ b/src/KTQ/Bundle/KeyMediaBundle/FieldType/KeyMedia/Value.php
@@ -39,4 +39,4 @@ public function __toString()
{
return json_encode($this);
}
-}
+}
\ No newline at end of file
diff --git a/src/KTQ/Bundle/KeyMediaBundle/Tests/Controller/DefaultControllerTest.php b/src/KTQ/Bundle/KeyMediaBundle/Tests/Controller/DefaultControllerTest.php
deleted file mode 100755
index 04638e9..0000000
--- a/src/KTQ/Bundle/KeyMediaBundle/Tests/Controller/DefaultControllerTest.php
+++ /dev/null
@@ -1,17 +0,0 @@
-request('GET', '/hello/Fabien');
-
- $this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0);
- }
-}