AppserverIo\Appserver\Core\Api\AppService::loadByWebappPath PHP Method

loadByWebappPath() public method

Returns the application with the passed webapp path.
public loadByWebappPath ( string $webappPath ) : AppNode | null
$webappPath string webapp path of the application to return
return AppserverIo\Appserver\Core\Api\Node\AppNode | null The application with the webapp path passed as parameter
    public function loadByWebappPath($webappPath)
    {
        foreach ($this->findAll() as $appNode) {
            if ($appNode->getWebappPath() == $webappPath) {
                return $appNode;
            }
        }
    }

Usage Example

Example #1
0
 /**
  * Tests if we can load a webapp by path
  *
  * @return null
  */
 public function testLoadByWebappPath()
 {
     $appNode = new AppNode('someappname', '/opt/appserver/targetwebapp');
     $this->appService->persist($appNode);
     $this->assertSame($appNode, $this->appService->loadByWebappPath($appNode->getWebappPath()));
     $this->assertNull($this->appService->loadByWebappPath('/absolutely/non/existing/webapp/path'));
 }