Skip to content

Version 1.8.0 - Stable

Compare
Choose a tag to compare
@phproberto phproberto released this 08 Jul 09:24

Index

  1. How to install / upgrade
  2. New Features
    2.1. hasEmptyDate(). Check if an entity date property is empty
    2.2. showNotEmptyDate(). Show a date when it's not empty
    2.3. Commands

1. How to install / upgrade

Download joomla-entity-v1.8.0.zip an install through Joomla! Extension Manager.

2. New Features

2.1. hasEmptyDate(). Check if an entity date property is empty

This function is useful when you only want to do something with a date if it's not empty. It covers all the possible empty values Joomla may find:

  • null, '', '0', '0000-00-00', '0000-00-00 00:00:00', '1971-01-01', '1971-01-01 00:00:00'
use Phproberto\Joomla\Entity\Content\Article;

$article = Article::find(2);

if (!$article->hasEmptyDate('modified'))
{
    echo $article->showDate('modified', 'Y-m-d H:i:s');
}

2.2. showNotEmptyDate(). Show a date when it's not empty

This function allows to easily show a date when it's not empty and provide a default value to show when a date is empty.

use Phproberto\Joomla\Entity\Content\Article;

$article = Article::find(2);

echo '<span class="article-date">';
	echo $article->showNotEmptyDate('modified', 'Y-m-d H:i:s', ['default' => 'Not available']);
echo '</span>';

2.3. Commands.

From this version this library will try to provide common commands required by developers to deal with files, database, entities, etc. It tries to apply the same concept behind entities. Provide a developer friendly interface to access commont tasks.

Examples:

// Drop a database table
use Phproberto\Joomla\Entity\Command\Database\DropTable;

DropTable::instance(['#__phproberto_table'])->execute();

// Empty a database table
use Phproberto\Joomla\Entity\Command\Database\EmptyTable;

EmptyTable::instance(['#__phproberto_table'])->execute();

// Execute an SQL file
use Phproberto\Joomla\Entity\Command\Database\ExecuteSQLFile;

ExecuteSQLFile::instance([__DIR__ . '/my-file.sql'])->execute();

// Delete a folder recursively
use Phproberto\Joomla\Entity\Command\FileSystem\DeleteFolderRecursively;

DeleteFolderRecursively::instance([__DIR__ . '/my-folder'])->execute();

Check Documentation for detailed information and usage examples.