Symfony\Component\DependencyInjection\ContainerInterface::hasParameter PHP Method

hasParameter() public method

Checks if a parameter exists.
public hasParameter ( string $name ) : boolean
$name string The parameter name
return boolean The presence of parameter in container
    function hasParameter($name);

Usage Example

 /**
  * Override this method in your own implementation to configure the Cassandra cluster instance.
  */
 protected function initializeCluster()
 {
     // contact points can an array or a string, optionally having multiple
     // comma-separated node host names / IP addresses
     $contactPoints = $this->container->getParameter('cassandra_cluster.contact_points');
     if (!is_array($contactPoints)) {
         $contactPoints = implode($contactPoints, ',');
         foreach ($contactPoints as &$contactPoint) {
             $contactPoint = trim($contactPoint);
         }
     }
     $cluster = \Cassandra::cluster();
     if (PHP_VERSION_ID < 50600) {
         call_user_func_array(array($cluster, "withContactPoints"), $contactPoints);
     } else {
         // PHP > 5.6 implements variadic parameters
         $cluster->withContactPoints(...$contactPoints);
     }
     $cluster->withPersistentSessions(true);
     // always use persistent connections but be explicit about it
     if ($this->container->hasParameter('cassandra_cluster.credentials.username') && $this->container->hasParameter('cassandra_cluster.credentials.password')) {
         $username = $this->container->getParameter('cassandra_cluster.credentials.username');
         $password = $this->container->getParameter('cassandra_cluster.credentials.password');
         $cluster->withCredentials($username, $password);
     }
     $this->cluster = $cluster->build();
 }
All Usage Examples Of Symfony\Component\DependencyInjection\ContainerInterface::hasParameter