Update for not finding package.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 14 Oct 2016 17:02:02 +0000 (13:02 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 14 Oct 2016 17:02:02 +0000 (13:02 -0400)
If you don't find the package then don't try to call the object.

package.php

index c9eb9ab..c030267 100644 (file)
@@ -5,24 +5,26 @@
 $package_id = filter_var($_REQUEST['package_id'], FILTER_VALIDATE_INT);
 if ( $package_id ) {
     $package = Toolkit_Packages_Package::fetchById(
-        Toolkit_Database::getInstance(), 
+        Toolkit_Database::getInstance(),
         $package_id
     );
-    $output = '<div id="pDetailContainer" class="row">'
-            . '<div class="small-12 columns">';
-    $output .='<h1>' . $package->getTitle() . '</h1>';
-    if ( $package->getImage() ) {
-        $output .= '<img class="pDetailImg" src=" ' . ROTATING_IMAGE_RESIZED . $package->getImage() . '">';
+    if ( is_object( $package ) && $package instanceof Toolkit_Packages_Package ) {
+        $output = '<div id="pDetailContainer" class="row">'
+                . '<div class="small-12 columns">';
+        $output .='<h1>' . $package->getTitle() . '</h1>';
+        if ( $package->getImage() ) {
+            $output .= '<img class="pDetailImg" src=" ' . ROTATING_IMAGE_RESIZED . $package->getImage() . '">';
+        }
+        $output .= '</div><div class="pBanners small-centered small-12 columns">';
+        $output .= '<div class="pSavings">'.$package->getSavings().'</div>';
+        $output .= '<div class="pDates">'.$package->getDateRange().'</div>';
+        $output .= '</div><div class="small-12 columns">';
+        $output .= $package->getDescription();
+        $output .= '</div>';
+        $output .= '</div>';
     }
-    $output .= '</div><div class="pBanners small-centered small-12 columns">';
-    $output .= '<div class="pSavings">'.$package->getSavings().'</div>';
-    $output .= '<div class="pDates">'.$package->getDateRange().'</div>';
-    $output .= '</div><div class="small-12 columns">';
-    $output .= $package->getDescription();
-    $output .= '</div>';
-    $output .= '</div>';
 }
 
 echo $output;
 ?>
-</div>
\ No newline at end of file
+</div>