-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from OPUS4/OPUSVIER-3884
OPUSVIER-3884 Convenience functions for enrichments.
- Loading branch information
Showing
4 changed files
with
277 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
* @author Pascal-Nicolas Becker <[email protected]> | ||
* @author Gunar Maiwald <[email protected]> | ||
* @author Jens Schwidder <[email protected]> | ||
* @copyright Copyright (c) 2008-2017, OPUS 4 development team | ||
* @copyright Copyright (c) 2008-2018, OPUS 4 development team | ||
* @license http://www.gnu.org/licenses/gpl.html General Public License | ||
*/ | ||
|
||
|
@@ -40,8 +40,15 @@ | |
* @category Framework | ||
* @package Opus | ||
* @uses Opus_Model_Abstract | ||
* | ||
* @method setKeyName(string $name) | ||
* @method string getKeyName() | ||
* @method setValue(string $value) | ||
* @method string getValue() | ||
*/ | ||
class Opus_Enrichment extends Opus_Model_Dependent_Abstract { | ||
class Opus_Enrichment extends Opus_Model_Dependent_Abstract | ||
{ | ||
|
||
/** | ||
* Primary key of the parent model. | ||
* | ||
|
@@ -63,16 +70,16 @@ class Opus_Enrichment extends Opus_Model_Dependent_Abstract { | |
* | ||
* @return void | ||
*/ | ||
protected function _init() { | ||
protected function _init() | ||
{ | ||
$key = new Opus_Model_Field('KeyName'); | ||
$key->setMandatory(true)->setValidator(new Zend_Validate_NotEmpty()); | ||
|
||
$value = new Opus_Model_Field('Value'); | ||
$value->setMandatory(true) | ||
->setValidator(new Zend_Validate_NotEmpty()); | ||
->setValidator(new Zend_Validate_NotEmpty()); | ||
|
||
$this->addField($key); | ||
$this->addField($value); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,9 @@ | |
* @category Framework | ||
* @package Opus | ||
* @author Gunar Maiwald <[email protected]> | ||
* @copyright Copyright (c) 2011, OPUS 4 development team | ||
* @author Jens Schwidder <[email protected]> | ||
* @copyright Copyright (c) 2011-2018, OPUS 4 development team | ||
* @license http://www.gnu.org/licenses/gpl.html General Public License | ||
* @version $Id$ | ||
*/ | ||
|
||
/** | ||
|
@@ -38,8 +38,13 @@ | |
* @category Framework | ||
* @package Opus | ||
* @uses Opus_Model_Abstract | ||
* | ||
* @method setName(string $string) | ||
* @method string getName() | ||
*/ | ||
class Opus_EnrichmentKey extends Opus_Model_AbstractDb { | ||
class Opus_EnrichmentKey extends Opus_Model_AbstractDb | ||
{ | ||
|
||
/** | ||
* Specify the table gateway. | ||
* | ||
|
@@ -52,7 +57,8 @@ class Opus_EnrichmentKey extends Opus_Model_AbstractDb { | |
* | ||
* @return array Array of Opus_EnrichmentKeys objects. | ||
*/ | ||
public static function getAll() { | ||
public static function getAll() | ||
{ | ||
return self::getAllFrom('Opus_EnrichmentKey', 'Opus_Db_EnrichmentKeys'); | ||
} | ||
|
||
|
@@ -62,7 +68,8 @@ public static function getAll() { | |
* | ||
* @return void | ||
*/ | ||
protected function _init() { | ||
protected function _init() | ||
{ | ||
$name = new Opus_Model_Field('Name'); | ||
$name->setMandatory(true) | ||
->setValidator(new Zend_Validate_NotEmpty()); | ||
|
@@ -77,7 +84,8 @@ protected function _init() { | |
* @param string $name | ||
* @return Opus_EnrichmentKey | ||
*/ | ||
public static function fetchByName($name = null) { | ||
public static function fetchByName($name = null) | ||
{ | ||
if (false === isset($name)) { | ||
return; | ||
} | ||
|
@@ -98,7 +106,8 @@ public static function fetchByName($name = null) { | |
* | ||
* @see library/Opus/Model/Opus_Model_Abstract#getDisplayName() | ||
*/ | ||
public function getDisplayName() { | ||
public function getDisplayName() | ||
{ | ||
return $this->getName(); | ||
} | ||
|
||
|
@@ -107,13 +116,13 @@ public function getDisplayName() { | |
* | ||
* @return array Array of Opus_EnrichmentKeys objects. | ||
*/ | ||
public static function getAllReferenced() { | ||
public static function getAllReferenced() | ||
{ | ||
$table = Opus_Db_TableGateway::getInstance('Opus_Db_DocumentEnrichments'); | ||
$db = $table->getAdapter(); | ||
$select = $db->select()->from(array('document_enrichments')); | ||
$select->reset('columns'); | ||
$select->columns("key_name")->distinct(true); | ||
return $db->fetchCol($select); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters