Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(file): Removes the class FilePluginFile
BREAKING CHANGE: If you use the class FilePluginFile in your plugin, replace this usage with ElggFile (for construction). Load files objects with get_entity(). Fixes #7763
- Loading branch information
Showing
8 changed files
with
60 additions
and
45 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
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 |
---|---|---|
@@ -1,42 +1,15 @@ | ||
<?php | ||
|
||
/** | ||
* Override the ElggFile | ||
* | ||
* @note When extending an ElggEntity, one should always register a unique type/subtype | ||
* combination. We failed to do so here, so get_entity() and friends will always return | ||
* these objects as ElggFile. We leave it this way just for BC. | ||
* Removed subclass of ElggFile. See https://github.com/Elgg/Elgg/issues/7763 | ||
*/ | ||
class FilePluginFile extends ElggFile { | ||
protected function initializeAttributes() { | ||
parent::initializeAttributes(); | ||
|
||
// This should have been a unique subtype (see above) | ||
$this->attributes['subtype'] = "file"; | ||
} | ||
|
||
public function __construct($guid = null) { | ||
if ($guid && !is_object($guid)) { | ||
// Loading entities via __construct(GUID) is deprecated, so we give it the entity row and the | ||
// attribute loader will finish the job. This is necessary due to not using a custom | ||
// subtype (see above). | ||
$guid = get_entity_as_row($guid); | ||
} | ||
parent::__construct($guid); | ||
} | ||
|
||
public function delete() { | ||
|
||
$thumbnails = array($this->thumbnail, $this->smallthumb, $this->largethumb); | ||
foreach ($thumbnails as $thumbnail) { | ||
if ($thumbnail) { | ||
$delfile = new ElggFile(); | ||
$delfile->owner_guid = $this->owner_guid; | ||
$delfile->setFilename($thumbnail); | ||
$delfile->delete(); | ||
} | ||
} | ||
|
||
return parent::delete(); | ||
class FilePluginFile { | ||
/** | ||
* Constructor | ||
* | ||
* @throws APIException | ||
*/ | ||
public function __construct() { | ||
throw new APIException(__CLASS__ . ' is no longer available. Use ElggFile or get_entity()'); | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
$file = new FilePluginFile(); | ||
$file = new ElggFile(); | ||
|
||
$mapping = array( | ||
'general' => 'general', | ||
|