Back to FeedEntry class

Method addContributor

public \Joomla\CMS\Feed\FeedEntry
addContributor
(mixed $name, mixed $email, mixed $uri = null, mixed $type = null)
Method to add a contributor to the feed entry object.
Parameters
  • string $name The full name of the person to add.
  • string $email The email address of the person to add.
  • string $uri The optional URI for the person to add.
  • string $type The optional type of person to add.
Returns
  • \Joomla\CMS\Feed\FeedEntry
Since
  • 3.1.4
Class: FeedEntry
Project: Joomla

Method addContributor - Source code

/**
 * Method to add a contributor to the feed entry object.
 *
 * @param   string  $name   The full name of the person to add.
 * @param   string  $email  The email address of the person to add.
 * @param   string  $uri    The optional URI for the person to add.
 * @param   string  $type   The optional type of person to add.
 *
 * @return  FeedEntry
 *
 * @since   3.1.4
 */
public function addContributor($name, $email, $uri = null, $type = null)
{
    $contributor = new FeedPerson($name, $email, $uri, $type);
    // If the new contributor already exists then there is nothing to do, so just return.
    foreach ($this->properties['contributors'] as $c) {
        if ($c == $contributor) {
            return $this;
        }
    }
    // Add the new contributor.
    $this->properties['contributors'][] = $contributor;
    return $this;
}